borgbackup/borg

View on GitHub

Showing 507 of 611 total issues

Function sig_info_handler has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

def sig_info_handler(sig_no, stack):  # pragma: no cover
    """search the stack for infos about the currently processed file and print them"""
    with signal_handler(sig_no, signal.SIG_IGN):
        for frame in inspect.getouterframes(stack):
            func, loc = frame[3], frame[0].f_locals
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 _read_files_cache has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def _read_files_cache(self):
        """read files cache from cache directory"""
        if "d" in self.cache_mode:  # d(isabled)
            return

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 release has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def release(self):
        if not self.is_locked():
            raise NotLocked(self.path)
        if not self.by_me():
            raise NotMyLock(self.path)
Severity: Minor
Found in src/borg/fslocking.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 _process_archive has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def _process_archive(self, archive_id, prefix=[]):
        """Build FUSE inode hierarchy from archive metadata"""
        self.file_versions = {}  # for versions mode: original path -> version
        t0 = time.perf_counter()
        archive = Archive(self._manifest, archive_id)
Severity: Minor
Found in src/borg/fuse.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 __init__ has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def __init__(
        self,
        manifest,
        name,
        *,
Severity: Minor
Found in src/borg/archive.py - About 1 hr to fix

    Function check has 30 lines of code (exceeds 25 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 hr to fix

      Function open has 9 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 9 arguments (exceeds 4 allowed). Consider refactoring.
        Open

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

          Function process_file has 9 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def process_file(self, *, path, parent_fd, name, st, cache, flags=flags_normal, last_try=False, strip_prefix):
          Severity: Major
          Found in src/borg/archive.py - About 1 hr to fix

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

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

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

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

                Function setup_logging has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                def setup_logging(
                    stream=None, conf_fname=None, env_var="BORG_LOGGING_CONF", level="info", is_serve=False, log_json=False, func=None
                ):
                    """setup logging module according to the arguments provided
                
                
                Severity: Minor
                Found in src/borg/logger.py - About 1 hr to fix

                  Function test_date_matching has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  def test_date_matching(archivers, request):
                      archiver = request.getfixturevalue(archivers)
                      check_cmd_setup(archiver)
                  
                      shutil.rmtree(archiver.repository_path)
                  Severity: Minor
                  Found in src/borg/testsuite/archiver/check_cmd_test.py - About 1 hr to fix

                    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

                    Severity
                    Category
                    Status
                    Source
                    Language