localstack/localstack

View on GitHub
localstack-core/localstack/services/lambda_/provider.py

Summary

Maintainability
F
2 wks
Test Coverage

File provider.py has 3300 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import base64
import dataclasses
import datetime
import json
import logging
Severity: Major
Found in localstack-core/localstack/services/lambda_/provider.py - About 1 wk to fix

    Function on_after_state_load has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
    Open

        def on_after_state_load(self):
            self.lambda_service = LambdaService()
            self.router.lambda_service = self.lambda_service
    
            for account_id, account_bundle in lambda_stores.items():
    Severity: Minor
    Found in localstack-core/localstack/services/lambda_/provider.py - About 5 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 _validate_layers has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
    Open

        def _validate_layers(self, new_layers: list[str], region: str, account_id: str):
            if len(new_layers) > LAMBDA_LAYERS_LIMIT_PER_FUNCTION:
                raise InvalidParameterValueException(
                    "Cannot reference more than 5 layers.", Type="User"
                )
    Severity: Minor
    Found in localstack-core/localstack/services/lambda_/provider.py - About 4 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 add_layer_version_permission has 10 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def add_layer_version_permission(
    Severity: Major
    Found in localstack-core/localstack/services/lambda_/provider.py - About 1 hr to fix

      Function _resolve_fn_qualifier has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def _resolve_fn_qualifier(resolved_fn: Function, qualifier: str | None) -> tuple[str, str]:
              """Attempts to resolve a given qualifier and returns a qualifier that exists or
              raises an appropriate ResourceNotFoundException.
      
              :param resolved_fn: The resolved lambda function
      Severity: Minor
      Found in localstack-core/localstack/services/lambda_/provider.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 invoke has 9 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def invoke(
      Severity: Major
      Found in localstack-core/localstack/services/lambda_/provider.py - About 1 hr to fix

        Function publish_layer_version has 9 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def publish_layer_version(
        Severity: Major
        Found in localstack-core/localstack/services/lambda_/provider.py - About 1 hr to fix

          Function update_alias has 9 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def update_alias(
          Severity: Major
          Found in localstack-core/localstack/services/lambda_/provider.py - About 1 hr to fix

            Function update_function_event_invoke_config has 8 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def update_function_event_invoke_config(
            Severity: Major
            Found in localstack-core/localstack/services/lambda_/provider.py - About 1 hr to fix

              Function list_functions has 8 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def list_functions(
              Severity: Major
              Found in localstack-core/localstack/services/lambda_/provider.py - About 1 hr to fix

                Function create_function_url_config has 8 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def create_function_url_config(
                Severity: Major
                Found in localstack-core/localstack/services/lambda_/provider.py - About 1 hr to fix

                  Function list_layer_versions has 8 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      def list_layer_versions(
                  Severity: Major
                  Found in localstack-core/localstack/services/lambda_/provider.py - About 1 hr to fix

                    Function update_function_url_config has 8 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        def update_function_url_config(
                    Severity: Major
                    Found in localstack-core/localstack/services/lambda_/provider.py - About 1 hr to fix

                      Function put_function_event_invoke_config has 8 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          def put_function_event_invoke_config(
                      Severity: Major
                      Found in localstack-core/localstack/services/lambda_/provider.py - About 1 hr to fix

                        Function create_alias has 8 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                            def create_alias(
                        Severity: Major
                        Found in localstack-core/localstack/services/lambda_/provider.py - About 1 hr to fix

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

                              def _create_version_model(
                                  self,
                                  function_name: str,
                                  region: str,
                                  account_id: str,
                          Severity: Minor
                          Found in localstack-core/localstack/services/lambda_/provider.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

                          Function list_event_source_mappings has 7 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                              def list_event_source_mappings(
                          Severity: Major
                          Found in localstack-core/localstack/services/lambda_/provider.py - About 50 mins to fix

                            Function remove_layer_version_permission has 7 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                                def remove_layer_version_permission(
                            Severity: Major
                            Found in localstack-core/localstack/services/lambda_/provider.py - About 50 mins to fix

                              Function _create_version_model has 7 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                                  def _create_version_model(
                              Severity: Major
                              Found in localstack-core/localstack/services/lambda_/provider.py - About 50 mins to fix

                                Function _publish_version_from_existing_version has 7 arguments (exceeds 4 allowed). Consider refactoring.
                                Open

                                    def _publish_version_from_existing_version(
                                Severity: Major
                                Found in localstack-core/localstack/services/lambda_/provider.py - About 50 mins to fix

                                  Function remove_permission has 7 arguments (exceeds 4 allowed). Consider refactoring.
                                  Open

                                      def remove_permission(
                                  Severity: Major
                                  Found in localstack-core/localstack/services/lambda_/provider.py - About 50 mins to fix

                                    Function list_aliases has 7 arguments (exceeds 4 allowed). Consider refactoring.
                                    Open

                                        def list_aliases(
                                    Severity: Major
                                    Found in localstack-core/localstack/services/lambda_/provider.py - About 50 mins to fix

                                      Function list_layers has 7 arguments (exceeds 4 allowed). Consider refactoring.
                                      Open

                                          def list_layers(
                                      Severity: Major
                                      Found in localstack-core/localstack/services/lambda_/provider.py - About 50 mins to fix

                                        Function publish_version has 7 arguments (exceeds 4 allowed). Consider refactoring.
                                        Open

                                            def publish_version(
                                        Severity: Major
                                        Found in localstack-core/localstack/services/lambda_/provider.py - About 50 mins to fix

                                          Function update_code_signing_config has 7 arguments (exceeds 4 allowed). Consider refactoring.
                                          Open

                                              def update_code_signing_config(
                                          Severity: Major
                                          Found in localstack-core/localstack/services/lambda_/provider.py - About 50 mins to fix

                                            Function _publish_version_with_changes has 7 arguments (exceeds 4 allowed). Consider refactoring.
                                            Open

                                                def _publish_version_with_changes(
                                            Severity: Major
                                            Found in localstack-core/localstack/services/lambda_/provider.py - About 50 mins to fix

                                              Function list_function_url_configs has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                              Open

                                                  def list_function_url_configs(
                                              Severity: Minor
                                              Found in localstack-core/localstack/services/lambda_/provider.py - About 45 mins to fix

                                                Function list_function_event_invoke_configs has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                                Open

                                                    def list_function_event_invoke_configs(
                                                Severity: Minor
                                                Found in localstack-core/localstack/services/lambda_/provider.py - About 45 mins to fix

                                                  Function create_code_signing_config has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                                  Open

                                                      def create_code_signing_config(
                                                  Severity: Minor
                                                  Found in localstack-core/localstack/services/lambda_/provider.py - About 45 mins to fix

                                                    Function list_functions_by_code_signing_config has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                                    Open

                                                        def list_functions_by_code_signing_config(
                                                    Severity: Minor
                                                    Found in localstack-core/localstack/services/lambda_/provider.py - About 45 mins to fix

                                                      Function put_provisioned_concurrency_config has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                                      Open

                                                          def put_provisioned_concurrency_config(
                                                      Severity: Minor
                                                      Found in localstack-core/localstack/services/lambda_/provider.py - About 45 mins to fix

                                                        Avoid deeply nested control flow statements.
                                                        Open

                                                                                    if api_utils.qualifier_is_alias(provisioned_qualifier):
                                                                                        alias = fn.aliases.get(provisioned_qualifier)
                                                                                        resolved_version = fn.versions.get(alias.function_version)
                                                                                        fn_arn = resolved_version.id.qualified_arn()
                                                                                    elif api_utils.qualifier_is_version(provisioned_qualifier):
                                                        Severity: Major
                                                        Found in localstack-core/localstack/services/lambda_/provider.py - About 45 mins to fix

                                                          Function list_provisioned_concurrency_configs has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                                          Open

                                                              def list_provisioned_concurrency_configs(
                                                          Severity: Minor
                                                          Found in localstack-core/localstack/services/lambda_/provider.py - About 45 mins to fix

                                                            Function list_versions_by_function has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                                            Open

                                                                def list_versions_by_function(
                                                            Severity: Minor
                                                            Found in localstack-core/localstack/services/lambda_/provider.py - About 45 mins to fix

                                                              Function delete_alias has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                              Open

                                                                  def delete_alias(
                                                              Severity: Minor
                                                              Found in localstack-core/localstack/services/lambda_/provider.py - About 35 mins to fix

                                                                Function get_policy has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                                Open

                                                                    def get_policy(
                                                                Severity: Minor
                                                                Found in localstack-core/localstack/services/lambda_/provider.py - About 35 mins to fix

                                                                  Function delete_function_event_invoke_config has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                                  Open

                                                                      def delete_function_event_invoke_config(
                                                                  Severity: Minor
                                                                  Found in localstack-core/localstack/services/lambda_/provider.py - About 35 mins to fix

                                                                    Function get_layer_version has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                                    Open

                                                                        def get_layer_version(
                                                                    Severity: Minor
                                                                    Found in localstack-core/localstack/services/lambda_/provider.py - About 35 mins to fix

                                                                      Function delete_layer_version has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                                      Open

                                                                          def delete_layer_version(
                                                                      Severity: Minor
                                                                      Found in localstack-core/localstack/services/lambda_/provider.py - About 35 mins to fix

                                                                        Function delete_function has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                                        Open

                                                                            def delete_function(
                                                                        Severity: Minor
                                                                        Found in localstack-core/localstack/services/lambda_/provider.py - About 35 mins to fix

                                                                          Function get_alias has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                                          Open

                                                                              def get_alias(
                                                                          Severity: Minor
                                                                          Found in localstack-core/localstack/services/lambda_/provider.py - About 35 mins to fix

                                                                            Function delete_function_url_config has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                                            Open

                                                                                def delete_function_url_config(
                                                                            Severity: Minor
                                                                            Found in localstack-core/localstack/services/lambda_/provider.py - About 35 mins to fix

                                                                              Function put_function_code_signing_config has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                                              Open

                                                                                  def put_function_code_signing_config(
                                                                              Severity: Minor
                                                                              Found in localstack-core/localstack/services/lambda_/provider.py - About 35 mins to fix

                                                                                Function list_code_signing_configs has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                                                Open

                                                                                    def list_code_signing_configs(
                                                                                Severity: Minor
                                                                                Found in localstack-core/localstack/services/lambda_/provider.py - About 35 mins to fix

                                                                                  Function delete_provisioned_concurrency_config has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                                                  Open

                                                                                      def delete_provisioned_concurrency_config(
                                                                                  Severity: Minor
                                                                                  Found in localstack-core/localstack/services/lambda_/provider.py - About 35 mins to fix

                                                                                    Function get_layer_version_policy has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                                                    Open

                                                                                        def get_layer_version_policy(
                                                                                    Severity: Minor
                                                                                    Found in localstack-core/localstack/services/lambda_/provider.py - About 35 mins to fix

                                                                                      Function invoke_async has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                                                      Open

                                                                                          def invoke_async(
                                                                                      Severity: Minor
                                                                                      Found in localstack-core/localstack/services/lambda_/provider.py - About 35 mins to fix

                                                                                        Function get_function has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                                                        Open

                                                                                            def get_function(
                                                                                        Severity: Minor
                                                                                        Found in localstack-core/localstack/services/lambda_/provider.py - About 35 mins to fix

                                                                                          Function get_function_configuration has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                                                          Open

                                                                                              def get_function_configuration(
                                                                                          Severity: Minor
                                                                                          Found in localstack-core/localstack/services/lambda_/provider.py - About 35 mins to fix

                                                                                            Function get_function_event_invoke_config has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                                                            Open

                                                                                                def get_function_event_invoke_config(
                                                                                            Severity: Minor
                                                                                            Found in localstack-core/localstack/services/lambda_/provider.py - About 35 mins to fix

                                                                                              Function untag_resource has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                                                              Open

                                                                                                  def untag_resource(
                                                                                              Severity: Minor
                                                                                              Found in localstack-core/localstack/services/lambda_/provider.py - About 35 mins to fix

                                                                                                Function get_function_url_config has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                                                                Open

                                                                                                    def get_function_url_config(
                                                                                                Severity: Minor
                                                                                                Found in localstack-core/localstack/services/lambda_/provider.py - About 35 mins to fix

                                                                                                  Function get_provisioned_concurrency_config has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                                                                  Open

                                                                                                      def get_provisioned_concurrency_config(
                                                                                                  Severity: Minor
                                                                                                  Found in localstack-core/localstack/services/lambda_/provider.py - About 35 mins to fix

                                                                                                    Function put_function_concurrency has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                                                                    Open

                                                                                                        def put_function_concurrency(
                                                                                                    Severity: Minor
                                                                                                    Found in localstack-core/localstack/services/lambda_/provider.py - About 35 mins to fix

                                                                                                      Function tag_resource has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                                                                      Open

                                                                                                          def tag_resource(
                                                                                                      Severity: Minor
                                                                                                      Found in localstack-core/localstack/services/lambda_/provider.py - About 35 mins to fix

                                                                                                        There are no issues that match your filters.

                                                                                                        Category
                                                                                                        Status