localstack/localstack

View on GitHub
localstack/aws/handlers/cors.py

Summary

Maintainability
A
3 hrs
Test Coverage

Function _is_in_allowed_origins has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def _is_in_allowed_origins(allowed_origins: List[str], origin: str) -> bool:
        """Returns true if the `origin` is in the `allowed_origins`."""
        for allowed_origin in allowed_origins:
            if allowed_origin == "*" or origin == allowed_origin:
                return True
Severity: Minor
Found in localstack/aws/handlers/cors.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

Function add_cors_headers has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def add_cors_headers(request_headers: Headers, response_headers: Headers):
        if ACL_ORIGIN not in response_headers:
            response_headers[ACL_ORIGIN] = (
                request_headers["Origin"]
                if request_headers.get("Origin") and not config.DISABLE_CORS_CHECKS
Severity: Minor
Found in localstack/aws/handlers/cors.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

Function should_enforce_self_managed_service has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def should_enforce_self_managed_service(context: RequestContext) -> bool:
    """
    Some services are handling their CORS checks on their own (depending on config vars).

    :param context: context of the request for which to check if the CORS checks should be executed in here or in
Severity: Minor
Found in localstack/aws/handlers/cors.py - About 55 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