| Total Complexity | 5 |
| Total Lines | 73 |
| Duplicated Lines | 65.75 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
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 |
||
| 20 | class ControllerAnnotatorTest extends SapphireTest |
||
| 21 | { |
||
| 22 | /** |
||
| 23 | * @var MockDataObjectAnnotator |
||
|
1 ignored issue
–
show
|
|||
| 24 | */ |
||
| 25 | private $annotator; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * @var AnnotatePermissionChecker $permissionChecker |
||
| 29 | */ |
||
| 30 | private $permissionChecker; |
||
| 31 | |||
| 32 | /** |
||
| 33 | * Setup Defaults |
||
| 34 | */ |
||
| 35 | View Code Duplication | public function setUp() |
|
| 36 | { |
||
| 37 | parent::setUp(); |
||
| 38 | Config::modify()->set(DataObjectAnnotator::class, 'enabled', true); |
||
| 39 | Config::modify()->set(DataObjectAnnotator::class, 'enabled_modules', ['ideannotator']); |
||
| 40 | |||
| 41 | $this->annotator = Injector::inst()->get(MockDataObjectAnnotator::class); |
||
| 42 | $this->permissionChecker = Injector::inst()->get(AnnotatePermissionChecker::class); |
||
| 43 | } |
||
| 44 | |||
| 45 | View Code Duplication | public function testPageGetsAnnotated() |
|
| 54 | } |
||
| 55 | |||
| 56 | View Code Duplication | public function testPageControllerGetsAnnotator() |
|
| 57 | { |
||
| 58 | $classInfo = new AnnotateClassInfo(AnnotatorPageTestController::class); |
||
|
1 ignored issue
–
show
|
|||
| 59 | $filePath = $classInfo->getClassFilePath(); |
||
| 60 | |||
| 61 | $content = $this->annotator->getGeneratedFileContent( |
||
| 62 | file_get_contents($filePath), |
||
| 63 | AnnotatorPageTestController::class |
||
| 64 | ); |
||
| 65 | |||
| 66 | $this->assertContains(' * Class \SilverLeague\IDEAnnotator\Tests\AnnotatorPageTestController', $content); |
||
| 67 | $this->assertContains('@property \SilverLeague\IDEAnnotator\Tests\AnnotatorPageTest dataRecord', $content); |
||
| 68 | $this->assertContains('@method \SilverLeague\IDEAnnotator\Tests\AnnotatorPageTest data()', $content); |
||
| 69 | $this->assertContains('@mixin \SilverLeague\IDEAnnotator\Tests\AnnotatorPageTest', $content); |
||
| 70 | $this->assertContains('@mixin \SilverLeague\IDEAnnotator\Tests\AnnotatorPageTest_Extension', $content); |
||
| 71 | } |
||
| 72 | |||
| 73 | /** |
||
| 74 | * Test the generation of annotations for an Extension |
||
| 75 | */ |
||
| 76 | View Code Duplication | public function testAnnotateControllerExtension() |
|
| 77 | { |
||
| 78 | $classInfo = new AnnotateClassInfo(AnnotatorPageTest_Extension::class); |
||
|
1 ignored issue
–
show
|
|||
| 79 | $filePath = $classInfo->getClassFilePath(); |
||
| 80 | $original = file_get_contents($filePath); |
||
| 81 | $annotated = $this->annotator->getGeneratedFileContent($original, AnnotatorPageTest_Extension::class); |
||
| 82 | |||
| 83 | $this->assertContains(' * Class \SilverLeague\IDEAnnotator\Tests\AnnotatorPageTest_Extension', $annotated); |
||
| 84 | $this->assertContains( |
||
| 85 | '@property \SilverLeague\IDEAnnotator\Tests\AnnotatorPageTestController|\SilverLeague\IDEAnnotator\Tests\AnnotatorPageTest_Extension $owner', |
||
| 86 | $annotated |
||
| 87 | ); |
||
| 88 | } |
||
| 89 | |||
| 90 | public function tearDown() |
||
| 93 | } |
||
| 94 | } |
||
| 95 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths