MethodNameUnderstandableTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 59
Duplicated Lines 50.85 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 2
Bugs 1 Features 1
Metric Value
wmc 4
c 2
b 1
f 1
lcom 1
cbo 5
dl 30
loc 59
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testIgnoreMethodsWithoutTestPrefix() 10 10 1
A testMoreWordsInMethod() 10 10 1
A testLessWordsInMethod() 10 10 1
A getRule() 0 8 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 MS\PHPMD\Tests\Unit\Test;
4
5
use MS\PHPMD\Rule\Test\MethodNameUnderstandable;
6
7
/**
8
 * Class MethodNameUnderstandableTest
9
 *
10
 * @package MS\PHPMD\Tests\Unit\Test
11
 */
12
class MethodNameUnderstandableTest extends AbstractClassTest
13
{
14
    /**
15
     * @covers MS\PHPMD\Rule\Test\MethodNameUnderstandable
16
     * @covers MS\PHPMD\Rule\Test\AbstractTestRule
17
     */
18 View Code Duplication
    public function testIgnoreMethodsWithoutTestPrefix()
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...
19
    {
20
        $methodNode = $this->getMethodNode(self::CLASS_NAME, 'getEntityManager');
21
22
        $node = \Mockery::mock('PHPMD\Node\ClassNode');
23
        $node->shouldReceive('getImage')->andReturn(self::CLASS_NAME);
24
        $node->shouldReceive('getMethods')->andReturn([$methodNode]);
25
26
        $this->assertRule($node, 0);
27
    }
28
29
    /**
30
     * @covers MS\PHPMD\Rule\Test\MethodNameUnderstandable
31
     * @covers MS\PHPMD\Rule\Test\AbstractTestRule
32
     */
33 View Code Duplication
    public function testMoreWordsInMethod()
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...
34
    {
35
        $methodNode = $this->getMethodNode(self::CLASS_NAME, 'testCanAddTwoNumbers');
36
37
        $node = \Mockery::mock('PHPMD\Node\ClassNode');
38
        $node->shouldReceive('getImage')->andReturn(self::CLASS_NAME);
39
        $node->shouldReceive('getMethods')->andReturn([$methodNode]);
40
41
        $this->assertRule($node, 0);
42
    }
43
44
    /**
45
     * @covers MS\PHPMD\Rule\Test\MethodNameUnderstandable
46
     * @covers MS\PHPMD\Rule\Test\AbstractTestRule
47
     */
48 View Code Duplication
    public function testLessWordsInMethod()
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...
49
    {
50
        $methodNode = $this->getMethodNode(self::CLASS_NAME, 'testAdd');
51
52
        $node = \Mockery::mock('PHPMD\Node\ClassNode');
53
        $node->shouldReceive('getImage')->andReturn(self::CLASS_NAME);
54
        $node->shouldReceive('getMethods')->andReturn([$methodNode]);
55
56
        $this->assertRule($node, 1);
57
    }
58
59
    /**
60
     * @return MethodNameUnderstandable
61
     */
62
    protected function getRule()
63
    {
64
        $rule =  new MethodNameUnderstandable();
65
        $rule->addProperty('number', '3');
66
        $rule->addProperty('regex', '([A-Z])');
67
68
        return $rule;
69
    }
70
}
71