borgbackup/borg

View on GitHub

Showing 507 of 611 total issues

Function do_info has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def do_info(self, args, repository, manifest, cache):
        """Show archive details such as disk space used"""

        if args.name:
            archive_infos = [manifest.archives.get_one([args.name])]
Severity: Minor
Found in src/borg/archiver/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 preprocess_args has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def preprocess_args(self, args):
        deprecations = [
            # ('--old', '--new' or None, 'Warning: "--old" has been deprecated. Use "--new" instead.'),
        ]
        for i, arg in enumerate(args[:]):
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

Function run has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def run(self, args):
        os.umask(args.umask)  # early, before opening files
        self.lock_wait = args.lock_wait
        func = get_func(args)
        # do not use loggers before this!
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

Function build_chunkindex_from_repo has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def build_chunkindex_from_repo(repository, *, disable_caches=False, cache_immediately=False):
    chunks = None
    # first, try to load a pre-computed and centrally cached chunks index:
    if not disable_caches:
        wanted_hash = load_chunks_hash(repository)
Severity: Minor
Found in src/borg/cache.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_repo_compress has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

def test_repo_compress(archiver):
    def check_compression(ctype, clevel, olevel):
        """check if all the chunks in the repo are compressed/obfuscated like expected"""
        repository = Repository(archiver.repository_path, exclusive=True)
        with repository:
Severity: Minor
Found in src/borg/testsuite/archiver/repo_compress_cmd_test.py - About 1 hr to fix

    Function build_parser_tar has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def build_parser_tar(self, subparsers, common_parser, mid_common_parser):
            from ._common import process_epilog
    
            export_tar_epilog = process_epilog(
                """
    Severity: Minor
    Found in src/borg/archiver/tar_cmds.py - About 1 hr to fix

      Function test_basic_functionality has 26 lines of code (exceeds 25 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 1 hr to fix

        Function test_debug_id_hash_format_put_get_parse_obj has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        def test_debug_id_hash_format_put_get_parse_obj(archivers, request):
            """Test format-obj and parse-obj commands"""
            archiver = request.getfixturevalue(archivers)
            cmd(archiver, "repo-create", RK_ENCRYPTION)
            data = b"some data" * 100
        Severity: Minor
        Found in src/borg/testsuite/archiver/debug_cmds_test.py - About 1 hr to fix

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

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

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

                def __init__(self, *, noatime, noctime, nobirthtime, numeric_ids, noflags, noacls, noxattrs):
            Severity: Major
            Found in src/borg/archive.py - About 1 hr to fix

              Function rebuild_archives has 8 arguments (exceeds 4 allowed). Consider refactoring.
              Open

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

                Consider simplifying this complex logical expression.
                Open

                                if item.path.endswith("directory") or item.path.endswith("borgtest"):
                                    assert stat.S_ISDIR(item.mode)
                                    assert item.uid > 0
                                    assert "hlid" not in item
                                elif item.path.endswith("no_hardlink") or item.path.endswith("target"):
                Severity: Major
                Found in src/borg/testsuite/archiver/transfer_cmd_test.py - About 1 hr to fix

                  Function format has 8 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

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

                    Function _create_archive_ts has 8 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                    def _create_archive_ts(archiver, name, y, m, d, H=0, M=0, S=0):
                    Severity: Major
                    Found in src/borg/testsuite/archiver/prune_cmd_test.py - About 1 hr to fix

                      Function format has 8 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

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

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

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

                          Function find_key has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                          Open

                              def find_key(self):
                                  if self.STORAGE == KeyBlobStorage.KEYFILE:
                                      keyfile = self._find_key_file_from_environment()
                                      if keyfile is not None:
                                          return self.sanity_check(keyfile, self.repository.id)
                          Severity: Minor
                          Found in src/borg/crypto/key.py - About 55 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 set_all has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                          Open

                          def set_all(path, xattrs, follow_symlinks=False):
                              """
                              Set all extended attributes on *path* from 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 55 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 add_entry has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                          Open

                              def add_entry(self, key, data, cache, complete):
                                  transformed = self.transform(key, data)
                                  if not cache:
                                      return transformed
                                  packed = self.pack(transformed)
                          Severity: Minor
                          Found in src/borg/remote.py - About 55 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_options_group has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                          Open

                              def write_options_group(self, write, group):
                                  def is_positional_group(group):
                                      return any(not o.option_strings for o in group._group_actions)
                          
                                  if is_positional_group(group):
                          Severity: Minor
                          Found in scripts/make.py - About 55 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

                          Severity
                          Category
                          Status
                          Source
                          Language