borgbackup/borg

View on GitHub
scripts/make.py

Summary

Maintainability
F
3 days
Test Coverage

File make.py has 485 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# Support code for building docs (build_usage, build_man)

import glob
import os
import io
Severity: Minor
Found in scripts/make.py - About 7 hrs to fix

    Function write_options has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
    Open

        def write_options(self, parser, fp):
            def is_positional_group(group):
                return any(not o.option_strings for o in group._group_actions)
    
            # HTML output:
    Severity: Minor
    Found in scripts/make.py - About 5 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

    Function generate_level has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
    Open

        def generate_level(self, prefix, parser, Archiver, extra_choices=None):
            is_subcommand = False
            choices = {}
            for action in parser._actions:
                if action.choices is not None and "SubParsersAction" in str(action.__class__):
    Severity: Minor
    Found in scripts/make.py - About 4 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

    Function rows_to_table has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

        def rows_to_table(self, rows, write):
            def write_row_separator():
                write("+")
                for column_width in column_widths:
                    write("-" * (column_width + 1))
    Severity: Minor
    Found in scripts/make.py - About 2 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

    Function generate_level has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

        def generate_level(self, prefix, parser, Archiver, extra_choices=None):
            is_subcommand = False
            choices = {}
            for action in parser._actions:
                if action.choices is not None and "SubParsersAction" in str(action.__class__):
    Severity: Minor
    Found in scripts/make.py - About 2 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

    Function write_options_group has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def write_options_group(self, group, fp, with_title=True, base_indent=4):
            def is_positional_group(group):
                return any(not o.option_strings for o in group._group_actions)
    
            indent = " " * base_indent
    Severity: Minor
    Found in scripts/make.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 write_options_group has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def write_options_group(self, write, group):
            def is_positional_group(group):
                return any(not o.option_strings for o in group._group_actions)
    
            if is_positional_group(group):
    Severity: Minor
    Found in scripts/make.py - About 55 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

    Avoid deeply nested control flow statements.
    Open

                            if option.metavar:
                                option_fmt = "``%s " + option.metavar + "``"
                            else:
                                option_fmt = "``%s``"
                            option_str = ", ".join(option_fmt % s for s in option.option_strings)
    Severity: Major
    Found in scripts/make.py - About 45 mins to fix

      Function issue has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

              def issue(name, rawtext, text, lineno, inliner, options={}, content=[]):
      Severity: Minor
      Found in scripts/make.py - About 45 mins to fix

        Avoid too many return statements within this function.
        Open

            return 1
        Severity: Major
        Found in scripts/make.py - About 30 mins to fix

          There are no issues that match your filters.

          Category
          Status