localstack/localstack

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

Summary

Maintainability
F
6 days
Test Coverage

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

import base64
import json
import logging
from typing import Dict, List
from uuid import uuid4
Severity: Major
Found in localstack-core/localstack/services/sns/provider.py - About 2 days to fix

    Function subscribe has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring.
    Open

        def subscribe(
            self,
            context: RequestContext,
            topic_arn: topicARN,
            protocol: String,
    Severity: Minor
    Found in localstack-core/localstack/services/sns/provider.py - About 7 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 publish has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
    Open

        def publish(
            self,
            context: RequestContext,
            message: String,
            topic_arn: topicARN = None,
    Severity: Minor
    Found in localstack-core/localstack/services/sns/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 publish_batch has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
    Open

        def publish_batch(
            self,
            context: RequestContext,
            topic_arn: topicARN,
            publish_batch_request_entries: PublishBatchRequestEntryList,
    Severity: Minor
    Found in localstack-core/localstack/services/sns/provider.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

    SnsProvider has 24 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class SnsProvider(SnsApi, ServiceLifecycleHook):
        """
        Provider class for AWS Simple Notification Service.
    
        AWS supports following operations in a cross-account setup:
    Severity: Minor
    Found in localstack-core/localstack/services/sns/provider.py - About 2 hrs to fix

      Function publish has 11 arguments (exceeds 4 allowed). Consider refactoring.
      Open

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

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

            def tag_resource(
                self, context: RequestContext, resource_arn: AmazonResourceName, tags: TagList, **kwargs
            ) -> TagResourceResponse:
                # each tag key must be unique
                # https://docs.aws.amazon.com/general/latest/gr/aws_tagging.html#tag-best-practices
        Severity: Minor
        Found in localstack-core/localstack/services/sns/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 validate_subscription_attribute has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

        def validate_subscription_attribute(
            attribute_name: str,
            attribute_value: str,
            topic_arn: str,
            endpoint: str,
        Severity: Minor
        Found in localstack-core/localstack/services/sns/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 subscribe has 7 arguments (exceeds 4 allowed). Consider refactoring.
        Open

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

          Avoid deeply nested control flow statements.
          Open

                                  if (new_attr := attributes.get(attr)) and sub.get(attr) != new_attr:
                                      raise InvalidParameterException(
                                          "Invalid parameter: Attributes Reason: Subscription already exists with different attributes"
                                      )
          
          
          Severity: Major
          Found in localstack-core/localstack/services/sns/provider.py - About 45 mins to fix

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

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

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

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

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

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

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

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

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

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

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

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

                        Function set_subscription_attributes has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def set_subscription_attributes(
                                self,
                                context: RequestContext,
                                subscription_arn: subscriptionARN,
                                attribute_name: attributeName,
                        Severity: Minor
                        Found in localstack-core/localstack/services/sns/provider.py - About 35 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