GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — develop (#307)
by
unknown
42s
created

test_match_winner_ascends_league()   C

Complexity

Conditions 13

Size

Total Lines 16

Duplication

Lines 16
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 13
c 1
b 0
f 1
dl 16
loc 16
rs 5.2936

How to fix   Complexity   

Complexity

Complex classes like test_match_winner_ascends_league() often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

1
# coding=utf-8
2
import pytest
3
from server.stats.division_service import *
0 ignored issues
show
Coding Style introduced by
The usage of wildcard imports like server.stats.division_service should generally be avoided.
Loading history...
Unused Code introduced by
Dict was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
logging was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
logger was imported with wildcard, but is not used.
Loading history...
4
5
6
@pytest.fixture()
7
def sample_divisions() -> List[Division]:
8
    return [Division(1, "League 1 - Division A", 1, 10.0),
9
            Division(2, "League 1 - Division B", 1, 30.0),
10
            Division(3, "League 1 - Division C", 1, 50.0),
11
            Division(4, "League 2 - Division D", 2, 20.0),
12
            Division(5, "League 2 - Division E", 2, 60.0),
13
            Division(6, "League 2 - Division F", 2, 100.0),
14
            Division(7, "League 3 - Division D", 3, 100.0),
15
            Division(8, "League 3 - Division E", 3, 200.0),
16
            Division(9, "League 3 - Division F", 3, 9999.0)]
17
18
19
@pytest.fixture()
20
def sample_players() -> List[PlayerDivisionInfo]:
21
    return [PlayerDivisionInfo(1, 1, 9.5),
22
            PlayerDivisionInfo(2, 1, 49.5),
23
            PlayerDivisionInfo(3, 2, 0.0),
24
            PlayerDivisionInfo(4, 3, 10.0)]
25
26
27
@pytest.fixture()
28
def division_service(sample_divisions, sample_players) -> DivisionService:
0 ignored issues
show
Comprehensibility Bug introduced by
sample_divisions is re-defining a name which is already available in the outer-scope (previously defined on line 7).

It is generally a bad practice to shadow variables from the outer-scope. In most cases, this is done unintentionally and might lead to unexpected behavior:

param = 5

class Foo:
    def __init__(self, param):   # "param" would be flagged here
        self.param = param
Loading history...
Comprehensibility Bug introduced by
sample_players is re-defining a name which is already available in the outer-scope (previously defined on line 20).

It is generally a bad practice to shadow variables from the outer-scope. In most cases, this is done unintentionally and might lead to unexpected behavior:

param = 5

class Foo:
    def __init__(self, param):   # "param" would be flagged here
        self.param = param
Loading history...
29
    return DivisionService(sample_divisions, sample_players)
30
31
32 View Code Duplication
def test_match_in_same_division(division_service):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
Comprehensibility Bug introduced by
division_service is re-defining a name which is already available in the outer-scope (previously defined on line 28).

It is generally a bad practice to shadow variables from the outer-scope. In most cases, this is done unintentionally and might lead to unexpected behavior:

param = 5

class Foo:
    def __init__(self, param):   # "param" would be flagged here
        self.param = param
Loading history...
33
    assert division_service.players[1].league == 1
34
    assert division_service.players[1].score == 9.5
35
    assert division_service.get_player_division(1).id == 1
36
    assert division_service.players[2].league == 1
37
    assert division_service.players[2].score == 49.5
38
    assert division_service.get_player_division(2).id == 3
39
40
    division_service.post_result(1,2, True)
41
42
    assert division_service.players[1].league == 1
43
    assert division_service.players[1].score == 10.5
44
    assert division_service.get_player_division(1).id == 2
45
    assert division_service.players[2].league == 1
46
    assert division_service.players[2].score == 49.0
47
    assert division_service.get_player_division(2).id == 3
48
49
50 View Code Duplication
def test_match_in_same_division_inverted(division_service):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
Comprehensibility Bug introduced by
division_service is re-defining a name which is already available in the outer-scope (previously defined on line 28).

It is generally a bad practice to shadow variables from the outer-scope. In most cases, this is done unintentionally and might lead to unexpected behavior:

param = 5

class Foo:
    def __init__(self, param):   # "param" would be flagged here
        self.param = param
Loading history...
51
    assert division_service.players[1].league == 1
52
    assert division_service.players[1].score == 9.5
53
    assert division_service.get_player_division(1).id == 1
54
    assert division_service.players[2].league == 1
55
    assert division_service.players[2].score == 49.5
56
    assert division_service.get_player_division(2).id == 3
57
58
    division_service.post_result(2,1, False)
59
60
    assert division_service.players[1].league == 1
61
    assert division_service.players[1].score == 10.5
62
    assert division_service.get_player_division(1).id == 2
63
    assert division_service.players[2].league == 1
64
    assert division_service.players[2].score == 49.0
65
    assert division_service.get_player_division(2).id == 3
66
67
68 View Code Duplication
def test_match_winner_ascends_league(division_service):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
Comprehensibility Bug introduced by
division_service is re-defining a name which is already available in the outer-scope (previously defined on line 28).

It is generally a bad practice to shadow variables from the outer-scope. In most cases, this is done unintentionally and might lead to unexpected behavior:

param = 5

class Foo:
    def __init__(self, param):   # "param" would be flagged here
        self.param = param
Loading history...
69
    assert division_service.players[1].league == 1
70
    assert division_service.players[1].score == 9.5
71
    assert division_service.get_player_division(1).id == 1
72
    assert division_service.players[2].league == 1
73
    assert division_service.players[2].score == 49.5
74
    assert division_service.get_player_division(2).id == 3
75
76
    division_service.post_result(2,1, True)
77
78
    assert division_service.players[1].league == 1
79
    assert division_service.players[1].score == 9.0
80
    assert division_service.get_player_division(1).id == 1
81
    assert division_service.players[2].league == 2
82
    assert division_service.players[2].score == 0.0
83
    assert division_service.get_player_division(2).id == 4
84
85
86
def test_do_not_fall_below_0(division_service):
0 ignored issues
show
Comprehensibility Bug introduced by
division_service is re-defining a name which is already available in the outer-scope (previously defined on line 28).

It is generally a bad practice to shadow variables from the outer-scope. In most cases, this is done unintentionally and might lead to unexpected behavior:

param = 5

class Foo:
    def __init__(self, param):   # "param" would be flagged here
        self.param = param
Loading history...
87
    assert division_service.players[1].league == 1
88
    assert division_service.players[1].score == 9.5
89
    assert division_service.players[3].league == 2
90
    assert division_service.players[3].score == 0.0
91
92
    division_service.post_result(1,3, True)
93
94
    assert division_service.players[1].league == 1
95
    assert division_service.players[1].score == 11.0
96
    assert division_service.players[3].league == 2
97
    assert division_service.players[3].score == 0.0
98
99
100 View Code Duplication
def test_gain_loss_winner_inferior(division_service):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
Comprehensibility Bug introduced by
division_service is re-defining a name which is already available in the outer-scope (previously defined on line 28).

It is generally a bad practice to shadow variables from the outer-scope. In most cases, this is done unintentionally and might lead to unexpected behavior:

param = 5

class Foo:
    def __init__(self, param):   # "param" would be flagged here
        self.param = param
Loading history...
101
    division_service.players[3].score = 11.0
102
103
    assert division_service.players[1].league == 1
104
    assert division_service.players[1].score == 9.5
105
    assert division_service.players[3].league == 2
106
    assert division_service.players[3].score == 11.0
107
108
    division_service.post_result(1,3, True)
109
110
    assert division_service.players[1].league == 1
111
    assert division_service.players[1].score == 11.0
112
    assert division_service.players[3].league == 2
113
    assert division_service.players[3].score == 10.0
114
115
116 View Code Duplication
def test_gain_loss_winner_superior(division_service):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
Comprehensibility Bug introduced by
division_service is re-defining a name which is already available in the outer-scope (previously defined on line 28).

It is generally a bad practice to shadow variables from the outer-scope. In most cases, this is done unintentionally and might lead to unexpected behavior:

param = 5

class Foo:
    def __init__(self, param):   # "param" would be flagged here
        self.param = param
Loading history...
117
    division_service.players[3].score = 11.0
118
119
    assert division_service.players[1].league == 1
120
    assert division_service.players[1].score == 9.5
121
    assert division_service.players[3].league == 2
122
    assert division_service.players[3].score == 11.0
123
124
    division_service.post_result(1,3, False)
125
126
    assert division_service.players[1].league == 1
127
    assert division_service.players[1].score == 9.0
128
    assert division_service.players[3].league == 2
129
    assert division_service.players[3].score == 11.5
130
131
132
def test_new_player(division_service):
0 ignored issues
show
Comprehensibility Bug introduced by
division_service is re-defining a name which is already available in the outer-scope (previously defined on line 28).

It is generally a bad practice to shadow variables from the outer-scope. In most cases, this is done unintentionally and might lead to unexpected behavior:

param = 5

class Foo:
    def __init__(self, param):   # "param" would be flagged here
        self.param = param
Loading history...
133
    assert 98 not in division_service.players
134
    assert 99 not in division_service.players
135
136
    division_service.post_result(98,99, False)
137
138
    assert division_service.players[98].league == 1
139
    assert division_service.players[98].score == 0.0
140
    assert division_service.players[99].league == 1
141
    assert division_service.players[99].score == 1.0
0 ignored issues
show
Coding Style introduced by
Final newline missing
Loading history...