borgbackup/borg

View on GitHub

Showing 611 of 611 total issues

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

      File fs.py has 444 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import errno
      import hashlib
      import os
      import posixpath
      import re
      Severity: Minor
      Found in src/borg/helpers/fs.py - About 6 hrs to fix

        File manifest.py has 435 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import enum
        import re
        from collections import namedtuple
        from datetime import datetime, timedelta, timezone
        from operator import attrgetter
        Severity: Minor
        Found in src/borg/manifest.py - About 6 hrs to fix

          File tar_cmds.py has 435 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import argparse
          import base64
          import logging
          import os
          import stat
          Severity: Minor
          Found in src/borg/archiver/tar_cmds.py - About 6 hrs to fix

            Function api has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
            Open

            def api(*, since, **kwargs_decorator):
                """Check version requirements and use self.call to do the remote method call.
            
                <since> specifies the version in which borg introduced this method.
                Calling this method when connected to an older version will fail without transmitting anything to the server.
            Severity: Minor
            Found in src/borg/remote.py - About 6 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 api has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
            Open

            def api(*, since, **kwargs_decorator):
                """Check version requirements and use self.call to do the remote method call.
            
                <since> specifies the version in which borg introduced this method.
                Calling this method when connected to an older version will fail without transmitting anything to the server.
            Severity: Minor
            Found in src/borg/legacyremote.py - About 6 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 repository.py has 433 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import os
            import time
            
            from borgstore.store import Store
            from borgstore.store import ObjectNotFound as StoreObjectNotFound
            Severity: Minor
            Found in src/borg/repository.py - About 6 hrs to fix

              Function do_extract has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
              Open

                  def do_extract(self, args, repository, manifest, archive):
                      """Extract archive contents"""
                      # be restrictive when restoring files, restore permissions later
                      if sys.getfilesystemencoding() == "ascii":
                          logger.warning(
              Severity: Minor
              Found in src/borg/archiver/extract_cmd.py - About 5 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 __init__.py has 381 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import errno
              import filecmp
              import io
              import os
              import re
              Severity: Minor
              Found in src/borg/testsuite/archiver/__init__.py - About 5 hrs to fix

                Function write_options has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
                Open

                    def write_options(self, parser, fp):
                        def is_positional_group(group):
                            return any(not o.option_strings for o in group._group_actions)
                
                        # HTML output:
                Severity: Minor
                Found in scripts/make.py - About 5 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 prepare_txn has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
                Open

                    def prepare_txn(self, transaction_id, do_cleanup=True):
                        self._active_txn = True
                        if self.do_lock and not self.lock.got_exclusive_lock():
                            if self.exclusive is not None:
                                # self.exclusive is either True or False, thus a new client is active here.
                Severity: Minor
                Found in src/borg/legacyrepository.py - About 5 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.py has 375 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import errno
                import json
                import os
                import tempfile
                import time
                Severity: Minor
                Found in src/borg/fslocking.py - About 5 hrs to fix

                  Function generate_level has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def generate_level(self, prefix, parser, Archiver, extra_choices=None):
                          is_subcommand = False
                          choices = {}
                          for action in parser._actions:
                              if action.choices is not None and "SubParsersAction" in str(action.__class__):
                  Severity: Minor
                  Found in scripts/make.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 translate has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def translate(pat, match_end=r"\Z"):
                      """Translate a shell-style pattern to a regular expression.
                  
                      The pattern may include ``**<sep>`` (<sep> stands for the platform-specific path separator; "/" on POSIX systems)
                      for matching zero or more directory levels and "*" for matching zero or more arbitrary characters except any path
                  Severity: Minor
                  Found in src/borg/helpers/shellpattern.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

                  File help_cmd.py has 362 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  import collections
                  import functools
                  import textwrap
                  
                  from ..constants import *  # NOQA
                  Severity: Minor
                  Found in src/borg/archiver/help_cmd.py - About 4 hrs to fix
                    Severity
                    Category
                    Status
                    Source
                    Language