edgewall/trac

View on GitHub
trac/db/pool.py

Summary

Maintainability
B
6 hrs
Test Coverage

Function get_cnx has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

    def get_cnx(self, connector, kwargs, timeout=None):
        cnx = None
        log = kwargs.get('log')
        key = str(kwargs)
        start = time_now()
Severity: Minor
Found in trac/db/pool.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 shutdown has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def shutdown(self, tid=None):
        """Close pooled connections not used in a while"""
        delay = 120
        if tid is None:
            delay = 0
Severity: Minor
Found in trac/db/pool.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 __init__ has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def __init__(self, pool, cnx, key, tid, log=None):
Severity: Minor
Found in trac/db/pool.py - About 35 mins to fix

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

        def _return_cnx(self, cnx, key, tid):
            # Decrement active refcount, clear slot if 1
            with self._available:
                assert (tid, key) in self._active
                cnx, num = self._active[(tid, key)]
    Severity: Minor
    Found in trac/db/pool.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