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):
- Read upRead up
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(
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:
- Read upRead up
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"]:
- Read upRead up
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 remove_test_cases_manual_number
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def remove_test_cases_manual_number(report) -> str:
"""Remove manual number sources from test cases metrics."""
# Added after Quality-time v5.15.0, see https://github.com/ICTU/quality-time/issues/9793
change = ""
for metric in metrics(report, metric_types=("test_cases",)):
- Read upRead up
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"]]:
- Read upRead up
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"