sensu-plugins/sensu-plugins-aws

View on GitHub

Showing 110 of 152 total issues

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

  def run
    begin
      aws_region = config[:aws_region].nil? || config[:aws_region].empty? ? query_instance_region : config[:aws_region]
      elb = RightAws::ElbInterface.new(config[:aws_access_key], config[:aws_secret_access_key],
                                       logger: Logger.new('/dev/null'),
Severity: Minor
Found in bin/check-elb-health.rb - About 1 hr to fix

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

      def run
        Aws.config.update(aws_config)
        client = Aws::EC2::Client.new
    
        if config[:eni].empty?
    Severity: Minor
    Found in bin/check-eni-status.rb - About 1 hr to fix

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

        def run
          instances = []
          if config[:db_cluster_id]
            db_cluster_writer_id = find_db_cluster_writer(config[:db_cluster_id])
            instances << find_db_instance(db_cluster_writer_id)
      Severity: Minor
      Found in bin/check-rds.rb - About 1 hr to fix

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

          def run
            Aws.config.update(aws_config)
            client = Aws::EC2::Client.new
        
            if config[:eni].empty?
        Severity: Minor
        Found in bin/check-eni-status.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 11 (exceeds 5 allowed). Consider refactoring.
        Open

          def run
            errors = []
            ec2 = Aws::EC2::Client.new
        
            dhcp_option_id = ec2.describe_vpcs(vpc_ids: [config[:vpc_id]]).vpcs[0].dhcp_options_id
        Severity: Minor
        Found in bin/check-vpc-nameservers.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 11 (exceeds 5 allowed). Consider refactoring.
        Open

          def run
            # TODO: come back and refactor
            elasticaches.describe_cache_clusters.cache_clusters.each do |elasticache| # rubocop:disable Metrics/BlockLength)
              if elasticache.engine.include? 'redis'
                if config[:statistic] == ''
        Severity: Minor
        Found in bin/metrics-elasticache.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 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def run
            begin
              aws_config
              client = Aws::EC2::Client.new
        
        
        Severity: Minor
        Found in bin/check-route.rb - About 1 hr to fix

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

            def run
              filters = Filter.parse(config[:filter])
              filters.push(
                name: 'instance-state-name',
                values: ['running']
          Severity: Minor
          Found in bin/check-ec2-cpu_balance.rb - About 1 hr to fix

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

              def run
                begin
                  aws_config
                  client = Aws::EC2::Client.new
            
            
            Severity: Minor
            Found in bin/check-instance-reachability.rb - About 1 hr to fix

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

                def run
                  if config[:statistic] == ''
                    default_statistic_per_metric = {
                      'Latency' => 'Average',
                      'RequestCount' => 'Sum',
              Severity: Minor
              Found in bin/metrics-elb.rb - About 1 hr to fix

                Method check_health has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def check_health(elb)
                    unhealthy_instances = {}
                    instance_health = if config[:instances]
                                        @elb.describe_instance_health(
                                          load_balancer_name: elb.load_balancer_name,
                Severity: Minor
                Found in bin/check-elb-health-sdk.rb - About 1 hr to fix

                  Method composite_check has 29 lines of code (exceeds 25 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

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

                      def run
                        ses = Aws::SES::Client.new(aws_config)
                        begin
                          response = ses.get_send_statistics
                    
                    
                    Severity: Minor
                    Found in bin/check-ses-statistics.rb - About 1 hr to fix

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

                        def run
                          instances = []
                          if config[:db_cluster_id]
                            db_cluster_writer_id = find_db_cluster_writer(config[:db_cluster_id])
                            instances << find_db_instance(db_cluster_writer_id)
                      Severity: Minor
                      Found in bin/check-rds.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 10 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def run
                          tags = config[:tag_keys].split(',')
                          s3 = Aws::S3::Client.new
                          missing_tags = []
                          s3.list_buckets.buckets.each do |bucket|
                      Severity: Minor
                      Found in bin/check-s3-tag.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 collect has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def collect(instance)
                          message = "\n#{instance[:db_instance_identifier]}: "
                          @severities = {
                            critical: false,
                            warning:  false
                      Severity: Minor
                      Found in bin/check-rds.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 10 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def run
                          tags = config[:tag_keys].split(',')
                          cloudfront = Aws::CloudFront::Client.new
                          missing_tags = []
                          cloudfront.list_distributions.distribution_list.items.each do |distribution|
                      Severity: Minor
                      Found in bin/check-cloudfront-tag.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 26 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def run
                          service_healths = services_by_health(config[:cluster_name], config[:services], config[:primary_status])
                      
                          unhealthy = []
                          unhealthy.concat(service_healths[:critical]) if service_healths.key? :critical
                      Severity: Minor
                      Found in bin/check-ecs-service-health.rb - About 1 hr to fix

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

                          def run
                            client = Aws::CloudWatch::Client.new
                        
                            options = { state_value: config[:state] }
                        
                        
                        Severity: Minor
                        Found in bin/check-cloudwatch-alarms.rb - 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

                        Method by_instances_status has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def by_instances_status(client)
                            if config[:scheme] == 'sensu.aws.ec2'
                              config[:scheme] += '.count'
                            end
                        
                        
                        Severity: Minor
                        Found in bin/metrics-ec2-count.rb - 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

                        Severity
                        Category
                        Status
                        Source
                        Language