View on GitHub


45 mins
Test Coverage

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

    def batch(self, items, Ruler, source={}):
        for key, item in items:
            res = getattr(Ruler, item.get('call'))(item.get('source'), source)

            if isinstance(res, dict):
Severity: Minor
Found in app/services/iterators/ - 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

Comparison to none should be 'if cond is none:'

            if not res == None:
Severity: Minor
Found in app/services/iterators/ by pep8

Comparison to singletons should use "is" or "is not".

Comparisons to singletons like None should always be done
with "is" or "is not", never the equality operators.

Okay: if arg is not None:
E711: if arg != None:
E711: if None == arg:
E712: if arg == True:
E712: if False == arg:

Also, beware of writing if x when you really mean if x is not None
-- e.g. when testing whether a variable or argument that defaults to
None was set to some other value.  The other value might have a type
(such as a container) that could be false in a boolean context!

There are no issues that match your filters.