shiwaforce/poco

View on GitHub
poco/poco.py

Summary

Maintainability
A
3 hrs
Test Coverage
B
89%

Function command_interpreter has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def command_interpreter(self, command, argv):
        if command == 'help':
            argv.append('-h')
            if len(argv) == 1:
                docopt(self.get_full_doc() + "\n" + CTAUtils.get_cta(), argv=argv)
Severity: Minor
Found in poco/poco.py - About 1 hr 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 get_args has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def get_args(self, command, classes, argv):
        for cls in classes:
            cmd = getattr(cls, 'command')
            if not isinstance(cmd, list):
                cmd = [cmd]
Severity: Minor
Found in poco/poco.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 collect_commands has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def collect_commands(self):
        try:
            command_packages = importlib.import_module('poco.commands', package='poco')
            for importer, modname, ispkg in pkgutil.iter_modules(command_packages.__path__):
                if not ispkg:
Severity: Minor
Found in poco/poco.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 check_base_class has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def check_base_class(self, cls):
        for base_class in inspect.getmro(cls)[1:]:
            if base_class == AbstractCommand:
                sub_command = getattr(cls, 'sub_command')
                if sub_command not in self.command_classes.keys():
Severity: Minor
Found in poco/poco.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

Test for membership should be 'not in'
Open

        if (not StateHolder.offline and not 'check-version' in argv):
Severity: Minor
Found in poco/poco.py by pep8

Negative comparison should be done using "not in" and "is not".

Okay: if x not in y:\n    pass
Okay: assert (X in Y or X is Z)
Okay: if not (X in Y):\n    pass
Okay: zz = x is not y
E713: Z = not X in Y
E713: if not X.B in Y:\n    pass
E714: if not X is Y:\n    pass
E714: Z = not X.B is Y

There are no issues that match your filters.

Category
Status