Showing 113 of 159 total issues

Function call_many has a Cognitive Complexity of 96 (exceeds 5 allowed). Consider refactoring.
Open

    def call_many(self, cmd, calls, wait=True, is_preloaded=False):
        if not calls:
            return
        def fetch_from_cache(args):
            msgid = self.cache[args].pop(0)
Severity: Minor
Found in attic/remote.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 archiver.py has 670 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import argparse
from binascii import hexlify
from datetime import datetime
from operator import attrgetter
import functools
Severity: Major
Found in attic/archiver.py - About 1 day to fix

    File archive.py has 616 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    from datetime import datetime
    from getpass import getuser
    from itertools import groupby
    import errno
    import shutil
    Severity: Major
    Found in attic/archive.py - About 1 day to fix

      File repository.py has 518 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      from configparser import RawConfigParser
      from binascii import hexlify
      from itertools import islice
      import errno
      import os
      Severity: Major
      Found in attic/repository.py - About 1 day to fix

        File versioneer.py has 479 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        """versioneer.py
        
        (like a rocketeer, but for versions)
        
        * https://github.com/warner/python-versioneer
        Severity: Minor
        Found in versioneer.py - About 7 hrs to fix

          File helpers.py has 460 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import argparse
          import binascii
          import grp
          import msgpack
          import os
          Severity: Minor
          Found in attic/helpers.py - About 7 hrs to fix

            File archiver.py has 451 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            from binascii import hexlify
            from configparser import RawConfigParser
            import os
            from io import StringIO
            import stat
            Severity: Minor
            Found in attic/testsuite/archiver.py - About 6 hrs to fix

              Function rebuild_refcounts has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
              Open

                  def rebuild_refcounts(self):
                      """Rebuild object reference counts by walking the metadata
              
                      Missing and/or incorrect data is repaired when detected
                      """
              Severity: Minor
              Found in attic/archive.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 check has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
              Open

                  def check(self, repair=False):
                      """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 attic/repository.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 extract_item has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
              Open

                  def extract_item(self, item, restore_attrs=True, dry_run=False):
                      if dry_run:
                          if b'chunks' in item:
                              for _ in self.pipeline.fetch_many([c[0] for c in item[b'chunks']], is_preloaded=True):
                                  pass
              Severity: Minor
              Found in attic/archive.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 process_archive has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
              Open

                  def process_archive(self, archive, prefix=[]):
                      """Build fuse inode hierarchy from archive metadata
                      """
                      unpacker = msgpack.Unpacker()
                      for key, chunk in zip(archive.metadata[b'items'], self.repository.get_many(archive.metadata[b'items'])):
              Severity: Minor
              Found in attic/fuse.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 __next__ has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
              Open

                  def __next__(self):
                      if self._resync:
                          data = b''.join(self._buffered_data)
                          while self._resync:
                              if not data:
              Severity: Minor
              Found in attic/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 restore_attrs has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
              Open

                  def restore_attrs(self, path, item, symlink=False, fd=None):
                      xattrs = item.get(b'xattrs')
                      if xattrs:
                              for k, v in xattrs.items():
                                  try:
              Severity: Minor
              Found in attic/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 run has 92 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def run(self, args=None):
                      check_extension_modules()
                      keys_dir = get_keys_dir()
                      if not os.path.exists(keys_dir):
                          os.makedirs(keys_dir)
              Severity: Major
              Found in attic/archiver.py - About 3 hrs to fix

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

                    def do_extract(self, args):
                        """Extract archive contents"""
                        # be restrictive when restoring files, restore permissions later
                        if sys.getfilesystemencoding() == 'ascii':
                            print('Warning: File system encoding is "ascii", extracting non-ascii filenames will not be supported.')
                Severity: Minor
                Found in attic/archiver.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 replay_segments has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
                Open

                    def replay_segments(self, index_transaction_id, segments_transaction_id):
                        self.prepare_txn(index_transaction_id, do_cleanup=False)
                        for segment, filename in self.io.segment_iterator():
                            if index_transaction_id is not None and segment <= index_transaction_id:
                                continue
                Severity: Minor
                Found in attic/repository.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 do_list has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
                Open

                    def do_list(self, args):
                        """List archive or repository contents"""
                        repository = self.open_repository(args.src)
                        manifest, key = Manifest.load(repository)
                        if args.src.archive:
                Severity: Minor
                Found in attic/archiver.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 has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                Open

                    def _process(self, archive, cache, excludes, exclude_caches, skip_inodes, path, restrict_dev):
                        if exclude_path(path, excludes):
                            return
                        try:
                            st = os.lstat(path)
                Severity: Minor
                Found in attic/archiver.py - About 2 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 serve has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                Open

                    def serve(self):
                        stdin_fd = sys.stdin.fileno()
                        stdout_fd = sys.stdout.fileno()
                        # Make stdin non-blocking
                        fl = fcntl.fcntl(stdin_fd, fcntl.F_GETFL)
                Severity: Minor
                Found in attic/remote.py - About 2 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

                ArchiverTestCase has 24 functions (exceeds 20 allowed). Consider refactoring.
                Open

                class ArchiverTestCase(ArchiverTestCaseBase):
                
                    def create_regular_file(self, name, size=0, contents=None):
                        filename = os.path.join(self.input_path, name)
                        if not os.path.exists(os.path.dirname(filename)):
                Severity: Minor
                Found in attic/testsuite/archiver.py - About 2 hrs to fix
                  Severity
                  Category
                  Status
                  Source
                  Language