localstack/localstack

View on GitHub
scripts/capture_notimplemented_responses.py

Summary

Maintainability
D
2 days
Test Coverage

Function simulate_call has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

def simulate_call(service: str, op: str) -> RowEntry:
    """generates a mock request based on the service and operation model and sends it to the API"""
    client = connect_externally_to.get_client(
        service,
        aws_access_key_id="test",
Severity: Minor
Found in scripts/capture_notimplemented_responses.py - About 4 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

File capture_notimplemented_responses.py has 322 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import csv
import json
import logging
import re
import sys
Severity: Minor
Found in scripts/capture_notimplemented_responses.py - About 3 hrs to fix

    Function map_to_notimplemented has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

    def map_to_notimplemented(row: RowEntry) -> bool:
        """
        Some simple heuristics to check the API responses and classify them into implemented/notimplemented
    
        Ideally they all should behave the same way when receiving requests for not yet implemented endpoints
    Severity: Minor
    Found in scripts/capture_notimplemented_responses.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

    Function run_script has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def run_script(services: list[str], path: None):
        """send requests against all APIs"""
        print(
            f"writing results to '{path}implementation_coverage_full.csv' and '{path}implementation_coverage_aggregated.csv'..."
        )
    Severity: Minor
    Found in scripts/capture_notimplemented_responses.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

    Avoid deeply nested control flow statements.
    Open

                        if result.get("error_code", "") != "InternalError":
                            break
                        if argument in parameters:
    Severity: Major
    Found in scripts/capture_notimplemented_responses.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          if argument in parameters:
                              # sometimes the parameter seem to be automatically added again by boto
                              # happened eg for ClientToken in ec2.ProvisionIpamPoolCidr
                              logging.warning(
                                  "unexpected keyword '%s' was added to the parameters again for: %s.%s",
      Severity: Major
      Found in scripts/capture_notimplemented_responses.py - About 45 mins to fix

        Avoid too many return statements within this function.
        Open

                return True
        Severity: Major
        Found in scripts/capture_notimplemented_responses.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                  return True
          Severity: Major
          Found in scripts/capture_notimplemented_responses.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                    return True
            Severity: Major
            Found in scripts/capture_notimplemented_responses.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                      return True
              Severity: Major
              Found in scripts/capture_notimplemented_responses.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                        return True
                Severity: Major
                Found in scripts/capture_notimplemented_responses.py - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                      return False
                  Severity: Major
                  Found in scripts/capture_notimplemented_responses.py - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                            return True
                    Severity: Major
                    Found in scripts/capture_notimplemented_responses.py - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                              return True
                      Severity: Major
                      Found in scripts/capture_notimplemented_responses.py - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                return True
                        Severity: Major
                        Found in scripts/capture_notimplemented_responses.py - About 30 mins to fix

                          There are no issues that match your filters.

                          Category
                          Status