borgbackup/borg

View on GitHub

Showing 507 of 611 total issues

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

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

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

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

      Function create has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def create(cls, repository, args, *, other_key=None):
              key = cls(repository)
              key.repository_id = repository.id
              if other_key is not None:
                  if isinstance(other_key, PlaintextKey):
      Severity: Minor
      Found in src/borg/crypto/key.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 upgrade_archive_metadata has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def upgrade_archive_metadata(self, *, metadata):
              new_metadata = {}
              # keep all metadata except archive version and stats. also do not keep
              # recreate_source_id, recreate_args, recreate_partial_chunks which were used only in 1.1.0b1 .. b2.
              for attr in ("hostname", "username", "comment", "chunker_params"):
      Severity: Minor
      Found in src/borg/upgrade.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 calculate_relative_offset has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

      def calculate_relative_offset(format_string, from_ts, earlier=False):
          """
          Calculates offset based on a relative marker. 7d (7 days), 8m (8 months)
          earlier: whether offset should be calculated to an earlier time.
          """
      Severity: Minor
      Found in src/borg/helpers/time.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 __init__ has 10 arguments (exceeds 4 allowed). Consider refactoring.
      Open

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

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

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

          Function extract_helper has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              def extract_helper(self, item, path, hlm, *, dry_run=False):
                  hardlink_set = False
                  # Hard link?
                  if "hlid" in item:
                      link_target = hlm.retrieve(id=item.hlid)
          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 create_helper has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              def create_helper(self, path, st, status=None, hardlinkable=True, strip_prefix=None):
                  if strip_prefix is not None:
                      assert not path.endswith(os.sep)
                      if strip_prefix.startswith(path + os.sep):
                          # still on a directory level that shall be stripped - do not create an item for this!
          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 matcher_add_tagged_dirs has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              def matcher_add_tagged_dirs(self, archive):
                  """Add excludes to the matcher created by exclude_cache and exclude_if_present."""
          
                  def exclude(dir, tag_item):
                      if self.keep_exclude_tags:
          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 open has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              def open(self, path, exclusive, lock_wait=None, lock=True):
                  self.path = path
                  try:
                      st = os.stat(path)
                  except FileNotFoundError:
          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 extract_item has 10 arguments (exceeds 4 allowed). Consider refactoring.
          Open

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

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

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

              Function fuse_mount has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

              def fuse_mount(archiver, mountpoint=None, *options, fork=True, os_fork=False, **kwargs):
                  # For a successful mount, `fork = True` is required for
                  # the borg mount daemon to work properly or the tests
                  # will just freeze. Therefore, if argument `fork` is not
                  # specified, the default value is `True`, regardless of
              Severity: Minor
              Found in src/borg/testsuite/archiver/__init__.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 test_disk_full has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

              def test_disk_full(test_pass, cmd_fixture, monkeypatch):
                  monkeypatch.setenv("BORG_CHECK_I_KNOW_WHAT_I_AM_DOING", "YES")
                  monkeypatch.setenv("BORG_DELETE_I_KNOW_WHAT_I_AM_DOING", "YES")
                  repo = os.path.join(DF_MOUNT, "repo")
                  input = os.path.join(DF_MOUNT, "input")
              Severity: Minor
              Found in src/borg/testsuite/archiver/disk_full_test.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_any has 10 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def _process_any(self, *, path, parent_fd, name, st, fso, cache, read_special, dry_run, strip_prefix):
              Severity: Major
              Found in src/borg/archiver/create_cmd.py - About 1 hr to fix

                Function do_repo_info has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                    def do_repo_info(self, args, repository, manifest, cache):
                        """Show repository infos"""
                        key = manifest.key
                        info = basic_json_data(manifest, cache=cache, extra={"security_dir": cache.security_manager.dir})
                
                
                Severity: Minor
                Found in src/borg/archiver/repo_info_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 compat_check has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                def compat_check(*, create, manifest, key, cache, compatibility, decorator_name):
                    if not create and (manifest or key or cache):
                        if compatibility is None:
                            raise AssertionError(f"{decorator_name} decorator used without compatibility argument")
                        if type(compatibility) is not tuple:
                Severity: Minor
                Found in src/borg/archiver/_common.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 test_migrate_lock_alive has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                def test_migrate_lock_alive(archivers, request):
                    """Both old_id and new_id must not be stale during lock migration / daemonization."""
                    archiver = request.getfixturevalue(archivers)
                    if archiver.get_kind() == "remote":
                        pytest.skip("only works locally")
                Severity: Minor
                Found in src/borg/testsuite/archiver/mount_cmds_test.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_args has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                    def get_args(self, argv, cmd):
                        """usually, just returns argv, except if we deal with a ssh forced command for borg serve."""
                        result = self.parse_args(argv[1:])
                        if cmd is not None and result.func == self.do_serve:
                            # borg serve case:
                Severity: Minor
                Found in src/borg/archiver/__init__.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

                Severity
                Category
                Status
                Source
                Language