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
Push — master ( 73a429...82b18e )
by Andrew
01:13
created

DictJugglerTaskDepends.load_from_issue()   B

Complexity

Conditions 5

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 5
c 1
b 0
f 0
dl 0
loc 9
rs 8.5454
1
# json parser implementation
2
from juggler import *
0 ignored issues
show
introduced by
Unable to import 'juggler'
Loading history...
Coding Style introduced by
The usage of wildcard imports like juggler should generally be avoided.
Loading history...
3
import json, re, math
0 ignored issues
show
introduced by
Multiple imports on one line (json, re, math)
Loading history...
introduced by
standard import "import json, re, math" should be placed before "from juggler import *"
Loading history...
4
5
class DictJugglerTaskDepends(JugglerTaskDepends):
0 ignored issues
show
Comprehensibility Best Practice introduced by
Undefined variable 'JugglerTaskDepends'
Loading history...
6
    def load_from_issue(self, issue):
7
        """
8
        Args:
9
            issue["depends"] - a list of identifiers that this task depends on
10
        """
11
        if "depends" in issue: 
0 ignored issues
show
Coding Style introduced by
Trailing whitespace
Loading history...
12
            if isinstance(issue["depends"], str):
13
                self.set_value([x for x in re.findall(r"[\w']+", issue["depends"])])
14
            else: self.set_value([x for x in issue["depends"]])
15
16
class DictJugglerTaskEffort(JugglerTaskEffort):
0 ignored issues
show
Comprehensibility Best Practice introduced by
Undefined variable 'JugglerTaskEffort'
Loading history...
17
    UNIT = "h"
18
    def load_from_issue(self, issue):
19
        if "effort" in issue: self.set_value(math.ceil(issue["effort"]))
0 ignored issues
show
Coding Style introduced by
More than one statement on a single line
Loading history...
20
21
class DictJugglerTaskAllocate(JugglerTaskAllocate):
0 ignored issues
show
Comprehensibility Best Practice introduced by
Undefined variable 'JugglerTaskAllocate'
Loading history...
22
    def load_from_issue(self, issue):
23
        if "allocate" in issue: self.set_value(issue["allocate"])
0 ignored issues
show
Coding Style introduced by
More than one statement on a single line
Loading history...
24
        else: self.set_value("me") # stub!
25
26
class DictJugglerTask(JugglerTask):
0 ignored issues
show
Comprehensibility Best Practice introduced by
Undefined variable 'JugglerTask'
Loading history...
27
    def load_default_properties(self, issue):
28
        self.set_property(DictJugglerTaskDepends(issue))
29
        self.set_property(DictJugglerTaskEffort(issue))
30
        self.set_property(DictJugglerTaskAllocate(issue))
31
    def load_from_issue(self, issue):
32
        self.set_id(issue["id"])
33
        if "summary" in issue: self.summary = issue["summary"]
0 ignored issues
show
Coding Style introduced by
More than one statement on a single line
Loading history...
Coding Style introduced by
The attribute summary 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...
34
35
class DictJuggler(GenericJuggler):
0 ignored issues
show
Comprehensibility Best Practice introduced by
Undefined variable 'GenericJuggler'
Loading history...
36
    """ a simple dictionary based format parser """
37
    def __init__(self, issues):
38
        self.issues = issues
39
    def load_issues(self):
40
        return self.issues
41
    def create_task_instance(self, issue):
0 ignored issues
show
Coding Style introduced by
This method could be written as a function/class method.

If a method does not access any attributes of the class, it could also be implemented as a function or static method. This can help improve readability. For example

class Foo:
    def some_method(self, x, y):
        return x + y;

could be written as

class Foo:
    @classmethod
    def some_method(cls, x, y):
        return x + y;
Loading history...
42
        return DictJugglerTask(issue)
43
44
class JsonJuggler(DictJuggler):
45
    def __init__(self, json_issues):
0 ignored issues
show
Bug introduced by
The __init__ method of the super-class DictJuggler is not called.

It is generally advisable to initialize the super-class by calling its __init__ method:

class SomeParent:
    def __init__(self):
        self.x = 1

class SomeChild(SomeParent):
    def __init__(self):
        # Initialize the super class
        SomeParent.__init__(self)
Loading history...
46
        self.issues = json.loads(json_issues)
47
    def toJSON(self):
48
        # TODO HERE: decode tasks back to JSON
49
        for t in self.walk(JugglerTask):
0 ignored issues
show
Comprehensibility Best Practice introduced by
Undefined variable 'JugglerTask'
Loading history...
50
            for i in self.issues:
51
                if t.get_id() == i["id"]:
52
                    i["booking"] = t.walk(JugglerBooking)[0].decode()[0].isoformat()
0 ignored issues
show
Comprehensibility Best Practice introduced by
Undefined variable 'JugglerBooking'
Loading history...
53
        return json.dumps(self.issues, sort_keys=True, indent=4, separators=(',', ': '))
54
0 ignored issues
show
coding-style introduced by
Trailing newlines
Loading history...
55