localstack/localstack

View on GitHub
localstack-core/localstack/testing/snapshots/transformer_utility.py

Summary

Maintainability
D
2 days
Test Coverage

File transformer_utility.py has 720 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import json
import logging
import re
from datetime import datetime
from json import JSONDecodeError
Severity: Major
Found in localstack-core/localstack/testing/snapshots/transformer_utility.py - About 1 day to fix

    TransformerUtility has 34 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class TransformerUtility:
        @staticmethod
        def key_value(
            key: str, value_replacement: Optional[str] = None, reference_replacement: bool = True
        ):
    Severity: Minor
    Found in localstack-core/localstack/testing/snapshots/transformer_utility.py - About 4 hrs to fix

      Function _resource_name_transformer has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

      def _resource_name_transformer(key: str, val: str) -> str:
          if isinstance(val, str):
              match = re.match(PATTERN_ARN, val)
              if match:
                  res = match.groups()[-1]
      Severity: Minor
      Found in localstack-core/localstack/testing/snapshots/transformer_utility.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

      Avoid too many return statements within this function.
      Open

                              return layer_name  # noqa
      Severity: Major
      Found in localstack-core/localstack/testing/snapshots/transformer_utility.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                                return layer_name  # noqa
        Severity: Major
        Found in localstack-core/localstack/testing/snapshots/transformer_utility.py - About 30 mins to fix

          Function secretsmanager_api has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def secretsmanager_api():
                  return [
                      KeyValueBasedTransformer(
                          lambda k, v: (
                              k
          Severity: Minor
          Found in localstack-core/localstack/testing/snapshots/transformer_utility.py - About 25 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