Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
- name: Test latest PHPCPD release
run: php ./releases/phpcpd-9.1.0.phar --log-sarif=reports/phpcpd/phpcpd-report.sarif src tests
- name: Upload SARIF report to GitHub
uses: github/codeql-action/upload-sarif@v3
uses: github/codeql-action/upload-sarif@v4
if: always()
with:
sarif_file: reports/phpcpd/phpcpd-report.sarif
Expand Down
83 changes: 1 addition & 82 deletions tests/Fixture/Math.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,149 +72,68 @@
return ($v1 - $v2);
}

/**
* Not tested method that should be visible with low coverage.
* Note: Added check for skipping php attributes.
*/
#[ORM\Entity]
#[ORM\Table(name: 'api_key')]
#[Groups([
'ApiKey',
'ApiKey.id',
'LogRequest.apiKey',
])]
#[OA\Response(
response: 401,
description: 'Invalid token (not found or expired)',
content: new JsonContent(
properties: [
new Property(property: 'code', description: 'Error code', type: 'integer'),
new Property(property: 'message', description: 'Error description', type: 'string'),
],
type: 'object',
example: [
'code' => 401,
'message' => 'JWT Token not found',
],
),
)]
#[OA\Response(
response: 403,
description: 'Access denied',
content: new JsonContent(
properties: [
new Property(property: 'code', description: 'Error code', type: 'integer'),
new Property(property: 'message', description: 'Error description', type: 'string'),
],
type: 'object',
example: [
'code' => 403,
'message' => 'Access denied',
],
),
)]
public function div($v1, $v2)
{
$v3 = $v1 / ($v2 + $v1);
if ($v3 > 14)
{
$v4 = 0;
for ($i = 0; $i < $v3; $i++)
{
$v4 += ($v2 * $i);
}
}
$v5 = ($v4 < $v3 ? ($v3 - $v4) : ($v4 - $v3));

$v6 = ($v1 * $v2 * $v3 * $v4 * $v5);

$d = array($v1, $v2, $v3, $v4, $v5, $v6);

$v7 = 1;
for ($i = 0; $i < $v6; $i++)
{
shuffle( $d );
$v7 = $v7 + $i * end($d);
}

$v8 = $v7;
foreach ( $d as $x )
{
$v8 *= $x;
}

$v3 = $v1 / ($v2 + $v1);
if ($v3 > 14)
{
$v4 = 0;
for ($i = 0; $i < $v3; $i++)
{
$v4 += ($v2 * $i);
}
}
$v5 = ($v4 < $v3 ? ($v3 - $v4) : ($v4 - $v3));

$v6 = ($v1 * $v2 * $v3 * $v4 * $v5);

$d = array($v1, $v2, $v3, $v4, $v5, $v6);

$v7 = 1;
for ($i = 0; $i < $v6; $i++)
{
shuffle( $d );
$v7 = $v7 + $i * end($d);
}

$v8 = $v7;
foreach ( $d as $x )
{
$v8 *= $x;
}

return $v8;
}

Check warning

Code scanning / phpcpd

Code duplication detected. Warning test

Found '59' lines of 'inconsistent' duplicated code.

/**
* Simple copy for cpd detection.
*/
#[ORM\Entity]
#[ORM\Table(name: 'api_key')]
#[Groups([
'ApiKey',
'ApiKey.id',
'LogRequest.apiKey',
])]
#[OA\Response(
response: 401,
description: 'Invalid token (not found or expired)',
content: new JsonContent(
properties: [
new Property(property: 'code', description: 'Error code', type: 'integer'),
new Property(property: 'message', description: 'Error description', type: 'string'),
],
type: 'object',
example: [
'code' => 401,
'message' => 'JWT Token not found',
],
),
)]
#[OA\Response(
response: 403,
description: 'Access denied',
content: new JsonContent(
properties: [
new Property(property: 'code', description: 'Error code', type: 'integer'),
new Property(property: 'message', description: 'Error description', type: 'string'),
],
type: 'object',
example: [
'code' => 403,
'message' => 'Access denied',
],
),
)]
public function complex($v1, $v2)
public function div($v1, $v2)
{
$v3 = $v1 / ($v2 + $v1);
if ($v3 > 14)
Expand Down
Loading