localstack/localstack

View on GitHub
scripts/metrics_coverage/diff_metrics_coverage.py

Summary

Maintainability
C
7 hrs
Test Coverage

Function mark_coverage_acceptance_test has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

def mark_coverage_acceptance_test(
    path_to_acceptance_metrics: str, coverage_collection: dict
) -> dict:
    """
    Iterates over all csv files in `path_to_acceptance_metrics` and updates the information in the `coverage_collection`
Severity: Minor
Found in scripts/metrics_coverage/diff_metrics_coverage.py - About 3 hrs 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 create_readable_report has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

def create_readable_report(
    coverage_collection: dict, additional_tested_collection: dict, output_dir: str
) -> None:
    """
    Helper function to create a very simple HTML view out of the collected metrics.
Severity: Minor
Found in scripts/metrics_coverage/diff_metrics_coverage.py - About 2 hrs 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

Avoid deeply nested control flow statements.
Open

                    if response_code not in operation_details:
                        operation_details[response_code] = True
                    add_to_additional = False
Severity: Major
Found in scripts/metrics_coverage/diff_metrics_coverage.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                        if operation not in service_details:
                            add_to_additional = True
                        else:
                            operation_details = service_details.setdefault(operation, {})
                            if response_code not in operation_details:
    Severity: Major
    Found in scripts/metrics_coverage/diff_metrics_coverage.py - About 45 mins to fix

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

      def create_initial_coverage(path_to_initial_metrics: str) -> dict:
          """
          Iterates over all csv files in `path_to_initial_metrics` and creates a dict collecting all status_codes that have been
          triggered for each service-operation combination:
      
      
      Severity: Minor
      Found in scripts/metrics_coverage/diff_metrics_coverage.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