borgbackup/borg

View on GitHub

Showing 611 of 611 total issues

Function do_help has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def do_help(self, parser, commands, args):
        if not args.topic:
            parser.print_help()
        elif args.topic in self.helptext:
            print(rst_to_terminal(self.helptext[args.topic]))
Severity: Minor
Found in src/borg/archiver/help_cmd.py - About 45 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 fuse_mount has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

def fuse_mount(archiver, mountpoint=None, *options, fork=True, os_fork=False, **kwargs):
Severity: Minor
Found in src/borg/testsuite/archiver/__init__.py - About 45 mins to fix

    Function print_warning has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def print_warning(self, msg, *args, **kw):
            warning_code = kw.get("wc", EXIT_WARNING)  # note: wc=None can be used to not influence exit code
            warning_type = kw.get("wt", "percent")
            assert warning_type in ("percent", "curly")
            warning_msgid = kw.get("msgid")
    Severity: Minor
    Found in src/borg/archiver/__init__.py - About 45 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 test_stats_progress has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def test_stats_progress(item_path, update_size, expected_output, stats, monkeypatch, columns=80):
    Severity: Minor
    Found in src/borg/testsuite/archive_test.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              for chunk_id, size in item.chunks:
                                  chunk_present = cache.seen_chunk(chunk_id, size)
                                  if not chunk_present:  # target repo does not yet have this chunk
                                      if not dry_run:
                                          cdata = other_repository.get(chunk_id)
      Severity: Major
      Found in src/borg/archiver/transfer_cmd.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                for id, size in item.chunks_healthy:
                                    use_it(id, wanted=True)
                pi.finish()
        Severity: Major
        Found in src/borg/archiver/compact_cmd.py - About 45 mins to fix

          Function do_key_import has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def do_key_import(self, args, repository):
                  """Import the repository key from backup"""
                  manager = KeyManager(repository)
                  if args.paper:
                      if args.path:
          Severity: Minor
          Found in src/borg/archiver/key_cmds.py - About 45 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 _import_tar has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def _import_tar(self, args, repository, manifest, key, cache, tarstream):
          Severity: Minor
          Found in src/borg/archiver/tar_cmds.py - About 45 mins to fix

            Function parse has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def parse(
                    self, id: bytes, cdata: bytes, decompress: bool = True, want_compressed: bool = False, ro_type: str = None
                ) -> tuple[dict, bytes]:
                    """
                    Parse a repo object into metadata and data (decrypt it, maybe decompress, maybe verify if the chunk plaintext
            Severity: Minor
            Found in src/borg/repoobj.py - About 45 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 parse_inclexcl_command has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            def parse_inclexcl_command(cmd_line_str, fallback=ShellPattern):
                """Read a --patterns-from command from string and return a CmdTuple object."""
            
                cmd_prefix_map = {
                    "-": IECommand.Exclude,
            Severity: Minor
            Found in src/borg/patterns.py - About 45 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 test_remote_rpc_exception_transport has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            def test_remote_rpc_exception_transport(remote_repository):
                with remote_repository:
                    s1 = "test string"
            
                    try:
            Severity: Minor
            Found in src/borg/testsuite/legacyrepository_test.py - About 45 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 write_chunkindex_to_repo_cache has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            def write_chunkindex_to_repo_cache(repository, chunks, *, compact=False, clear=False, force_write=False):
            Severity: Minor
            Found in src/borg/cache.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  for seed in (1849058162, 1234567653):
                                      fh = BytesIO(data)
                                      chunker = Chunker(seed, minexp, maxexp, maskbits, winsize)
                                      chunks = [blake2b_256(b"", c) for c in cf(chunker.chunkify(fh, -1))]
                                      runs.append(blake2b_256(b"", b"".join(chunks)))
              Severity: Major
              Found in src/borg/testsuite/chunker_slow_test.py - About 45 mins to fix

                Function lib_ext_kwargs has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def lib_ext_kwargs(pc, prefix_env_var, lib_name, lib_pkg_name, pc_version, lib_subdir="lib"):
                Severity: Minor
                Found in setup.py - About 45 mins to fix

                  Function test_remote_rpc_exception_transport has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def test_remote_rpc_exception_transport(remote_repository):
                      with remote_repository:
                          s1 = "test string"
                  
                          try:
                  Severity: Minor
                  Found in src/borg/testsuite/repository_test.py - About 45 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

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                      with Repository(archiver.repository_path) as repository:
                          repo_key = AESOCBRepoKey(repository)
                          repo_key.load(None, Passphrase.env_passphrase())
                  Severity: Minor
                  Found in src/borg/testsuite/archiver/key_cmds_test.py and 1 other location - About 45 mins to fix
                  src/borg/testsuite/archiver/key_cmds_test.py on lines 146..148

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 35.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                      with Repository(archiver.repository_path) as repository:
                          repo_key2 = AESOCBRepoKey(repository)
                          repo_key2.load(None, Passphrase.env_passphrase())
                  Severity: Minor
                  Found in src/borg/testsuite/archiver/key_cmds_test.py and 1 other location - About 45 mins to fix
                  src/borg/testsuite/archiver/key_cmds_test.py on lines 132..134

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 35.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Consider simplifying this complex logical expression.
                  Open

                                  if tag in (TAG_PUT2, TAG_PUT) and is_index_object:
                                      try:
                                          new_segment, offset = self.io.write_put(key, data, raise_full=True)
                                      except LoggedIO.SegmentFull:
                                          complete_xfer()
                  Severity: Major
                  Found in src/borg/legacyrepository.py - About 40 mins to fix

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

                        def __init__(self, path, write, filename=None, override_fd=None, integrity_data=None):
                    Severity: Minor
                    Found in src/borg/crypto/file_integrity.py - About 35 mins to fix

                      Function open has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          def open(self, *, exclusive, lock_wait=None, lock=True):
                      Severity: Minor
                      Found in src/borg/repository.py - About 35 mins to fix
                        Severity
                        Category
                        Status
                        Source
                        Language