attic/archive.py

Summary

Maintainability
F
5 days
Test Coverage

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

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

        def process_file(self, path, st, cache):
            safe_path = make_path_safe(path)
            # Is it a hard link?
            if st.st_nlink > 1:
                source = self.hard_links.get((st.st_ino, st.st_dev))
    Severity: Minor
    Found in attic/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 unpack_many has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        def unpack_many(self, ids, filter=None, preload=False):
            unpacker = msgpack.Unpacker(use_list=False)
            for data in self.fetch_many(ids):
                unpacker.feed(data)
                items = [decode_dict(item, (b'path', b'source', b'user', b'group')) for item in unpacker]
    Severity: Minor
    Found in attic/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 __init__ has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def __init__(self, repository, key, manifest, name, cache=None, create=False,
                     checkpoint_interval=300, numeric_owner=False):
            self.cwd = os.getcwd()
            self.key = key
            self.repository = repository
    Severity: Minor
    Found in attic/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_manifest has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def rebuild_manifest(self):
            """Rebuild the manifest object if it is missing
    
            Iterates through all objects in the repository looking for archive metadata blocks.
            """
    Severity: Minor
    Found in attic/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 __init__ has 9 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(self, repository, key, manifest, name, cache=None, create=False,
    Severity: Major
    Found in attic/archive.py - About 1 hr to fix

      Function delete has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def delete(self, stats):
              unpacker = msgpack.Unpacker(use_list=False)
              for items_id, data in zip(self.metadata[b'items'], self.repository.get_many(self.metadata[b'items'])):
                  unpacker.feed(self.key.decrypt(items_id, data))
                  self.cache.chunk_decref(items_id, stats)
      Severity: Minor
      Found in attic/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 calc_stats has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def calc_stats(self, cache):
              def add(id):
                  count, size, csize = cache.chunks[id]
                  stats.update(size, csize, count == 1)
                  cache.chunks[id] = count - 1, size, csize
      Severity: Minor
      Found in attic/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

      Function restore_attrs has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def restore_attrs(self, path, item, symlink=False, fd=None):
      Severity: Minor
      Found in attic/archive.py - About 35 mins to fix

        Function verify_chunks has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def verify_chunks(self):
                unused = set()
                for id_, (count, size, csize) in self.chunks.iteritems():
                    if count == 0:
                        unused.add(id_)
        Severity: Minor
        Found in attic/archive.py - About 35 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 _open_rb has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def _open_rb(path, st):
                flags_noatime = None
                euid = None
        
                def open_simple(p, s):
        Severity: Minor
        Found in attic/archive.py - About 35 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

        There are no issues that match your filters.

        Category
        Status