krateng/maloja

View on GitHub
maloja/database/dbcache.py

Summary

Maintainability
B
6 hrs
Test Coverage

Function cached_wrapper_individual has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def cached_wrapper_individual(inner_func):

        def outer_func(set_arg,**kwargs):
            if 'dbconn' in kwargs:
                conn = kwargs.pop('dbconn')
Severity: Minor
Found in maloja/database/dbcache.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 serialize has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

def serialize(obj):
    try:
        return serialize(obj.hashable())
    except AttributeError:
        try:
Severity: Minor
Found in maloja/database/dbcache.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 get_size_of has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def get_size_of(obj,counted=None):
    if counted is None:
        counted = set()
    if id(obj) in counted: return 0
    size = sys.getsizeof(obj)
Severity: Minor
Found in maloja/database/dbcache.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 invalidate_caches has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def invalidate_caches(scrobbletime=None):

        cleared, kept = 0, 0
        for k in cache.keys():
            # VERY BIG TODO: differentiate between None as in 'unlimited timerange' and None as in 'time doesnt matter here'!
Severity: Minor
Found in maloja/database/dbcache.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 cached_wrapper has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def cached_wrapper(inner_func):

        def outer_func(*args,**kwargs):

            if 'dbconn' in kwargs:
Severity: Minor
Found in maloja/database/dbcache.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

Avoid too many return statements within this function.
Open

            return json.dumps(obj.hashable())
Severity: Major
Found in maloja/database/dbcache.py - About 30 mins to fix

    There are no issues that match your filters.

    Category
    Status