borgbackup/borg

View on GitHub

Showing 611 of 611 total issues

Function build_parser_debug has 65 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def build_parser_debug(self, subparsers, common_parser, mid_common_parser):
        debug_epilog = process_epilog(
            """
        These commands are not intended for normal use and potentially very
        dangerous if used incorrectly.
Severity: Major
Found in src/borg/archiver/debug_cmd.py - About 2 hrs to fix

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

        def recover_segment(self, segment, filename):
            logger.info("Attempting to recover " + filename)
            if segment in self.fds:
                del self.fds[segment]
            if os.path.getsize(filename) < MAGIC_LEN + self.header_fmt.size:
    Severity: Minor
    Found in src/borg/legacyrepository.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_benchmark_crud has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

        def do_benchmark_crud(self, args):
            """Benchmark Create, Read, Update, Delete for archives."""
    
            def parse_args(args, cmd):
                # we need to inherit some essential options from the "borg benchmark crud" invocation
    Severity: Minor
    Found in src/borg/archiver/benchmark_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_tag has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

        def do_tag(self, args, repository, manifest, cache):
            """Manage tags"""
    
            def tags_set(tags):
                """return a set of tags, removing empty tags"""
    Severity: Minor
    Found in src/borg/archiver/tag_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_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

            Severity
            Category
            Status
            Source
            Language