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
Push — master ( 0254c9...47ea54 )
by
unknown
01:26
created

game_connection()   A

Complexity

Conditions 2

Size

Total Lines 17

Duplication

Lines 17
Ratio 100 %

Importance

Changes 0
Metric Value
cc 2
dl 17
loc 17
rs 9.4285
c 0
b 0
f 0
1
import asyncio
0 ignored issues
show
Unused Code introduced by
The import asyncio seems to be unused.
Loading history...
2
from unittest import mock
3
import pytest
4
5
from server import LobbyConnection
6
7
8
@pytest.fixture()
9
def lobbythread():
10
    return mock.Mock(
11
        sendJSON=lambda obj: None
12
    )
13
14
15 View Code Duplication
@pytest.fixture
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
16
def game_connection(request, game, loop, player_service, players, game_service, transport):
17
    from server import GameConnection, LobbyConnection
0 ignored issues
show
Comprehensibility Bug introduced by
LobbyConnection is re-defining a name which is already available in the outer-scope (previously defined on line 5).

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...
Unused Code introduced by
The import LobbyConnection was already done on line 5. You should be able to
remove this line.
Loading history...
18
    conn = GameConnection(loop=loop,
19
                          lobby_connection=mock.create_autospec(LobbyConnection(loop)),
20
                          player_service=player_service,
21
                          games=game_service)
22
    conn._transport = transport
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like _transport was declared protected and should not be accessed from this context.

Prefixing a member variable _ is usually regarded as the equivalent of declaring it with protected visibility that exists in other languages. Consequentially, such a member should only be accessed from the same class or a child class:

class MyParent:
    def __init__(self):
        self._x = 1;
        self.y = 2;

class MyChild(MyParent):
    def some_method(self):
        return self._x    # Ok, since accessed from a child class

class AnotherClass:
    def some_method(self, instance_of_my_child):
        return instance_of_my_child._x   # Would be flagged as AnotherClass is not
                                         # a child class of MyParent
Loading history...
23
    conn.player = players.hosting
24
    conn.game = game
25
    conn.lobby = mock.Mock(spec=LobbyConnection)
26
27
    def fin():
28
        conn.abort()
29
30
    request.addfinalizer(fin)
31
    return conn
32
33
34 View Code Duplication
@pytest.fixture
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
35
def connections(loop, player_service, game_service, transport, game):
36
    from server import GameConnection
37
38
    def make_connection(player, connectivity):
39
        lc = LobbyConnection(loop)
40
        lc.protocol = mock.Mock()
41
        conn = GameConnection(loop=loop,
42
                              lobby_connection=lc,
43
                              player_service=player_service,
44
                              games=game_service)
45
        conn.player = player
46
        conn.game = game
47
        conn._transport = transport
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like _transport was declared protected and should not be accessed from this context.

Prefixing a member variable _ is usually regarded as the equivalent of declaring it with protected visibility that exists in other languages. Consequentially, such a member should only be accessed from the same class or a child class:

class MyParent:
    def __init__(self):
        self._x = 1;
        self.y = 2;

class MyChild(MyParent):
    def some_method(self):
        return self._x    # Ok, since accessed from a child class

class AnotherClass:
    def some_method(self, instance_of_my_child):
        return instance_of_my_child._x   # Would be flagged as AnotherClass is not
                                         # a child class of MyParent
Loading history...
48
        conn._connectivity_state.set_result(connectivity)
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like _connectivity_state was declared protected and should not be accessed from this context.

Prefixing a member variable _ is usually regarded as the equivalent of declaring it with protected visibility that exists in other languages. Consequentially, such a member should only be accessed from the same class or a child class:

class MyParent:
    def __init__(self):
        self._x = 1;
        self.y = 2;

class MyChild(MyParent):
    def some_method(self):
        return self._x    # Ok, since accessed from a child class

class AnotherClass:
    def some_method(self, instance_of_my_child):
        return instance_of_my_child._x   # Would be flagged as AnotherClass is not
                                         # a child class of MyParent
Loading history...
49
        return conn
50
51
    return mock.Mock(
52
        make_connection=make_connection
53
    )
54