Completed
Pull Request — master (#1)
by Harry
03:02
created

ServiceCheckTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 69
Duplicated Lines 82.61 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A testSimpleServiceCheck() 0 5 1
A testMetaData() 15 15 1
A testTags() 16 16 1
A testMessageIsAfterTags() 16 16 1
A testCoreStatsDImplementation() 10 10 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 Graze\DogStatsD\Test\Unit;
4
5
use Graze\DogStatsD\Client;
6
use Graze\DogStatsD\Test\TestCase;
7
8
class ServiceCheckTest extends TestCase
9
{
10
    public function testSimpleServiceCheck()
11
    {
12
        $this->client->serviceCheck('service.api', Client::STATUS_OK);
13
        $this->assertEquals('_sc|service.api|0', $this->client->getLastMessage());
14
    }
15
16 View Code Duplication
    public function testMetaData()
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...
17
    {
18
        $this->client->serviceCheck(
19
            'service.api',
20
            Client::STATUS_CRITICAL,
21
            [
22
                'time'     => 12345678,
23
                'hostname' => 'some.host',
24
            ]
25
        );
26
        $this->assertEquals(
27
            '_sc|service.api|2|d:12345678|h:some.host',
28
            $this->client->getLastMessage()
29
        );
30
    }
31
32 View Code Duplication
    public function testTags()
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...
33
    {
34
        $this->client->serviceCheck(
35
            'service.api',
36
            Client::STATUS_WARNING,
37
            [
38
                'time'     => 12345678,
39
                'hostname' => 'some.host',
40
            ],
41
            ['tag']
42
        );
43
        $this->assertEquals(
44
            '_sc|service.api|1|d:12345678|h:some.host|#tag',
45
            $this->client->getLastMessage()
46
        );
47
    }
48
49 View Code Duplication
    public function testMessageIsAfterTags()
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...
50
    {
51
        $this->client->serviceCheck(
52
            'service.api',
53
            Client::STATUS_UNKNOWN,
54
            [
55
                'time'    => 12345678,
56
                'message' => 'some_message',
57
            ],
58
            ['tag']
59
        );
60
        $this->assertEquals(
61
            '_sc|service.api|3|d:12345678|#tag|m:some_message',
62
            $this->client->getLastMessage()
63
        );
64
    }
65
66 View Code Duplication
    public function testCoreStatsDImplementation()
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...
67
    {
68
        $this->client->configure(array(
69
            'host' => '127.0.0.1',
70
            'port' => 8125,
71
            'dataDog' => false
72
        ));
73
        $this->client->serviceCheck('service.api', Client::STATUS_OK);
74
        $this->assertEquals('', $this->client->getLastMessage());
75
    }
76
}
77