borgbackup/borg

View on GitHub

Showing 611 of 611 total issues

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

    def get_item_data(self, item, jsonline=False):
        item_data = {}
        item_data.update({} if jsonline else self.static_data)

        item_data.update(text_to_json("path", item.path))
Severity: Minor
Found in src/borg/helpers/parseformat.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 check_repository_compatibility has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def check_repository_compatibility(self, operations):
        for operation in operations:
            assert isinstance(operation, self.Operation)
            feature_flags = self.config.get("feature_flags", None)
            if feature_flags is None:
Severity: Minor
Found in src/borg/manifest.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 _mkstemp_inner has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def _mkstemp_inner(dir, pre, suf, flags, output_type, mode=0o600):
    """Code common to mkstemp, TemporaryFile, and NamedTemporaryFile."""

    dir = _os.path.abspath(dir)
    names = _get_candidate_names()
Severity: Minor
Found in src/borg/helpers/fs.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 make_key has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def make_key(self, repository):
        attempt = 0

        #  try the manifest first!
        attempt += 1
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 _rebuild_sparse has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def _rebuild_sparse(self, segment):
        """Rebuild sparse bytes count for a single segment relative to the current index."""
        try:
            segment_size = self.io.segment_size(segment)
        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 check has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def check(
        self,
        repository,
        *,
        verify_data=False,
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 flush has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def flush(self, flush=False):
        if self.buffer.tell() == 0:
            return
        self.buffer.seek(0)
        # The chunker returns a memoryview to its internal buffer,
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 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

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

    if archiver.FORK_DEFAULT:
        cmd(archiver, "repo-info", exit_code=EXIT_ERROR)
    else:
        with pytest.raises(Cache.RepositoryAccessAborted):
            cmd(archiver, "repo-info")
Severity: Major
Found in src/borg/testsuite/archiver/checks_test.py and 1 other location - About 1 hr to fix
src/borg/testsuite/archiver/checks_test.py on lines 190..194

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 39.

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

    if archiver.FORK_DEFAULT:
        cmd(archiver, "repo-info", exit_code=EXIT_ERROR)
    else:
        with pytest.raises(Cache.CacheInitAbortedError):
            cmd(archiver, "repo-info")
Severity: Major
Found in src/borg/testsuite/archiver/checks_test.py and 1 other location - About 1 hr to fix
src/borg/testsuite/archiver/checks_test.py on lines 156..160

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 39.

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

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
                Severity
                Category
                Status
                Source
                Language