localstack/localstack

View on GitHub
localstack/services/cloudwatch/provider_v2.py

Summary

Maintainability
F
4 days
Test Coverage

File provider_v2.py has 796 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import datetime
import json
import logging
import threading
import uuid
Severity: Major
Found in localstack/services/cloudwatch/provider_v2.py - About 1 day to fix

    CloudwatchProvider has 33 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class CloudwatchProvider(CloudwatchApi, ServiceLifecycleHook):
        """
        Cloudwatch provider.
    
        LIMITATIONS:
    Severity: Minor
    Found in localstack/services/cloudwatch/provider_v2.py - About 4 hrs to fix

      Function set_alarm_state has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          def set_alarm_state(
              self,
              context: RequestContext,
              alarm_name: AlarmName,
              state_value: StateValue,
      Severity: Minor
      Found in localstack/services/cloudwatch/provider_v2.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_metric_statistics has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_metric_statistics(
              self,
              context: RequestContext,
              namespace: Namespace,
              metric_name: MetricName,
      Severity: Minor
      Found in localstack/services/cloudwatch/provider_v2.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 put_metric_alarm has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def put_metric_alarm(self, context: RequestContext, request: PutMetricAlarmInput) -> None:
              # missing will be the default, when not set (but it will not explicitly be set)
              if request.get("TreatMissingData", "missing") not in [
                  "breaching",
                  "notBreaching",
      Severity: Minor
      Found in localstack/services/cloudwatch/provider_v2.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_metric_statistics has 11 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def get_metric_statistics(
      Severity: Major
      Found in localstack/services/cloudwatch/provider_v2.py - About 1 hr to fix

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

            def describe_alarms(
        Severity: Major
        Found in localstack/services/cloudwatch/provider_v2.py - About 1 hr to fix

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

              def get_metric_data(
                  self,
                  context: RequestContext,
                  metric_data_queries: MetricDataQueries,
                  start_time: Timestamp,
          Severity: Minor
          Found in localstack/services/cloudwatch/provider_v2.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_parameters_for_put_metric_data has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

          def _validate_parameters_for_put_metric_data(metric_data: MetricData) -> None:
              for index, metric_item in enumerate(metric_data):
                  indexplusone = index + 1
                  if metric_item.get("Value") and metric_item.get("Values"):
                      raise InvalidParameterCombinationException(
          Severity: Minor
          Found in localstack/services/cloudwatch/provider_v2.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 describe_alarm_history has 10 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def describe_alarm_history(
          Severity: Major
          Found in localstack/services/cloudwatch/provider_v2.py - About 1 hr to fix

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

                def get_metric_data(
            Severity: Major
            Found in localstack/services/cloudwatch/provider_v2.py - About 1 hr to fix

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

                  def list_metrics(
              Severity: Major
              Found in localstack/services/cloudwatch/provider_v2.py - About 1 hr to fix

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

                    def describe_alarms_for_metric(
                Severity: Major
                Found in localstack/services/cloudwatch/provider_v2.py - About 1 hr to fix

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

                      def set_alarm_state(
                  Severity: Minor
                  Found in localstack/services/cloudwatch/provider_v2.py - About 45 mins to fix

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

                        def _update_state(
                    Severity: Minor
                    Found in localstack/services/cloudwatch/provider_v2.py - About 35 mins to fix

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

                          def describe_alarm_history(
                              self,
                              context: RequestContext,
                              alarm_name: AlarmName = None,
                              alarm_types: AlarmTypes = None,
                      Severity: Minor
                      Found in localstack/services/cloudwatch/provider_v2.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