tuomas2/serviceform

View on GitHub
serviceform/serviceform/views/decorators.py

Summary

Maintainability
B
4 hrs
Test Coverage
A
97%

Function require_authenticated_participant has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

def require_authenticated_participant(function=None, check_flow=True):
    def actual_decorator(func):
        @wraps(func)
        def wrapper(request: HttpRequest, *args, title: str='', **kwargs) -> HttpResponse:
            current_view = request.resolver_match.view_name
Severity: Minor
Found in serviceform/serviceform/views/decorators.py - About 2 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 serviceform has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def serviceform(function=None, check_form_permission=False, init_counters=False,
                all_responsibles=True, fetch_participants=False):
    def actual_decorator(func):
        @wraps(func)
        def wrapper(request: HttpRequest, slug: str,
Severity: Minor
Found in serviceform/serviceform/views/decorators.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 serviceform has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

def serviceform(function=None, check_form_permission=False, init_counters=False,
Severity: Minor
Found in serviceform/serviceform/views/decorators.py - About 35 mins to fix

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

    def require_authenticated_responsible(func):
        @wraps(func)
        def wrapper(request: HttpRequest, *args, **kwargs) -> HttpResponse:
            responsible = utils.get_responsible(request)
            if responsible:
    Severity: Minor
    Found in serviceform/serviceform/views/decorators.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

    Missing whitespace around parameter equals
    Open

            def wrapper(request: HttpRequest, *args, title: str='', **kwargs) -> HttpResponse:

    Don't use spaces around the '=' sign in function arguments.

    Don't use spaces around the '=' sign when used to indicate a
    keyword argument or a default parameter value, except when
    using a type annotation.
    
    Okay: def complex(real, imag=0.0):
    Okay: return magic(r=real, i=imag)
    Okay: boolean(a == b)
    Okay: boolean(a != b)
    Okay: boolean(a <= b)
    Okay: boolean(a >= b)
    Okay: def foo(arg: int = 42):
    Okay: async def foo(arg: int = 42):
    
    E251: def complex(real, imag = 0.0):
    E251: return magic(r = real, i = imag)
    E252: def complex(real, image: float=0.0):

    Missing whitespace around parameter equals
    Open

            def wrapper(request: HttpRequest, *args, title: str='', **kwargs) -> HttpResponse:

    Don't use spaces around the '=' sign in function arguments.

    Don't use spaces around the '=' sign when used to indicate a
    keyword argument or a default parameter value, except when
    using a type annotation.
    
    Okay: def complex(real, imag=0.0):
    Okay: return magic(r=real, i=imag)
    Okay: boolean(a == b)
    Okay: boolean(a != b)
    Okay: boolean(a <= b)
    Okay: boolean(a >= b)
    Okay: def foo(arg: int = 42):
    Okay: async def foo(arg: int = 42):
    
    E251: def complex(real, imag = 0.0):
    E251: return magic(r = real, i = imag)
    E252: def complex(real, image: float=0.0):

    There are no issues that match your filters.

    Category
    Status