sipa/initialization.py

Summary

Maintainability
A
3 hrs
Test Coverage

Function init_env_and_config has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

def init_env_and_config(app):
    if not app.config.get("FLATPAGES_ROOT"):
        app.config["FLATPAGES_ROOT"] = os.path.join(
            os.path.dirname(__file__),
            "../content",
Severity: Minor
Found in sipa/initialization.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_app has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

def init_app(app, **kwargs):
    """Initialize the Flask app located in the module sipa.
    This initializes the Flask app by:

    * calling the internal init_app() procedures of each module
Severity: Minor
Found in sipa/initialization.py - About 1 hr to fix

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

    def load_config_file(app, config=None):
        """Just load the config file, do nothing else"""
        # default configuration
        from .config import default
    
    
    Severity: Minor
    Found in sipa/initialization.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

    Error: invalid syntax (<unknown>, line 154)</unknown>
    Open

        if url := app.config["CONTENT_URL"]:
    Severity: Minor
    Found in sipa/initialization.py by radon

    We encountered an error attempting to analyze this line.

    There are no issues that match your filters.

    Category
    Status