sonntagsgesicht/auxilium

View on GitHub
auxilium/tools/docmaintain_tools.py

Summary

Maintainability
C
1 day
Test Coverage

Function replace_headers has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
Open

def replace_headers(pkg=basename(getcwd()), last=None, path=getcwd()):
    last = dict() if last is None else last
    pkg = __import__(pkg) if isinstance(pkg, str) else pkg
    root, _ = split(pkg.__file__)

Severity: Minor
Found in auxilium/tools/docmaintain_tools.py - About 6 hrs 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

Avoid deeply nested control flow statements.
Open

                    if lines:
                        new_lines = new_header + ['', ''] + lines
                    else:
                        new_lines = new_header

Severity: Major
Found in auxilium/tools/docmaintain_tools.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                        if removed and removed[0].startswith('#!'):
                            new_header[0] = removed[0]
    
                        # add new header
                        if lines:
    Severity: Major
    Found in auxilium/tools/docmaintain_tools.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          if last.get(file, '') == str(getmtime(file)):
                              this[file] = str(getmtime(file))
                              log(LEVEL-1,
                                  ICONS[""] +
                                  "no file header update required for %s" % file)
      Severity: Major
      Found in auxilium/tools/docmaintain_tools.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            while lines and \
                                    (lines[0].strip() == '' or
                                     lines[0].startswith('#')):
                                removed.append(lines.pop(0).strip())
        
        
        Severity: Major
        Found in auxilium/tools/docmaintain_tools.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              if new_lines[-1].strip():
                                  f.write(linesep)  # last empty line
                              f.close()
          Severity: Major
          Found in auxilium/tools/docmaintain_tools.py - About 45 mins to fix

            There are no issues that match your filters.

            Category
            Status