borgbackup/borg

View on GitHub

Showing 611 of 611 total issues

Function process_symlink has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def process_symlink(self, *, path, parent_fd, name, st, strip_prefix):
Severity: Minor
Found in src/borg/archive.py - About 45 mins to fix

    Function valid_msgpacked_dict has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def valid_msgpacked_dict(d, keys_serialized):
        """check if the data <d> looks like a msgpacked dict"""
        d_len = len(d)
        if d_len == 0:
            return False
    Severity: Minor
    Found in src/borg/archive.py - About 45 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

    Avoid deeply nested control flow statements.
    Open

                            if pi:
                                pi.show(increase=len(data), info=[remove_surrogates(item.path)])
                            with backup_io("write"):
    Severity: Major
    Found in src/borg/archive.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              with backup_io("write"):
                                  if sparse and zeros.startswith(data):
                                      # all-zero chunk: create a hole in a sparse file
                                      fd.seek(len(data), 1)
                                  else:
      Severity: Major
      Found in src/borg/archive.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                if not is_special_file and not changed_while_backup:
                                    # we must not memorize special files, because the contents of e.g. a
                                    # block or char device will change without its mtime/size/inode changing.
                                    # also, we must not memorize a potentially inconsistent/corrupt file that
                                    # changed while we backed it up.
        Severity: Major
        Found in src/borg/archive.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  if msgid in self.ignore_responses:
                                      self.ignore_responses.remove(msgid)
                                      # async methods never return values, but may raise exceptions.
                                      if "exception_class" in unpacked:
                                          self.async_responses[msgid] = unpacked
          Severity: Major
          Found in src/borg/legacyremote.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                    with backup_io("read"):
                                        self.process_file_chunks(
                                            item,
                                            cache,
                                            self.stats,
            Severity: Major
            Found in src/borg/archive.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                      if not self.shadow_index[key]:
                                          # shadowed segments list is empty -> remove it
                                          del self.shadow_index[key]
                          assert segments[segment] == 0, "Corrupted segment reference count - corrupted index or hints"
              Severity: Major
              Found in src/borg/legacyrepository.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                            if tag == TAG_PUT2:
                                                c_offset = self.HEADER_ID_SIZE + self.ENTRY_HASH_SIZE
                                                # skip if header is invalid
                                                if crc32(d[4:c_offset]) & 0xFFFFFFFF != crc:
                                                    d = d[1:]
                Severity: Major
                Found in src/borg/legacyrepository.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                              for archive_info in manifest.archives.list(sort_by=["ts"]):
                                                  msg.append(format_archive(archive_info))
                                          else:
                  Severity: Major
                  Found in src/borg/archiver/repo_delete_cmd.py - About 45 mins to fix

                    Function cache_if_remote has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def cache_if_remote(repository, *, decrypted_cache=False, pack=None, unpack=None, transform=None, force_cache=False):
                        """
                        Return a Repository(No)Cache for *repository*.
                    
                        If *decrypted_cache* is a repo_objs object, then get and get_many will return a tuple
                    Severity: Minor
                    Found in src/borg/legacyremote.py - About 45 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 process_dir has 6 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        def process_dir(self, *, path, parent_fd, name, st, strip_prefix):
                    Severity: Minor
                    Found in src/borg/archive.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                              if "size" in item:
                                                  item_size = item.size
                                                  if item_size != item_chunks_size:
                                                      raise BackupError(
                                                          "Size inconsistency detected: size {}, chunks size {}".format(
                      Severity: Major
                      Found in src/borg/archive.py - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                                if changed_while_backup:
                                                    # regular file changed while we backed it up, might be inconsistent/corrupt!
                                                    if last_try:
                                                        status = "C"  # crap! retries did not help.
                                                    else:
                        Severity: Major
                        Found in src/borg/archive.py - About 45 mins to fix

                          Function call_many has 6 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                              def call_many(self, cmd, calls, wait=True, is_preloaded=False, async_wait=True):
                          Severity: Minor
                          Found in src/borg/legacyremote.py - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                    for data in self.pipeline.fetch_many(
                                                        [c.id for c in item.chunks], is_preloaded=True, ro_type=ROBJ_FILE_STREAM
                                                    ):
                                                        if pi:
                                                            pi.show(increase=len(data), info=[remove_surrogates(item.path)])
                            Severity: Major
                            Found in src/borg/archive.py - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                      if stdout:
                                                          sys.stdout.buffer.flush()
                                                      if "size" in item:
                              Severity: Major
                              Found in src/borg/archive.py - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                                        for chunk in chunks:
                                                            if not cache.seen_chunk(chunk.id):
                                                                # cache said it is unmodified, but we lost a chunk: process file like modified
                                                                status = "M"
                                                                break
                                Severity: Major
                                Found in src/borg/archive.py - About 45 mins to fix

                                  Avoid deeply nested control flow statements.
                                  Open

                                                          if not is_win32:  # TODO for win32
                                                              with backup_io("fstat2"):
                                                                  st2 = os.fstat(fd)
                                                              if is_special_file:
                                                                  # special files:
                                  Severity: Major
                                  Found in src/borg/archive.py - About 45 mins to fix

                                    Function process_fifo has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                    Open

                                        def process_fifo(self, *, path, parent_fd, name, st, strip_prefix):
                                    Severity: Minor
                                    Found in src/borg/archive.py - About 45 mins to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language