localstack/localstack

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

Summary

Maintainability
F
1 wk
Test Coverage

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

import copy
import hashlib
import json
import logging
import re
Severity: Major
Found in localstack-core/localstack/services/sqs/provider.py - About 4 days to fix

    Function create_queue has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        def create_queue(
            self,
            context: RequestContext,
            queue_name: String,
            attributes: QueueAttributeMap = None,
    Severity: Minor
    Found in localstack-core/localstack/services/sqs/provider.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 check_attributes has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

    def check_attributes(message_attributes: MessageBodyAttributeMap):
        if not message_attributes:
            return
        for attribute_name in message_attributes:
            if len(attribute_name) >= 256:
    Severity: Minor
    Found in localstack-core/localstack/services/sqs/provider.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 _run has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

        def _run(self, move_task: MessageMoveTask):
            try:
                if move_task.destination_arn:
                    LOG.info(
                        "Move task started %s (%s -> %s)",
    Severity: Minor
    Found in localstack-core/localstack/services/sqs/provider.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 _collect_messages has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        def _collect_messages(
            self, queue: SqsQueue, show_invisible: bool = False, show_delayed: bool = False
        ) -> List[Message]:
            """
            Retrieves from a given SqsQueue all visible messages without causing any side effects (not setting any
    Severity: Minor
    Found in localstack-core/localstack/services/sqs/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 receive_message has 11 arguments (exceeds 4 allowed). Consider refactoring.
    Open

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

      Function send_message has 10 arguments (exceeds 4 allowed). Consider refactoring.
      Open

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

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

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

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

              def do_update_all_queues(self):
                  for queue in self.iter_queues():
                      try:
                          queue.requeue_inflight_messages()
                      except Exception:
          Severity: Minor
          Found in localstack-core/localstack/services/sqs/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 add_permission has 7 arguments (exceeds 4 allowed). Consider refactoring.
          Open

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

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

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

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

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

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

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

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

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

                    Avoid deeply nested control flow statements.
                    Open

                                            if queue.attributes.get(k) != v:
                                                LOG.debug(
                                                    "queue attribute values %s for queue %s do not match %s (existing) != %s (new)",
                                                    k,
                                                    queue_name,
                    Severity: Major
                    Found in localstack-core/localstack/services/sqs/provider.py - About 45 mins to fix

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                          def tag_queue(self, context: RequestContext, queue_url: String, tags: TagMap, **kwargs) -> None:
                                      Severity: Minor
                                      Found in localstack-core/localstack/services/sqs/provider.py - About 35 mins to fix

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                          def send_message_batch(
                                                              self,
                                                              context: RequestContext,
                                                              queue_url: String,
                                                              entries: SendMessageBatchRequestEntryList,
                                                      Severity: Minor
                                                      Found in localstack-core/localstack/services/sqs/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

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

                                                          def receive_message(
                                                              self,
                                                              context: RequestContext,
                                                              queue_url: String,
                                                              attribute_names: AttributeNameList = None,
                                                      Severity: Minor
                                                      Found in localstack-core/localstack/services/sqs/provider.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

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

                                                          def publish_approximate_cloudwatch_metrics(self):
                                                              """Publishes the metrics for ApproximateNumberOfMessagesVisible, ApproximateNumberOfMessagesNotVisible
                                                              and ApproximateNumberOfMessagesDelayed to CloudWatch"""
                                                              # TODO ApproximateAgeOfOldestMessage is missing
                                                              #  https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-available-cloudwatch-metrics.html
                                                      Severity: Minor
                                                      Found in localstack-core/localstack/services/sqs/provider.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