andry81/tacklelib

View on GitHub
python_patches/fcache/cache.py

Summary

Maintainability
A
2 hrs
Test Coverage

FileCache has 24 functions (exceeds 20 allowed). Consider refactoring.
Wontfix

class FileCache(MutableMapping):
    """A persistent file cache that is dictionary-like and has a write buffer.

    *appname* is passed to `appdirs <https://pypi.python.org/pypi/appdirs/>`_
    to determine a system-appropriate location for the cache files. The cache
Severity: Minor
Found in python_patches/fcache/cache.py - About 2 hrs to fix

    Function __init__ has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def __init__(self, appname, flag='c', mode=0o666, keyencoding='utf-8',
                     serialize=True, app_cache_dir=None):
            """Initialize a :class:`FileCache` object."""
            if not isinstance(flag, str):
                raise TypeError("flag must be str not '{}'".format(type(flag)))
    Severity: Minor
    Found in python_patches/fcache/cache.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 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(self, appname, flag='c', mode=0o666, keyencoding='utf-8',
    Severity: Minor
    Found in python_patches/fcache/cache.py - About 45 mins to fix

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

          def __delitem__(self, key):
              ekey = self._encode_key(key)
              filename = self._key_to_filename(ekey)
              if not self._sync:
                  try:
      Severity: Minor
      Found in python_patches/fcache/cache.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