Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Passed
Pull Request — master (#277)
by Jérémiah
14:57
created

QueryComplexityTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 75
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 1
cbo 1
dl 75
loc 75
rs 10

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 Overblog\GraphQLBundle\Tests\Functional\Security;
4
5
use Overblog\GraphQLBundle\Tests\Functional\TestCase;
6
7
class QueryComplexityTest extends TestCase
8
{
9
    private $userFriendsWithoutLimitQuery = <<<'EOF'
10
query {
11
  user {
12
    friends {
13
      edges {
14
        node {
15
          name
16
        }
17
      }
18
    }
19
  }
20
}
21
EOF;
22
23
    private $userFriendsWithLimitQuery = <<<'EOF'
24
query {
25
  user {
26
    friends(first: 1) {
27
      edges {
28
        node {
29
          name
30
        }
31
      }
32
    }
33
  }
34
}
35
EOF;
36
37
    public function testComplexityReachLimitation()
38
    {
39
        $expected = [
40
            'errors' => [
41
                [
42
                    'message' => 'Max query complexity should be 10 but got 54.',
43
                    'category' => 'graphql',
44
                ],
45
            ],
46
        ];
47
48
        $this->assertResponse($this->userFriendsWithoutLimitQuery, $expected, self::ANONYMOUS_USER, 'queryComplexity');
49
    }
50
51
    public function testComplexityReachLimitationEnv()
52
    {
53
        $expected = [
54
            'errors' => [
55
                [
56
                    'message' => 'Max query complexity should be 10 but got 54.',
57
                    'category' => 'graphql',
58
                ],
59
            ],
60
        ];
61
62
        $this->assertResponse($this->userFriendsWithoutLimitQuery, $expected, self::ANONYMOUS_USER, 'queryComplexityEnv');
63
    }
64
65
    public function testComplexityUnderLimitation()
66
    {
67
        $expected = [
68
            'data' => [
69
                'user' => [
70
                    'friends' => [
71
                        'edges' => [
72
                            ['node' => ['name' => 'Nick']],
73
                        ],
74
                    ],
75
                ],
76
            ],
77
        ];
78
79
        $this->assertResponse($this->userFriendsWithLimitQuery, $expected, self::ANONYMOUS_USER, 'queryComplexity');
80
    }
81
}
82