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 ( ff6a96...dcc5a2 )
by Andrew
01:14
created

DictJugglerResource.load_from_issue()   A

Complexity

Conditions 2

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
c 0
b 0
f 0
dl 0
loc 4
rs 10
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
import dateutil.parser
0 ignored issues
show
introduced by
third party import "import dateutil.parser" should be placed before "from juggler import *"
Loading history...
5
6
class DictJugglerTaskDepends(JugglerTaskDepends):
0 ignored issues
show
Comprehensibility Best Practice introduced by
Undefined variable 'JugglerTaskDepends'
Loading history...
7
    def load_from_issue(self, issue):
8
        """
9
        Args:
10
            issue["depends"] - a list of identifiers that this task depends on
11
        """
12
        if "depends" in issue: 
0 ignored issues
show
Coding Style introduced by
Trailing whitespace
Loading history...
13
            # TODO HERE: remove ID normalization!
14
            if isinstance(issue["depends"], str) or isinstance(issue['depends'], unicode):
0 ignored issues
show
Unused Code introduced by
Consider merging these isinstance calls to isinstance(issue['depends'], (str, unicode))
Loading history...
Comprehensibility Best Practice introduced by
Undefined variable 'unicode'
Loading history...
15
                self.set_value([int(x) for x in re.findall(r"[\w']+", issue["depends"])])
16
            # TODO check for list, else add idfr
17
            else: self.set_value([int(x) for x in issue["depends"]])
18
19
class DictJugglerTaskPriority(JugglerTaskPriority):
0 ignored issues
show
Comprehensibility Best Practice introduced by
Undefined variable 'JugglerTaskPriority'
Loading history...
20
    def load_from_issue(self, issue):
21
        if "priority" in issue: self.set_value(int(issue["priority"]))
0 ignored issues
show
Coding Style introduced by
More than one statement on a single line
Loading history...
22
        
0 ignored issues
show
Coding Style introduced by
Trailing whitespace
Loading history...
23
class DictJugglerTaskStart(JugglerTaskStart):
0 ignored issues
show
Comprehensibility Best Practice introduced by
Undefined variable 'JugglerTaskStart'
Loading history...
24
    def load_from_issue(self, issue):
25
        if "start" in issue: 
0 ignored issues
show
Coding Style introduced by
Trailing whitespace
Loading history...
26
            if isinstance(issue["start"], str) or isinstance(issue['start'], unicode):
0 ignored issues
show
Unused Code introduced by
Consider merging these isinstance calls to isinstance(issue['start'], (str, unicode))
Loading history...
Comprehensibility Best Practice introduced by
Undefined variable 'unicode'
Loading history...
27
                self.set_value(dateutil.parser.parse(issue["start"]))
28
            else:
29
                self.set_value(issue["start"])
30
        
0 ignored issues
show
Coding Style introduced by
Trailing whitespace
Loading history...
31
class DictJugglerTaskEffort(JugglerTaskEffort):
0 ignored issues
show
Comprehensibility Best Practice introduced by
Undefined variable 'JugglerTaskEffort'
Loading history...
32
    UNIT = "h"
33
    def load_from_issue(self, issue):
34
        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...
35
36
class DictJugglerTaskAllocate(JugglerTaskAllocate):
0 ignored issues
show
Comprehensibility Best Practice introduced by
Undefined variable 'JugglerTaskAllocate'
Loading history...
37
    def load_from_issue(self, issue):
38
        if "allocate" in issue: alloc = issue["allocate"]
0 ignored issues
show
Coding Style introduced by
More than one statement on a single line
Loading history...
39
        else: alloc = "me" # stub!
40
        self.set_value(alloc) 
0 ignored issues
show
Coding Style introduced by
Trailing whitespace
Loading history...
41
        src.walk(JugglerSource)[0].set_property(DictJugglerResource(issue))
0 ignored issues
show
Comprehensibility Best Practice introduced by
Undefined variable 'JugglerSource'
Loading history...
42
43
class DictJugglerTask(JugglerTask):
0 ignored issues
show
Comprehensibility Best Practice introduced by
Undefined variable 'JugglerTask'
Loading history...
44
    def load_default_properties(self, issue):
45
        self.set_property(DictJugglerTaskDepends(issue))
46
        self.set_property(DictJugglerTaskEffort(issue))
47
        self.set_property(DictJugglerTaskAllocate(issue))
48
        self.set_property(DictJugglerTaskStart(issue))
49
        self.set_property(DictJugglerTaskPriority(issue))
50
    def load_from_issue(self, issue):
51
        self.set_id(issue["id"])
52
        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...
53
54
class DictJuggler(GenericJuggler):
0 ignored issues
show
Comprehensibility Best Practice introduced by
Undefined variable 'GenericJuggler'
Loading history...
55
    """ a simple dictionary based format parser """
56
    def __init__(self, issues):
57
        self.issues = issues
58
    def load_issues(self):
59
        return self.issues
60
    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...
61
        return DictJugglerTask(issue)
62
    def create_jugglersource_instance(self):
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...
63
        global src
0 ignored issues
show
Bug introduced by
Global variable 'src' undefined at the module level
Loading history...
64
        src = DictJugglerSource()
65
        return src
66
67
class DictJugglerSource(JugglerSource):
0 ignored issues
show
Comprehensibility Best Practice introduced by
Undefined variable 'JugglerSource'
Loading history...
68
    def load_default_properties(self, issue = None):
0 ignored issues
show
Coding Style introduced by
No space allowed around keyword argument assignment
Loading history...
Unused Code introduced by
The argument issue seems to be unused.
Loading history...
69
        self.set_property(JugglerProject())
0 ignored issues
show
Comprehensibility Best Practice introduced by
Undefined variable 'JugglerProject'
Loading history...
70
        # self.set_property(DictJugglerResource()) # define no resource
71
        self.set_property(JugglerIcalreport())
0 ignored issues
show
Comprehensibility Best Practice introduced by
Undefined variable 'JugglerIcalreport'
Loading history...
72
        
0 ignored issues
show
Coding Style introduced by
Trailing whitespace
Loading history...
73
class DictJugglerResource(JugglerResource):
0 ignored issues
show
Comprehensibility Best Practice introduced by
Undefined variable 'JugglerResource'
Loading history...
74
    def load_from_issue(self, issue):
75
        if "allocate" in issue:
76
            self.set_id(issue["allocate"])
77
            self.set_value(issue["allocate"])
78
79
class JsonJuggler(DictJuggler):
80
    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...
81
        self.issues = json.loads(json_issues)
82
    def toJSON(self):
83
        for t in self.walk(JugglerTask):
0 ignored issues
show
Comprehensibility Best Practice introduced by
Undefined variable 'JugglerTask'
Loading history...
84
            for i in self.issues:
85
                if t.get_id() == i["id"]:
86
                    i["booking"] = t.walk(JugglerBooking)[0].decode()[0].isoformat()
0 ignored issues
show
Comprehensibility Best Practice introduced by
Undefined variable 'JugglerBooking'
Loading history...
87
        return json.dumps(self.issues, sort_keys=True, indent=4, separators=(',', ': '))
88
0 ignored issues
show
coding-style introduced by
Trailing newlines
Loading history...
89