Completed
Pull Request — master (#30)
by Scott
02:51
created

PhpCsReflectionTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 57
Duplicated Lines 38.6 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 2
Bugs 1 Features 0
Metric Value
dl 22
loc 57
rs 10
c 2
b 1
f 0
wmc 4
lcom 1
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
B testRelatedMethods() 0 31 2
A testRelatedMethodsFileNotFound() 22 22 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
namespace exussum12\CoverageChecker\tests;
3
4
use Exception;
5
use PHPUnit\Framework\TestCase;
6
7
/**
8
 * Ignored due to acceptance test needing to write values
9
 * @SuppressWarnings(PHPMD.Superglobals)
10
 */
11
class PhpCsReflectionTest extends TestCase
12
{
13
    public function testRelatedMethods()
14
    {
15
        $GLOBALS['argv'] = [
16
            'diffFilter',
17
            '--phpcs',
18
            '--report=json',
19
            __DIR__ . '/fixtures/DocBlocks.txt',
20
            __DIR__ . '/fixtures/DocBlocks.json'
21
        ];
22
23
        try {
24
            ob_start();
25
            require(__DIR__ . "/../src/Runners/generic.php");
26
        } catch (Exception $exception) {
27
            $output = json_decode(ob_get_clean());
28
            $file = $output->violations->{'DocBlocks.php'};
29
            $this->assertEquals(
30
                14,
31
                count($file)
32
            );
33
34
            $this->assertEquals(
35
                5,
36
                count($file[12]->message)
37
            );
38
39
            return true;
40
        }
41
42
        $this->fail('Exception not thrown when Expected');
43
    }
44
45 View Code Duplication
    public function testRelatedMethodsFileNotFound()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
46
    {
47
        $GLOBALS['argv'] = [
48
            'diffFilter',
49
            '--phpcs',
50
            '--report=json',
51
            __DIR__ . '/fixtures/DocBlocks.txt',
52
            __DIR__ . '/fixtures/DocBlocksNotFound.json'
53
        ];
54
55
        try {
56
            ob_start();
57
            require(__DIR__ . "/../src/Runners/generic.php");
58
        } catch (Exception $exception) {
59
            $output = ob_get_clean();
60
            $this->assertContains("Can't find file", $output);
61
62
            return true;
63
        }
64
65
        $this->fail('Exception not thrown when Expected');
66
    }
67
}
68