Completed
Push — master ( 4d96cc...d35fc1 )
by Tomáš
04:03 queued 01:56
created

NamedSniffTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 5 5 1
A testRegisteredSniffs() 6 6 1

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
3
namespace Symplify\MultiCodingStandard\Tests\CodeSniffer\CodeSnifferFactory\Sniff;
4
5
use PHP_CodeSniffer;
6
use phpunit\framework\TestCase;
7
use PHPUnit_Framework_Assert;
8
use Symplify\MultiCodingStandard\Tests\ContainerFactory;
9
use SymplifyCodingStandard\Sniffs\Naming\AbstractClassNameSniff;
10
11 View Code Duplication
final class NamedSniffTest extends TestCase
0 ignored issues
show
Duplication introduced by
This class 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...
12
{
13
    /**
14
     * @var PHP_CodeSniffer
15
     */
16
    private $codeSniffer;
17
18
    protected function setUp()
19
    {
20
        $container = (new ContainerFactory())->createWithConfig(__DIR__ . '/config/config-named-sniffs.neon');
21
        $this->codeSniffer = $container->getByType(PHP_CodeSniffer::class);
22
    }
23
24
    public function testRegisteredSniffs()
25
    {
26
        $registeredSniffs = PHPUnit_Framework_Assert::getObjectAttribute($this->codeSniffer, 'sniffs');
27
        $this->assertCount(1, $registeredSniffs);
28
        // $this->assertSame([AbstractClassNameSniff::class => AbstractClassNameSniff::class], $registeredSniffs);
0 ignored issues
show
Unused Code Comprehensibility introduced by
58% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
29
    }
30
}
31