atlassian/localstack

View on GitHub
localstack/utils/persistence.py

Summary

Maintainability
A
2 hrs
Test Coverage

Function get_file_path has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def get_file_path(api, create=False):
    if api not in API_FILE_PATHS:
        API_FILE_PATHS[api] = False
        if not DATA_DIR:
            return False
Severity: Minor
Found in localstack/utils/persistence.py - About 45 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 record has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

def record(api, method, path, data, headers):
Severity: Minor
Found in localstack/utils/persistence.py - About 35 mins to fix

    Function should_record has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def should_record(api, method, path, data, headers):
    Severity: Minor
    Found in localstack/utils/persistence.py - About 35 mins to fix

      Function record has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      def record(api, method, path, data, headers):
          """ Record a given API call to a persistent file on disk """
          file_path = get_file_path(api, create=True)
          if CURRENTLY_REPLAYING or not file_path or not should_record(api, method, path, data, headers):
              return
      Severity: Minor
      Found in localstack/utils/persistence.py - About 35 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