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

QueryMaxDepthTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 82
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
c 2
b 0
f 0
lcom 1
cbo 1
dl 82
loc 82
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 QueryMaxDepthTest extends TestCase
8
{
9
    private $userFriendsWithoutViolationQuery = <<<'EOF'
10
query {
11
  user {
12
    friends(first:1) {
13
      edges {
14
        node {
15
          name
16
        }
17
      }
18
    }
19
  }
20
}
21
EOF;
22
23
    private $userFriendsWithViolationQuery = <<<'EOF'
24
query {
25
  user {
26
    friends(first: 1) {
27
      edges {
28
        node {
29
          name
30
          friends {
31
            edges {
32
              node {
33
                name
34
              }
35
            }
36
          }
37
        }
38
      }
39
    }
40
  }
41
}
42
EOF;
43
44
    public function testMaxDepthReachLimitation()
45
    {
46
        $expected = [
47
            'errors' => [
48
                [
49
                    'message' => 'Max query depth should be 3 but got 6.',
50
                    'category' => 'graphql',
51
                ],
52
            ],
53
        ];
54
55
        $this->assertResponse($this->userFriendsWithViolationQuery, $expected, self::ANONYMOUS_USER, 'queryMaxDepth');
56
    }
57
58
    public function testMaxDepthReachLimitationEnv()
59
    {
60
        $expected = [
61
            'errors' => [
62
                [
63
                    'message' => 'Max query depth should be 3 but got 6.',
64
                    'category' => 'graphql',
65
                ],
66
            ],
67
        ];
68
69
        $this->assertResponse($this->userFriendsWithViolationQuery, $expected, self::ANONYMOUS_USER, 'queryMaxDepthEnv');
70
    }
71
72
    public function testComplexityUnderLimitation()
73
    {
74
        $expected = [
75
            'data' => [
76
                'user' => [
77
                    'friends' => [
78
                        'edges' => [
79
                            ['node' => ['name' => 'Nick']],
80
                        ],
81
                    ],
82
                ],
83
            ],
84
        ];
85
86
        $this->assertResponse($this->userFriendsWithoutViolationQuery, $expected, self::ANONYMOUS_USER, 'queryMaxDepth');
87
    }
88
}
89