kengz/SLM-Lab

View on GitHub
slm_lab/spec/spec_util.py

Summary

Maintainability
A
25 mins
Test Coverage
D
68%

Function tick has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring.
Open

def tick(spec, unit):
    '''
    Method to tick lab unit (experiment, trial, session) in meta spec to advance their indices
    Reset lower lab indices to -1 so that they tick to 0
    spec_util.tick(spec, 'session')
Severity: Minor
Found in slm_lab/spec/spec_util.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

TODO found
Open

    # TODO expand to be more comprehensive
Severity: Minor
Found in slm_lab/spec/spec_util.py by fixme

Comparison to false should be 'if cond is false:' or 'if not cond:'
Open

        assert ps.get(spec, 'agent.0.net.gpu') == False, f'Distributed mode "synced" works with CPU only. Set gpu: false.'
Severity: Minor
Found in slm_lab/spec/spec_util.py 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.

Category
Status