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.
Passed
Pull Request — master (#3)
by Oleg
02:37
created

SpawnerCommand   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 29
ccs 0
cts 9
cp 0
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 12 2
1
"""
2
Enarksh
3
4
Copyright 2013-2016 Set Based IT Consultancy
5
6
Licence MIT
7
"""
8
# ----------------------------------------------------------------------------------------------------------------------
9
from cleo import Command
10
11
from enarksh.Spawner.Spawner import Spawner
12
from enarksh.style.EnarkshStyle import EnarkshStyle
13
14
15
# ----------------------------------------------------------------------------------------------------------------------
16
class SpawnerCommand(Command):
17
    """
18
    Starts the spawner.
19
    """
20
21
    name = 'spawner'
22
23
    options = [
24
        {
25
            'name': 'daemonize',
26
            'shortcut': 'd',
27
            'flag': True,
28
            'description': 'If set, use demonize'
29
        }
30
    ]
31
32
    # ------------------------------------------------------------------------------------------------------------------
33
    def handle(self):
34
        """
35
        Executes the logger command.
36
        """
37
        self._io = EnarkshStyle(self.input, self.output)
0 ignored issues
show
Coding Style introduced by
The attribute _io was defined outside __init__.

It is generally a good practice to initialize all attributes to default values in the __init__ method:

class Foo:
    def __init__(self, x=None):
        self.x = x
Loading history...
38
39
        spawner = Spawner()
40
41
        if self.option('daemonize'):
42
            spawner._daemonize()
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like _daemonize 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...
43
44
        spawner.main()
45
46
47
# ----------------------------------------------------------------------------------------------------------------------
48