borgbackup/borg

View on GitHub

Showing 507 of 611 total issues

Function do_benchmark_cpu has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def do_benchmark_cpu(self, args):
        """Benchmark CPU bound operations."""
        from timeit import timeit

        random_10M = os.urandom(10 * 1000 * 1000)
Severity: Minor
Found in src/borg/archiver/benchmark_cmd.py - About 1 hr to fix

    Function build_parser_create has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def build_parser_create(self, subparsers, common_parser, mid_common_parser):
            from ._common import process_epilog
            from ._common import define_exclusion_group
    
            create_epilog = process_epilog(
    Severity: Minor
    Found in src/borg/archiver/create_cmd.py - About 1 hr to fix

      Function test_basic_functionality has 38 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      def test_basic_functionality(archivers, request):
          archiver = request.getfixturevalue(archivers)
          # Setup files for the first snapshot
          create_regular_file(archiver.input_path, "empty", size=0)
          create_regular_file(archiver.input_path, "file_unchanged", size=128)
      Severity: Minor
      Found in src/borg/testsuite/archiver/diff_cmd_test.py - About 1 hr to fix

        Function test_prune_repository_example has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        def test_prune_repository_example(archivers, request):
            archiver = request.getfixturevalue(archivers)
            cmd(archiver, "repo-create", RK_ENCRYPTION)
            # Archives that will be kept, per the example
            # Oldest archive
        Severity: Minor
        Found in src/borg/testsuite/archiver/prune_cmd_test.py - About 1 hr to fix

          Function __init__ has 12 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def __init__(
          Severity: Major
          Found in src/borg/helpers/msgpack.py - About 1 hr to fix

            Function __init__ has 12 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def __init__(
            Severity: Major
            Found in src/borg/archive.py - About 1 hr to fix

              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 setup_logging has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

              def setup_logging(
                  stream=None, conf_fname=None, env_var="BORG_LOGGING_CONF", level="info", is_serve=False, log_json=False, func=None
              ):
                  """setup logging module according to the arguments provided
              
              
              Severity: Minor
              Found in src/borg/logger.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 _check has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

              def _check(rv, path=None, detect_buffer_too_small=False):
                  from . import get_errno
              
                  if rv < 0:
                      e = get_errno()
              Severity: Minor
              Found in src/borg/platform/xattr.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 get_all has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

              def get_all(path, follow_symlinks=False):
                  """
                  Return all extended attributes on *path* as a mapping.
              
                  *path* can either be a path (str or bytes) or an open file descriptor (int).
              Severity: Minor
              Found in src/borg/xattr.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 main has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

              def main():
                  given = parse_version(sys.argv[1])
                  filenames = sys.argv[2:]
              
                  overall_versions = set()
              Severity: Minor
              Found in scripts/glibc_check.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 has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

                  def write(self, fd, to_send):
                      if self.ratelimit:
                          now = time.monotonic()
                          if self.ratelimit_last + RATELIMIT_PERIOD <= now:
                              self.ratelimit_quota += self.ratelimit
              Severity: Minor
              Found in src/borg/remote.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 new has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

                  def new(cls, allow_empty=False):
                      passphrase = cls.env_new_passphrase()
                      if passphrase is not None:
                          return passphrase
                      passphrase = cls.env_passphrase()
              Severity: Minor
              Found in src/borg/helpers/passphrase.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 has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

                  def write(self, fd, to_send):
                      if self.ratelimit:
                          now = time.monotonic()
                          if self.ratelimit_last + RATELIMIT_PERIOD <= now:
                              self.ratelimit_quota += self.ratelimit
              Severity: Minor
              Found in src/borg/legacyremote.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 process_pipe has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

                  def process_pipe(self, *, path, cache, fd, mode, user=None, group=None):
                      status = "i"  # stdin (or other pipe)
                      self.print_file_status(status, path)
                      status = None  # we already printed the status
                      if user is not None:
              Severity: Minor
              Found in src/borg/archive.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 get_fd has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

                  def get_fd(self, segment):
                      # note: get_fd() returns a fd with undefined file pointer position,
                      # so callers must always seek() to desired position afterwards.
                      now = time.monotonic()
              
              
              Severity: Minor
              Found in src/borg/legacyrepository.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 do_debug_search_repo_objs has a Cognitive Complexity of 12 (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 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 _wait_for_readers_finishing has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

                  def _wait_for_readers_finishing(self, remove, sleep):
                      timer = TimeoutTimer(self.timeout, sleep).start()
                      while True:
                          self._lock.acquire()
                          try:
              Severity: Minor
              Found in src/borg/fslocking.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 list has 11 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def list(
              Severity: Major
              Found in src/borg/manifest.py - About 1 hr to fix

                Function get_repository has 11 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                def get_repository(
                Severity: Major
                Found in src/borg/archiver/_common.py - About 1 hr to fix
                  Severity
                  Category
                  Status
                  Source
                  Language