borgbackup/borg

View on GitHub

Showing 507 of 611 total issues

File fs.py has 444 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import errno
import hashlib
import os
import posixpath
import re
Severity: Minor
Found in src/borg/helpers/fs.py - About 6 hrs to fix

    File manifest.py has 435 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import enum
    import re
    from collections import namedtuple
    from datetime import datetime, timedelta, timezone
    from operator import attrgetter
    Severity: Minor
    Found in src/borg/manifest.py - About 6 hrs to fix

      File tar_cmds.py has 435 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import argparse
      import base64
      import logging
      import os
      import stat
      Severity: Minor
      Found in src/borg/archiver/tar_cmds.py - About 6 hrs to fix

        Function api has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
        Open

        def api(*, since, **kwargs_decorator):
            """Check version requirements and use self.call to do the remote method call.
        
            <since> specifies the version in which borg introduced this method.
            Calling this method when connected to an older version will fail without transmitting anything to the server.
        Severity: Minor
        Found in src/borg/remote.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

        Function api has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
        Open

        def api(*, since, **kwargs_decorator):
            """Check version requirements and use self.call to do the remote method call.
        
            <since> specifies the version in which borg introduced this method.
            Calling this method when connected to an older version will fail without transmitting anything to the server.
        Severity: Minor
        Found in src/borg/legacyremote.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

        File repository.py has 433 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import os
        import time
        
        from borgstore.store import Store
        from borgstore.store import ObjectNotFound as StoreObjectNotFound
        Severity: Minor
        Found in src/borg/repository.py - About 6 hrs to fix

          Function do_extract has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
          Open

              def do_extract(self, args, repository, manifest, archive):
                  """Extract archive contents"""
                  # be restrictive when restoring files, restore permissions later
                  if sys.getfilesystemencoding() == "ascii":
                      logger.warning(
          Severity: Minor
          Found in src/borg/archiver/extract_cmd.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

          File __init__.py has 381 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import errno
          import filecmp
          import io
          import os
          import re
          Severity: Minor
          Found in src/borg/testsuite/archiver/__init__.py - About 5 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 prepare_txn has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
            Open

                def prepare_txn(self, transaction_id, do_cleanup=True):
                    self._active_txn = True
                    if self.do_lock and not self.lock.got_exclusive_lock():
                        if self.exclusive is not None:
                            # self.exclusive is either True or False, thus a new client is active here.
            Severity: Minor
            Found in src/borg/legacyrepository.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

            File fslocking.py has 375 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import errno
            import json
            import os
            import tempfile
            import time
            Severity: Minor
            Found in src/borg/fslocking.py - About 5 hrs to fix

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

              def translate(pat, match_end=r"\Z"):
                  """Translate a shell-style pattern to a regular expression.
              
                  The pattern may include ``**<sep>`` (<sep> stands for the platform-specific path separator; "/" on POSIX systems)
                  for matching zero or more directory levels and "*" for matching zero or more arbitrary characters except any path
              Severity: Minor
              Found in src/borg/helpers/shellpattern.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

              File help_cmd.py has 362 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import collections
              import functools
              import textwrap
              
              from ..constants import *  # NOQA
              Severity: Minor
              Found in src/borg/archiver/help_cmd.py - About 4 hrs to fix

                Function main has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
                Open

                def main():  # pragma: no cover
                    # Make sure stdout and stderr have errors='replace' to avoid unicode
                    # issues when print()-ing unicode file names
                    sys.stdout = ErrorIgnoringTextIOWrapper(sys.stdout.buffer, sys.stdout.encoding, "replace", line_buffering=True)
                    sys.stderr = ErrorIgnoringTextIOWrapper(sys.stderr.buffer, sys.stderr.encoding, "replace", line_buffering=True)
                Severity: Minor
                Found in src/borg/archiver/__init__.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 do_repo_delete has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
                Open

                    def do_repo_delete(self, args, repository):
                        """Delete a repository"""
                        self.output_list = args.output_list
                        dry_run = args.dry_run
                        keep_security_info = args.keep_security_info
                Severity: Minor
                Found in src/borg/archiver/repo_delete_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

                RemoteRepository has 34 functions (exceeds 20 allowed). Consider refactoring.
                Open

                class RemoteRepository:
                    extra_test_args = []  # type: ignore
                
                    class RPCError(Exception):
                        def __init__(self, unpacked):
                Severity: Minor
                Found in src/borg/remote.py - About 4 hrs to fix

                  Function acquire has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def acquire(self):
                          # goal
                          # for exclusive lock: there must be only 1 exclusive lock and no other (exclusive or non-exclusive) locks.
                          # for non-exclusive lock: there can be multiple n-e locks, but there must not exist an exclusive lock.
                          logger.debug(f"LOCK-ACQUIRE: trying to acquire a lock. exclusive: {self.is_exclusive}.")
                  Severity: Minor
                  Found in src/borg/storelocking.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 show_progress has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def show_progress(self, item=None, final=False, stream=None, dt=None):
                          now = time.monotonic()
                          if dt is None or now - self.last_progress > dt:
                              self.last_progress = now
                              if self.output_json:
                  Severity: Minor
                  Found in src/borg/archive.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 analyze_archives has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def analyze_archives(self) -> Tuple[Set, Set, int, int, int]:
                          """Iterate over all items in all archives, create the dicts id -> size of all used/wanted chunks."""
                  
                          def use_it(id, *, wanted=False):
                              entry = self.chunks.get(id)
                  Severity: Minor
                  Found in src/borg/archiver/compact_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

                  Severity
                  Category
                  Status
                  Source
                  Language