borgbackup/borg

View on GitHub

Showing 507 of 611 total issues

Function _read has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

    def _read(self, fd, header, segment, offset, acceptable_tags, read_data=True):
        """
        Code shared by read() and iter_objects().

        Confidence in returned data:
Severity: Minor
Found in src/borg/legacyrepository.py - About 4 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_prune has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

    def do_prune(self, args, repository, manifest):
        """Prune repository archives according to specified rules"""
        if not any(
            (
                args.secondly,
Severity: Minor
Found in src/borg/archiver/prune_cmd.py - About 3 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 prune_cmd.py has 329 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import argparse
from collections import OrderedDict
from datetime import datetime, timezone, timedelta
import logging
from operator import attrgetter
Severity: Minor
Found in src/borg/archiver/prune_cmd.py - About 3 hrs to fix

    File process.py has 328 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import contextlib
    import os
    import os.path
    import shlex
    import signal
    Severity: Minor
    Found in src/borg/helpers/process.py - About 3 hrs to fix

      File check_cmd_test.py has 325 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      from datetime import datetime, timezone, timedelta
      import shutil
      from unittest.mock import patch
      
      import pytest
      Severity: Minor
      Found in src/borg/testsuite/archiver/check_cmd_test.py - About 3 hrs to fix

        Function create_helper has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
        Open

            def create_helper(self, tarinfo, status=None, type=None):
                ph = tarinfo.pax_headers
                if ph and "BORG.item.version" in ph:
                    assert ph["BORG.item.version"] == "1"
                    meta_bin = base64.b64decode(ph["BORG.item.meta"])
        Severity: Minor
        Found in src/borg/archive.py - About 3 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

        Repository has 30 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class Repository:
            """borgstore based key value store"""
        
            class AlreadyExists(Error):
                """A repository already exists at {}."""
        Severity: Minor
        Found in src/borg/repository.py - About 3 hrs to fix

          LegacyRemoteRepository has 30 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class LegacyRemoteRepository:
              extra_test_args = []  # type: ignore
          
              class RPCError(Exception):
                  def __init__(self, unpacked):
          Severity: Minor
          Found in src/borg/legacyremote.py - About 3 hrs to fix

            File mount_cmds_test.py has 317 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import errno
            import os
            import stat
            import sys
            
            
            Severity: Minor
            Found in src/borg/testsuite/archiver/mount_cmds_test.py - About 3 hrs to fix

              Function unpack_many has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
              Open

                  def unpack_many(self, ids, *, filter=None, preload=False):
                      """
                      Return iterator of items.
              
                      *ids* is a chunk ID list of an item stream. *filter* is a callable
              Severity: Minor
              Found in src/borg/archive.py - About 3 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 verify_data has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
              Open

                  def verify_data(self):
                      logger.info("Starting cryptographic data integrity verification...")
                      chunks_count = len(self.chunks)
                      errors = 0
                      defect_chunks = []
              Severity: Minor
              Found in src/borg/archive.py - About 3 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 iter_archive_items has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
              Open

                  def iter_archive_items(self, archive_item_ids, filter=None):
                      unpacker = msgpack.Unpacker()
              
                      # Current offset in the metadata stream, which consists of all metadata chunks glued together
                      stream_offset = 0
              Severity: Minor
              Found in src/borg/fuse.py - About 3 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 fslocking_test.py has 311 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import random
              import time
              from threading import Thread, Lock as ThreadingLock
              from traceback import format_exc
              
              
              Severity: Minor
              Found in src/borg/testsuite/fslocking_test.py - About 3 hrs to fix

                Function create_filter_process has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
                Open

                def create_filter_process(cmd, stream, stream_close, inbound=True):
                    if cmd:
                        # put a filter process between stream and us (e.g. a [de]compression command)
                        # inbound: <stream> --> filter --> us
                        # outbound: us --> filter --> <stream>
                Severity: Minor
                Found in src/borg/helpers/process.py - About 3 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 hashindex_test.py has 302 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                # Note: these tests are part of the self test, do not use or import pytest functionality here.
                #       See borg.selftest for details. If you add/remove test methods, update SELFTEST_COUNT
                
                import base64
                import hashlib
                Severity: Minor
                Found in src/borg/testsuite/hashindex_test.py - About 3 hrs to fix

                  Function borg_cmd has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def borg_cmd(self, args, testing):
                          """return a borg serve command line"""
                          # give some args/options to 'borg serve' process as they were given to us
                          opts = []
                          if args is not None:
                  Severity: Minor
                  Found in src/borg/remote.py - About 3 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 borg_cmd has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def borg_cmd(self, args, testing):
                          """return a borg serve command line"""
                          # give some args/options to 'borg serve' process as they were given to us
                          opts = []
                          if args is not None:
                  Severity: Minor
                  Found in src/borg/legacyremote.py - About 3 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 _assert_dirs_equal_cmp has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def _assert_dirs_equal_cmp(diff, ignore_flags=False, ignore_xattrs=False, ignore_ns=False):
                      assert diff.left_only == []
                      assert diff.right_only == []
                      assert diff.diff_files == []
                      assert diff.funny_files == []
                  Severity: Minor
                  Found in src/borg/testsuite/archiver/__init__.py - About 3 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 exec_cmd has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def exec_cmd(*args, archiver=None, fork=False, exe=None, input=b"", binary_output=False, **kw):
                      if fork:
                          try:
                              if exe is None:
                                  borg = (sys.executable, "-m", "borg")
                  Severity: Minor
                  Found in src/borg/testsuite/archiver/__init__.py - About 3 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_leaf has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def _process_leaf(self, name, item, parent, prefix, is_dir, item_inode, hlm):
                          path = item.path
                          del item.path  # save some space
                  
                          def file_version(item, path):
                  Severity: Minor
                  Found in src/borg/fuse.py - About 3 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