borgbackup/borg

View on GitHub

Showing 507 of 611 total issues

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

    def do_delete(self, args, repository):
        """Delete archives"""
        self.output_list = args.output_list
        dry_run = args.dry_run
        manifest = Manifest.load(repository, (Manifest.Operation.DELETE,))
Severity: Minor
Found in src/borg/archiver/delete_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_change_location has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    def do_change_location(self, args, repository, manifest, cache):
        """Change repository key location"""
        key = manifest.key
        if not hasattr(key, "change_passphrase"):
            raise CommandError("This repository is not encrypted, cannot change the key location.")
Severity: Minor
Found in src/borg/archiver/key_cmds.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 read has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    def read(self, fh, offset, size):
        parts = []
        item = self.get_item(fh)

        # optimize for linear reads:
Severity: Minor
Found in src/borg/fuse.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 acquire has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    def acquire(self, timeout=None, sleep=None):
        if timeout is None:
            timeout = self.timeout
        if sleep is None:
            sleep = self.sleep
Severity: Minor
Found in src/borg/fslocking.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

Archives has 23 functions (exceeds 20 allowed). Consider refactoring.
Open

class Archives:
    """
    Manage the list of archives.

    We still need to support the borg 1.x manifest-with-list-of-archives,
Severity: Minor
Found in src/borg/manifest.py - About 2 hrs to fix

    Archive has 23 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Archive:
        class AlreadyExists(Error):
            """Archive {} already exists"""
    
            exit_mcode = 30
    Severity: Minor
    Found in src/borg/archive.py - About 2 hrs to fix

      Function open has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          def open(
              self,
              path,
              create=False,
              lock_wait=None,
      Severity: Minor
      Found in src/borg/remote.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 test_missing_file_chunk has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

      def test_missing_file_chunk(archivers, request):
          archiver = request.getfixturevalue(archivers)
          check_cmd_setup(archiver)
      
          archive, repository = open_archive(archiver.repository_path, "archive1")
      Severity: Minor
      Found in src/borg/testsuite/archiver/check_cmd_test.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 __init__ has 19 arguments (exceeds 4 allowed). Consider refactoring.
      Open

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

        File checks_test.py has 264 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import os
        import shutil
        from unittest.mock import patch
        
        import pytest
        Severity: Minor
        Found in src/borg/testsuite/archiver/checks_test.py - About 2 hrs to fix

          Function compare_archives_iter has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

              def compare_archives_iter(
                  archive1: "Archive", archive2: "Archive", matcher=None, can_compare_chunk_ids=False
              ) -> Iterator[ItemDiff]:
                  """
                  Yields an ItemDiff instance describing changes/indicating equality.
          Severity: Minor
          Found in src/borg/archive.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 __next__ has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

              def __next__(self):
                  if self._resync:
                      data = b"".join(self._buffered_data)
                      while self._resync:
                          if not data:
          Severity: Minor
          Found in src/borg/archive.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 parse_args has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

              def parse_args(self, args=None):
                  if args:
                      args = self.preprocess_args(args)
                  parser = self.build_parser()
                  args = parser.parse_args(args or ["-h"])
          Severity: Minor
          Found in src/borg/archiver/__init__.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 _import_tar has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

              def _import_tar(self, args, repository, manifest, key, cache, tarstream):
                  t0 = archive_ts_now()
                  t0_monotonic = time.monotonic()
          
                  archive = Archive(
          Severity: Minor
          Found in src/borg/archiver/tar_cmds.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 decorator has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

              def decorator(method):
                  @functools.wraps(method)
                  def wrapper(self, args, **kwargs):
                      location = getattr(args, "other_location")
                      if not location.valid:  # nothing to do
          Severity: Minor
          Found in src/borg/archiver/_common.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 test_basic_functionality has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

          def test_basic_functionality(archivers, request):
              archiver = request.getfixturevalue(archivers)
              if archiver.EXE:
                  pytest.skip("test_basic_functionality seems incompatible with fakeroot and/or the binary.")
              have_root = create_test_files(archiver.input_path)
          Severity: Minor
          Found in src/borg/testsuite/archiver/create_cmd_test.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

          File key_test.py has 259 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import tempfile
          from binascii import a2b_base64
          from unittest.mock import MagicMock
          
          import pytest
          Severity: Minor
          Found in src/borg/testsuite/key_test.py - About 2 hrs to fix

            Function yes has 17 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            def yes(
            Severity: Major
            Found in src/borg/helpers/yes_no.py - About 2 hrs to fix

              File transfer_cmd.py has 255 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import argparse
              
              from ._common import with_repository, with_other_repository, Highlander
              from ..archive import Archive
              from ..compress import CompressionSpec
              Severity: Minor
              Found in src/borg/archiver/transfer_cmd.py - About 2 hrs to fix

                Function os_open has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                Open

                def os_open(*, flags, path=None, parent_fd=None, name=None, noatime=False):
                    """
                    Use os.open to open a fs item.
                
                    If parent_fd and name are given, they are preferred and openat will be used,
                Severity: Minor
                Found in src/borg/helpers/fs.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

                Severity
                Category
                Status
                Source
                Language