ettoreleandrotognoli/python-cdi

View on GitHub

Showing 5 of 5 total issues

Function boot_cdi has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def boot_cdi(paths=('*_cdi.py',), root=None):
    root = sys.path if root is None else root
    if isinstance(root, str):
        root = [root]
    libs = []
Severity: Minor
Found in pycdi/utils.py - About 45 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function sub_container has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def sub_container(self, *args, **kwargs):
        container = PyCDIContainer(parent=self)
        for instance in args:
            container.register_instance(instance)
        for context, instances in kwargs.items():
Severity: Minor
Found in pycdi/core.py - About 45 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function __init__ has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def __init__(self, member=None, name=None, type=object, context=DEFAULT_CONTEXT, multiple=False):
Severity: Minor
Found in pycdi/core.py - About 35 mins to fix

    Function __call__ has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def __call__(self, to_inject):
            if isinstance(to_inject, type):
                annotations = getattr(to_inject.__init__, '__annotations__', {})
            else:
                annotations = getattr(to_inject, '__annotations__', {})
    Severity: Minor
    Found in pycdi/core.py - About 25 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function __call__ has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def __call__(self, decorated):
            def producer():
                instance = getattr(decorated, '_instance', None)
                if instance is None:
                    instance = [self.container.call(decorated) for i in range(self.limit)]
    Severity: Minor
    Found in pycdi/utils.py - About 25 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Severity
    Category
    Status
    Source
    Language