borgbackup/borg

View on GitHub
src/borg/archiver/debug_cmd.py

Summary

Maintainability
F
3 days
Test Coverage

File debug_cmd.py has 644 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import argparse
import functools
import json
import textwrap

Severity: Major
Found in src/borg/archiver/debug_cmd.py - About 1 day to fix

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

        def do_debug_dump_repo_objs(self, args, repository):
            """dump (decrypted, decompressed) repo objects, repo index MUST be current/correct"""
            from ..crypto.key import key_factory
    
            def decrypt_dump(i, id, cdata, tag=None, segment=None, offset=None):
    Severity: Minor
    Found in src/borg/archiver/debug_cmd.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 build_parser_debug has 76 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def build_parser_debug(self, subparsers, common_parser, mid_common_parser):
            debug_epilog = process_epilog(
                """
            These commands are not intended for normal use and potentially very
            dangerous if used incorrectly.
    Severity: Major
    Found in src/borg/archiver/debug_cmd.py - About 3 hrs to fix

      Function do_debug_search_repo_objs has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

          def do_debug_search_repo_objs(self, args, repository):
              """search for byte sequences in repo objects, repo index MUST be current/correct"""
              context = 32
      
              def print_finding(info, wanted, data, offset):
      Severity: Minor
      Found in src/borg/archiver/debug_cmd.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 do_debug_dump_archive has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def do_debug_dump_archive(self, args, repository, manifest):
              """dump decoded archive metadata (not: data)"""
              repo_objs = manifest.repo_objs
              try:
                  archive_meta_orig = manifest.archives.get_raw_dict()[args.name]
      Severity: Minor
      Found in src/borg/archiver/debug_cmd.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 decrypt_dump has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

              def decrypt_dump(i, id, cdata, tag=None, segment=None, offset=None):
      Severity: Minor
      Found in src/borg/archiver/debug_cmd.py - About 35 mins to fix

        Function do_debug_delete_obj has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def do_debug_delete_obj(self, args, repository):
                """delete the objects with the given IDs from the repo"""
                modified = False
                for hex_id in args.ids:
                    try:
        Severity: Minor
        Found in src/borg/archiver/debug_cmd.py - About 35 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 do_debug_refcount_obj has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def do_debug_refcount_obj(self, args, repository, manifest, cache):
                """display refcounts for the objects with the given IDs"""
                for hex_id in args.ids:
                    try:
                        id = hex_to_bin(hex_id, length=32)
        Severity: Minor
        Found in src/borg/archiver/debug_cmd.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

        There are no issues that match your filters.

        Category
        Status