Skip to content
Closed
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
131 changes: 25 additions & 106 deletions tests/Fixture/Math.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,175 +46,94 @@
*/
class PhpUnderControl_Example_Math
{
/**
* Adds the two given values.
*
* @param integer $v1 Value one.
* @param integer $v2 Value two.
*
* @return integer.
*/
public function add($v1, $v2)
{
return ($v1 + $v2);
}

/**
* Subtract param two from param one
*
* @param integer $v1 Value one.
* @param integer $v2 Value two.
*
* @return integer.
*/
public function sub($v1, $v2)
{
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.
* Adds the two given values.
*
* @param integer $v1 Value one.
* @param integer $v2 Value two.
*
* @return integer.
*/
public function add($v1, $v2)
{
return ($v1 + $v2);
}

/**
* Subtract param two from param one
*
* @param integer $v1 Value one.
* @param integer $v2 Value two.
*
* @return integer.
*/
#[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 sub($v1, $v2)
{
return ($v1 - $v2);
}

public function div($v1, $v2)
{
$v3 = $v1 / ($v2 + $v1);
if ($v3 > 14)
Expand Down
Loading