ICTU/quality-time

View on GitHub
components/api_server/src/initialization/migrations.py

Summary

Maintainability
A
3 hrs
Test Coverage

Function add_source_parameter_hash_to_latest_measurement has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def add_source_parameter_hash_to_latest_measurement(database: Database, report) -> int:
    """Add source parameter hashes to the latest measurements. Return the number of measurements changed."""
    # Added after Quality-time v5.12.0, see https://github.com/ICTU/quality-time/issues/8736
    count = 0
    for subject in subjects(report):
Severity: Minor
Found in components/api_server/src/initialization/migrations.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

Function change_sonarqube_parameter has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

def change_sonarqube_parameter(
Severity: Minor
Found in components/api_server/src/initialization/migrations.py - About 35 mins to fix

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

    def metrics(report, metric_types: Sequence[str] | None = None):
        """Yield the metrics in the report, optionally filtered by metric type."""
        for subject in subjects(report):
            for metric in subject["metrics"].values():
                if not metric_types or metric["type"] in metric_types:
    Severity: Minor
    Found in components/api_server/src/initialization/migrations.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

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

    def sources(report, metric_types: Sequence[str], source_type: str, parameter: str):
        """Yield the sources in the report, filtered by metric type, source type, and parameter."""
        for metric in metrics(report, metric_types):
            for source in metric.get("sources", {}).values():
                if source["type"] == source_type and parameter in source["parameters"]:
    Severity: Minor
    Found in components/api_server/src/initialization/migrations.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

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

    def sources_with_branch_parameter(report: dict):
        """Return the sources with a branch parameter."""
        for metric in metrics(report, list(METRICS_WITH_SOURCES_WITH_BRANCH_PARAMETER.keys())):
            for source in metric.get("sources", {}).values():
                if source["type"] in METRICS_WITH_SOURCES_WITH_BRANCH_PARAMETER[metric["type"]]:
    Severity: Minor
    Found in components/api_server/src/initialization/migrations.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