localstack/localstack

View on GitHub
localstack/aws/protocol/op_router.py

Summary

Maintainability
C
7 hrs
Test Coverage

Function matches has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

    def matches(self, query_args: MultiDict, headers: Headers) -> bool:
        """
        Returns true if the given query args and the given headers of a request match the required query args and
        headers of this rule.
        :param query_args: query arguments of the incoming request
Severity: Minor
Found in localstack/aws/protocol/op_router.py - About 3 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 from_operation has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    def from_operation(op: OperationModel) -> "_HttpOperation":
        # botocore >= 1.28 might modify the internal model (specifically for S3).
        # It will modify the request URI to strip the bucket name from the path and set the original value at
        # "authPath".
        # Since botocore 1.31.2, botocore will strip the query from the `authPart`
Severity: Minor
Found in localstack/aws/protocol/op_router.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

Avoid deeply nested control flow statements.
Open

                        if query_name not in query_args:
                            # an empty list defines a required query param only needs to be present
                            # (no specific value will be enforced when matching)
                            query_args[query_name] = []

Severity: Major
Found in localstack/aws/protocol/op_router.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                            if value not in query_arg_values:
                                return False
    
    
    Severity: Major
    Found in localstack/aws/protocol/op_router.py - About 45 mins to fix

      There are no issues that match your filters.

      Category
      Status