localstack/aws/accounts.py
Function get_account_id_from_access_key_id
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
Open
def get_account_id_from_access_key_id(access_key_id: str) -> str:
"""Return the Account ID associated the Access Key ID."""
# If AWS_ACCESS_KEY_ID has a 12-digit integer value, use it as the account ID
if re.match(r"\d{12}", access_key_id):
- 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"