localstack/localstack

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

Summary

Maintainability
F
3 days
Test Coverage

File publisher.py has 1070 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import abc
import base64
import copy
import datetime
import hashlib
Severity: Major
Found in localstack-core/localstack/services/sns/publisher.py - About 2 days to fix

    Function _publish has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

        def _publish(self, context: SnsBatchPublishContext, subscriber: SnsSubscription):
            entries = []
            sqs_system_attrs = create_sqs_system_attributes(context.request_headers)
            # TODO: check ID, SNS rules are not the same as SQS, so maybe generate the entries ID
            failure_map = {}
    Severity: Minor
    Found in localstack-core/localstack/services/sns/publisher.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

    Function store_delivery_log has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def store_delivery_log(
        message_context: SnsMessage,
        subscriber: SnsSubscription,
        success: bool,
        topic_attributes: dict[str, str] = None,
    Severity: Minor
    Found in localstack-core/localstack/services/sns/publisher.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 create_sns_message_body has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def create_sns_message_body(
        message_context: SnsMessage,
        subscriber: SnsSubscription,
        topic_attributes: dict[str, str] = None,
    ) -> str:
    Severity: Minor
    Found in localstack-core/localstack/services/sns/publisher.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 get_sqs_kwargs has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_sqs_kwargs(msg_context: SnsMessage, subscriber: SnsSubscription):
            kwargs = {}
            if is_raw_message_delivery(subscriber) and msg_context.message_attributes:
                kwargs["MessageAttributes"] = msg_context.message_attributes
    
    
    Severity: Minor
    Found in localstack-core/localstack/services/sns/publisher.py - About 45 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 store_delivery_log has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

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

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

          def _publish(self, context: SnsPublishContext, subscriber: SnsSubscription):
              message_context = context.message
              message_body = self.prepare_message(
                  message_context, subscriber, topic_attributes=context.topic_attributes
              )
      Severity: Minor
      Found in localstack-core/localstack/services/sns/publisher.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