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
Branch master (0bcf65)
by Raphaël
01:25 queued 27s
created

BaseResolver   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 10
Duplicated Lines 0 %

Test Coverage

Coverage 80%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
dl 0
loc 10
ccs 4
cts 5
cp 0.8
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __init__() 0 2 1
A resolve() 0 2 1
1
"""
2
Module that contains all the resolvers.
3
4
A resolver is a class that is able to retrieve a dependency to inject.
5
"""
6 1
from pyjection.reference import Reference
7
8
9 1
class BaseResolver(object):
10
    """
11
    Base class for the resolvers
12
    """
13
14 1
    def __init__(self, injector):
15 1
        self._injector = injector
16
17 1
    def resolve(self, method_parameter, service):
18
        pass
19
20
21 1
class ServiceResolver(BaseResolver):
22
    """
23
    Try to resolve the dependency based on
24
    the service that has been provided to the injector.
25
    """
26
27 1
    def resolve(self, method_parameter, service):
28 1
        if method_parameter.name not in service.arguments:
29 1
            return None
30
31 1
        value = service.arguments[method_parameter.name]
32 1
        if not isinstance(value, Reference):
33 1
            return value
34
        # The value references an other dependency service
35 1
        if value.return_class:
36 1
            return self._injector.get_uninstantiated(value.name)
37 1
        return self._injector.get(value.name)
38
39
40 1
class NameResolver(BaseResolver):
41
    """
42
    Try to resolve the dependency based on the parameter name.
43
44
    If the latter is declared in the dependency injector then we retrieve it
45
    as the instance to inject.
46
    """
47
48 1
    def resolve(self, method_parameter, service):
49 1
        if self._injector.has_service(method_parameter.name):
50
            return self._injector.get(method_parameter.name)
51