borgbackup/borg

View on GitHub

Showing 507 of 611 total issues

File extract_cmd_test.py has 563 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import errno
import os
import shutil
import time
from unittest.mock import patch
Severity: Major
Found in src/borg/testsuite/archiver/extract_cmd_test.py - About 1 day to fix

    Function check has a Cognitive Complexity of 60 (exceeds 5 allowed). Consider refactoring.
    Open

        def check(self, repair=False, max_duration=0):
            """Check repository consistency"""
    
            def log_error(msg):
                nonlocal obj_corrupted
    Severity: Minor
    Found in src/borg/repository.py - About 1 day 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 60 (exceeds 5 allowed). Consider refactoring.
    Open

        def check(self, repair=False, max_duration=0):
            """Check repository consistency
    
            This method verifies all segment checksums and makes sure
            the index is consistent with the data stored in the segments.
    Severity: Minor
    Found in src/borg/legacyrepository.py - About 1 day 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 _rec_walk has a Cognitive Complexity of 60 (exceeds 5 allowed). Consider refactoring.
    Open

        def _rec_walk(
            self,
            *,
            path,
            parent_fd,
    Severity: Minor
    Found in src/borg/archiver/create_cmd.py - About 1 day 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 _common.py has 555 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import functools
    import os
    import textwrap
    
    import borg
    Severity: Major
    Found in src/borg/archiver/_common.py - About 1 day to fix

      Function restore_attrs has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring.
      Open

          def restore_attrs(self, path, item, symlink=False, fd=None):
              """
              Restore filesystem attributes on *path* (*fd*) from *item*.
      
              Does not access the repository.
      Severity: Minor
      Found in src/borg/archive.py - About 1 day 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 __init__.py has 542 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      # borg cli interface / toplevel archiver code
      
      import sys
      import traceback
      
      
      Severity: Major
      Found in src/borg/archiver/__init__.py - About 1 day to fix

        File fuse.py has 539 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import errno
        import functools
        import io
        import os
        import stat
        Severity: Major
        Found in src/borg/fuse.py - About 1 day to fix

          File patterns_test.py has 535 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import argparse
          import io
          import os.path
          import sys
          
          
          Severity: Major
          Found in src/borg/testsuite/patterns_test.py - About 1 day to fix

            Function test_basic_functionality has a Cognitive Complexity of 56 (exceeds 5 allowed). Consider refactoring.
            Open

            def test_basic_functionality(archivers, request):
                archiver = request.getfixturevalue(archivers)
                # Setup files for the first snapshot
                create_regular_file(archiver.input_path, "empty", size=0)
                create_regular_file(archiver.input_path, "file_unchanged", size=128)
            Severity: Minor
            Found in src/borg/testsuite/archiver/diff_cmd_test.py - About 1 day 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 debug_cmd.py has 526 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import argparse
            import functools
            import json
            import textwrap
            
            
            Severity: Major
            Found in src/borg/archiver/debug_cmd.py - About 1 day to fix

              Function _process_any has a Cognitive Complexity of 52 (exceeds 5 allowed). Consider refactoring.
              Open

                  def _process_any(self, *, path, parent_fd, name, st, fso, cache, read_special, dry_run, strip_prefix):
                      """
                      Call the right method on the given FilesystemObjectProcessor.
                      """
              
              
              Severity: Minor
              Found in src/borg/archiver/create_cmd.py - About 1 day 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 yes has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring.
              Open

              def yes(
                  msg=None,
                  false_msg=None,
                  true_msg=None,
                  default_msg=None,
              Severity: Minor
              Found in src/borg/helpers/yes_no.py - About 7 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 process_file has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring.
              Open

                  def process_file(self, *, path, parent_fd, name, st, cache, flags=flags_normal, last_try=False, strip_prefix):
                      with self.create_helper(path, st, None, strip_prefix=strip_prefix) as (
                          item,
                          status,
                          hardlinked,
              Severity: Minor
              Found in src/borg/archive.py - About 7 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 make.py has 485 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              # Support code for building docs (build_usage, build_man)
              
              import glob
              import os
              import io
              Severity: Minor
              Found in scripts/make.py - About 7 hrs to fix

                Function import_paperkey has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring.
                Open

                    def import_paperkey(self, args):
                        try:
                            # imported here because it has global side effects
                            import readline  # noqa
                        except ImportError:
                Severity: Minor
                Found in src/borg/crypto/keymanager.py - About 7 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 compact_segments has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring.
                Open

                    def compact_segments(self, threshold):
                        """Compact sparse segments by copying data into new segments"""
                        if not self.compact:
                            logger.debug("Nothing to do: compact empty")
                            return
                Severity: Minor
                Found in src/borg/legacyrepository.py - About 7 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 _export_tar has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
                Open

                    def _export_tar(self, args, archive, tarstream):
                        matcher = build_matcher(args.patterns, args.paths)
                
                        progress = args.progress
                        output_list = args.output_list
                Severity: Minor
                Found in src/borg/archiver/tar_cmds.py - About 7 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 mount has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
                Open

                    def mount(self, mountpoint, mount_options, foreground=False):
                        """Mount filesystem on *mountpoint* with *mount_options*."""
                
                        def pop_option(options, key, present, not_present, wanted_type, int_base=0):
                            assert isinstance(options, list)  # we mutate this
                Severity: Minor
                Found in src/borg/fuse.py - About 7 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

                LegacyRepository has 48 functions (exceeds 20 allowed). Consider refactoring.
                Open

                class LegacyRepository:
                    """
                    Filesystem based transactional key value store
                
                    Transactionality is achieved by using a log (aka journal) to record changes. The log is a series of numbered files
                Severity: Minor
                Found in src/borg/legacyrepository.py - About 6 hrs to fix
                  Severity
                  Category
                  Status
                  Source
                  Language