houtianze/bypy

View on GitHub
bypy/cached.py

Summary

Maintainability
D
3 days
Test Coverage

Function cleancache has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

    def cleancache():
        if cached.loadcache():
            for absdir in cached.cache.keys():
                if not os.path.exists(absdir):
                    if cached.verbose:
Severity: Minor
Found in bypy/cached.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 loadcache has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

    def loadcache(existingcache = {}):
        # load cache even we don't use cached hash values,
        # because we will save (possibly updated) and hash values
        if not cached.cacheloaded: # no double-loading
            if cached.verbose:
Severity: Minor
Found in bypy/cached.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 mergeinto has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

    def mergeinto(fromc, to, keepto = True):
        conflicts = 0
        for absdir in fromc:
            entry = fromc[absdir]
            if not absdir in to:
Severity: Minor
Found in bypy/cached.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 cached.py has 275 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/env python
# encoding: utf-8
# PYTHON_ARGCOMPLETE_OK

# from __future__ imports must occur at the beginning of the file
Severity: Minor
Found in bypy/cached.py - About 2 hrs to fix

    Function isbincache has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        def isbincache(cache):
            for absdir in cache:
                entry = cache[absdir]
                for file in entry:
                    info = entry[file]
    Severity: Minor
    Found in bypy/cached.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 __call__ has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        def __call__(self, *args):
            assert len(args) > 0
            result = None
            path = args[0]
            dir, file = os.path.split(path) # the 'filename' parameter
    Severity: Minor
    Found in bypy/cached.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 savecache has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def savecache(force_saving = False):
            saved = False
            # even if we were unable to load the cache, we still save it.
            if cached.dirty or force_saving:
                if cached.verbose:
    Severity: Minor
    Found in bypy/cached.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 encrypt_md5 has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def encrypt_md5(md5str):
        def validate_md5():
            if len(md5str) != 32:
                return md5str
            for i in range(32):
    Severity: Minor
    Found in bypy/cached.py - About 55 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

    Avoid deeply nested control flow statements.
    Open

                            if os.path.exists(p):
                                files[f] = oldfiles[f]
                            else:
                                if cached.verbose:
                                    needclean = True
    Severity: Major
    Found in bypy/cached.py - About 45 mins to fix

      Function remove has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def remove(path):
              def notfound():
                  pdbg("Failed to delete cache: Path '{}' not found in cache.".format(path))
      
              dir, file = os.path.split(path)
      Severity: Minor
      Found in bypy/cached.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

      Avoid deeply nested control flow statements.
      Open

                              if not cached.ishexchar(c):
                                  return True
              return False
      Severity: Major
      Found in bypy/cached.py - About 45 mins to fix

        Function _store has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def _store(self, info, path, value):
                cached.dirty = True
                info['size'] = getfilesize(path)
                info['mtime'] = getfilemtime_int(path)
                info[self.f.__name__] = value
        Severity: Minor
        Found in bypy/cached.py - About 25 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 stringifypickle has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        def stringifypickle(picklecache):
            for absdir in picklecache:
                entry = picklecache[absdir]
                for file in entry:
                    info = entry[file]
        Severity: Minor
        Found in bypy/cached.py - About 25 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