localstack/utils/persistence.py
Function get_file_path
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
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
- Read upRead up
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
Open
def record(api, method, path, data, headers):
Function should_record
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def should_record(api, method, path, data, headers):
Function record
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
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
- Read upRead up
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"