sensu-plugins/sensu-plugins-aws

View on GitHub

Showing 110 of 152 total issues

Method run has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def run
    elb = Aws::ElasticLoadBalancing::Client.new(aws_config)

    begin
      instance_health = elb.describe_instance_health(load_balancer_name: config[:load_balancer])
Severity: Minor
Found in bin/check-elb-nodes.rb - About 1 hr to fix

    Method handle has 40 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def handle
        mail_to = build_mail_to_list
        body = <<-BODY.gsub(/^\s+/, '')
                #{@event['check']['output']}
                Host: #{@event['client']['name']}
    Severity: Minor
    Found in bin/handler-ses.rb - About 1 hr to fix

      Method run has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def run
          errors = []
          @ec2 = Aws::EC2::Client.new
      
          volumes = @ec2.describe_volumes(
      Severity: Minor
      Found in bin/check-ebs-snapshots.rb - About 1 hr to fix

        Method run has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

          def run
            # Subnets that meet the threshold criteria will store info hashes in this array
            consumption_alert = []
        
            begin
        Severity: Minor
        Found in bin/check-subnet-ip-consumption.rb - 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

        Method run has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

          def run
            errors = []
            @ec2 = Aws::EC2::Client.new
        
            volumes = @ec2.describe_volumes(
        Severity: Minor
        Found in bin/check-ebs-snapshots.rb - 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

        Method run has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

          def run
            errors = []
        
            volume_filters = Filter.parse(config[:filter])
        
        
        Severity: Minor
        Found in bin/check-ebs-burst-limit.rb - 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

        Method run has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def run
            begin
              client = Aws::EC2::Client.new(aws_config)
        
              params = {
        Severity: Minor
        Found in bin/check-expiring-reservations.rb - About 1 hr to fix

          Method run has 39 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def run
              begin
                cw = Aws::CloudWatch::Client.new(aws_config)
                now = Time.now
                r = cw.get_metric_statistics(
          Severity: Minor
          Found in bin/metrics-billing.rb - About 1 hr to fix

            Method run has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def run
                aws_regions = ec2_regions
                @message = ''
                critical = false
            
            
            Severity: Minor
            Found in bin/check-elb-health-sdk.rb - About 1 hr to fix

              Method run has 36 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def run
                  errors = []
                  warnings = []
                  buckets = if config[:all_buckets]
                              list_buckets
              Severity: Minor
              Found in bin/check-s3-bucket-visibility.rb - About 1 hr to fix

                Method check_capacity has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                  def check_capacity(table)
                    config[:capacity_for].each do |r_or_w|
                      metric_name   = "Consumed#{r_or_w.to_s.capitalize}CapacityUnits"
                      metric        = cloud_watch_metric metric_name, table.table_name
                      metric_value  = begin
                Severity: Minor
                Found in bin/check-dynamodb-capacity.rb - 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

                Method check_sum_requests has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                  def check_sum_requests(elb)
                    metric        = request_count_metric elb.load_balancer_name
                    metric_value  = begin
                                      latest_value metric
                                    rescue StandardError
                Severity: Minor
                Found in bin/check-elb-sum-requests.rb - 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

                Method run has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                  def run
                    aws_region = config[:aws_region].nil? || config[:aws_region].empty? ? query_instance_region : config[:aws_region]
                    begin
                      elb = Fog::AWS::ELB.new aws_config
                      if config[:instances]
                Severity: Minor
                Found in bin/check-elb-health-fog.rb - 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

                Method check_latency has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                  def check_latency(elb)
                    metric        = latency_metric elb.load_balancer_name
                    metric_value  = begin
                                      latest_value metric
                                    rescue StandardError
                Severity: Minor
                Found in bin/check-elb-latency.rb - 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

                Method ec2_node_should_be_deleted? has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                  def ec2_node_should_be_deleted?
                    # Defining region for aws SDK object
                    ec2 = Aws::EC2::Client.new(region: region)
                    settings['ec2_node'] = {} unless settings['ec2_node']
                    instance_states = @event['client']['ec2_states'] || settings['ec2_node']['ec2_states'] || ['shutting-down', 'terminated', 'stopping', 'stopped']
                Severity: Minor
                Found in bin/handler-ec2_node.rb - 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

                Method composite_check has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                  def composite_check
                    numerator_metric_resp = get_metric(config[:numerator_metric_name])
                    denominator_metric_resp = get_metric(config[:denominator_metric_name])
                
                    ## If the numerator is empty, then we see if there is a default. If there is a default
                Severity: Minor
                Found in bin/check-cloudwatch-composite-metric.rb - 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

                Method check_throttle has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                  def check_throttle(table)
                    config[:throttle_for].each do |r_or_w|
                      metric_name   = "#{r_or_w.to_s.capitalize}ThrottleEvents"
                      metric        = cloud_watch_metric metric_name, table.table_name
                      metric_value  = begin
                Severity: Minor
                Found in bin/check-dynamodb-throttle.rb - 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

                Method run has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def run
                    statistic_type = {
                      'CPUUtilization' => 'Average',
                      'DatabaseConnections' => 'Average',
                      'FreeStorageSpace' => 'Average',
                Severity: Minor
                Found in bin/metrics-rds.rb - About 1 hr to fix

                  Method maint_clusters has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def maint_clusters
                      maint_clusters = []
                      aws_regions = rds_regions
                  
                      unless config[:aws_region].casecmp('all').zero?
                  Severity: Minor
                  Found in bin/check-rds-events.rb - About 1 hr to fix

                    Method run has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def run
                        aws_config = {}
                        if config[:use_iam_role].nil?
                          aws_config[:access_key_id] = config[:aws_access_key]
                          aws_config[:secret_access_key] = config[:aws_secret_access_key]
                    Severity: Minor
                    Found in bin/check-emr-cluster.rb - About 1 hr to fix
                      Severity
                      Category
                      Status
                      Source
                      Language