ICTU/quality-time

View on GitHub
components/api_server/src/model/transformations.py

Summary

Maintainability
B
5 hrs
Test Coverage

Function _sources_to_change has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def _sources_to_change(reports, items, scope: EditScope) -> Iterator:
    """Return the sources to change, given the scope."""
    for report in _reports_to_change(reports, items[-1], scope):
        for subject_uuid, subject in _subjects_to_change(report, items[2], scope):
            for metric_uuid, metric in _metrics_to_change(subject, items[1], scope):
Severity: Minor
Found in components/api_server/src/model/transformations.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 replace_report_uuids has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def replace_report_uuids(*reports) -> None:
    """Change all uuids in this report."""
    for report in reports:
        report["report_uuid"] = uuid()
        for subject_uuid, subject in list(report.get("subjects", {}).items()):
Severity: Minor
Found in components/api_server/src/model/transformations.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 hide_credentials has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def hide_credentials(data_model, *reports) -> None:
    """Hide the credentials in the reports. The data model must be passed so hiding also works when time traveling."""
    for source in iter_sources(*reports):
        for parameter_key in __password_parameter_keys(source, data_model):
            source["parameters"][parameter_key] = CREDENTIALS_REPLACEMENT_TEXT
Severity: Minor
Found in components/api_server/src/model/transformations.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_source_parameter has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

def change_source_parameter(  # noqa: PLR0913
Severity: Major
Found in components/api_server/src/model/transformations.py - About 50 mins to fix

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

    def encrypt_source_credentials(public_key: str, *reports: dict):
        """Encrypt all source credentials in the reports."""
        for source in iter_sources(*reports):
            for parameter_key in __password_parameter_keys(source):
                password = source["parameters"][parameter_key]
    Severity: Minor
    Found in components/api_server/src/model/transformations.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

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

    def change_source_parameter(  # noqa: PLR0913
        reports,
        items,
        parameter_key: str,
        old_value,
    Severity: Minor
    Found in components/api_server/src/model/transformations.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

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

    def encrypt_issue_tracker_credentials(public_key: str, *reports: dict):
        """Encrypt all issue tracker credentials in the reports."""
        for report in reports:
            for secret_attribute in ("password", "private_token"):
                if secret_attribute in report.get("issue_tracker", {}).get("parameters", {}):
    Severity: Minor
    Found in components/api_server/src/model/transformations.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

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

    def decrypt_issue_tracker_credentials(private_key: str, *reports: dict):
        """Decrypt all issue tracker credentials in the reports."""
        for report in reports:
            for secret_attribute in ("password", "private_token"):
                if secret_attribute in report.get("issue_tracker", {}).get("parameters", {}):
    Severity: Minor
    Found in components/api_server/src/model/transformations.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