ICTU/quality-time

View on GitHub
components/collector/src/model/parameters.py

Summary

Maintainability
A
1 hr
Test Coverage

Function get has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def get(self, parameter_key: str, quote: bool = False) -> str | list[str]:
        """Return the parameter with the given key."""

        def quote_if_needed(parameter_value: str) -> str:
            """Quote the string if needed."""
Severity: Minor
Found in components/collector/src/model/parameters.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

Consider simplifying this complex logical expression.
Open

        if parameter_info.type == "multiple_choice":
            # If the user didn't pick any values, select the default value if any, otherwise select all values:
            default_value = parameter_info.default_value
            value = self.__parameters.get(parameter_key) or default_value or parameter_info.values or []
            # Ensure all values picked by the user are still allowed. Remove any values that are no longer allowed:
Severity: Major
Found in components/collector/src/model/parameters.py - About 40 mins to fix

    There are no issues that match your filters.

    Category
    Status