sensu-plugins/sensu-plugins-aws

View on GitHub

Showing 110 of 152 total issues

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

  def run
    filter_list = config[:exclude_tags].split(/}\s?{/).map do |x|
      x.gsub(/[{}]/, '')
    end
    filter_list = filter_list.map do |y|
Severity: Minor
Found in bin/check-ec2-filter.rb - 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

Method run has 54 lines of code (exceeds 25 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: Major
Found in bin/metrics-elasticache.rb - About 2 hrs to fix

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

      def run
        warning = 3
        critical = 4
        result_launched = ''
        result_terminated = ''
    Severity: Major
    Found in bin/check-asg-instances-created.rb - About 2 hrs to fix

      Method run has a Cognitive Complexity of 16 (exceeds 5 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 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

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

        def run
          event_instances = []
          aws_config = {}
      
          aws_regions = ec2_regions
      Severity: Major
      Found in bin/check-instance-events.rb - About 2 hrs to fix

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

          def run
            begin
              s3 = Aws::S3::Client.new(aws_config)
              list_buckets = s3.list_buckets
        
        
        Severity: Minor
        Found in bin/metrics-s3.rb - About 2 hrs to fix

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

            def run
              aws_config = {}
          
              if (config[:key_name].nil? && config[:key_prefix].nil?) || (!config[:key_name].nil? && !config[:key_prefix].nil?)
                critical 'Need one option between "key_name" and "key_prefix"'
          Severity: Minor
          Found in bin/check-s3-object.rb - About 2 hrs to fix

            Consider simplifying this complex logical expression.
            Open

                  if config[:complaint_crit] > 0 && config[:complaint_crit] <= complaints || \
                     config[:reject_crit] > 0 && config[:reject_crit] <= rejects || \
                     config[:bounce_crit] > 0 && config[:bounce_crit] <= bounces || \
                     config[:low_delivery_crit] > 0 && config[:low_delivery_crit] > bounces || \
                     config[:delivery_crit] > 0 && config[:delivery_crit] <= bounces
            Severity: Critical
            Found in bin/check-ses-statistics.rb - About 2 hrs to fix

              Consider simplifying this complex logical expression.
              Open

                    elsif config[:complaint_warn] > 0 && config[:complaint_warn] <= complaints || \
                          config[:reject_warn] > 0 && config[:reject_warn] <= rejects || \
                          config[:bounce_warn] > 0 && config[:bounce_warn] <= bounces || \
                          config[:low_delivery_warn] > 0 && config[:low_delivery_warn] > bounces || \
                          config[:delivery_warn] > 0 && config[:delivery_warn] <= bounces
              Severity: Critical
              Found in bin/check-ses-statistics.rb - About 2 hrs to fix

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

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

                    def run
                      warning = 0
                      critical = 0
                      instance_in_service = 0
                      result = ''
                  Severity: Minor
                  Found in bin/check-asg-instances-inservice.rb - About 1 hr to fix

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

                      def run
                        service_limit_msg = []
                    
                        begin
                          # Get all check IDs with category "service_limits"
                    Severity: Minor
                    Found in bin/check-trustedadvisor-service-limits.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 47 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def run
                        ok_message = []
                        warning_message = []
                        critical_message = []
                    
                    
                    Severity: Minor
                    Found in bin/check-elb-certs.rb - About 1 hr to fix

                      Method run has a Cognitive Complexity of 14 (exceeds 5 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

                      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_health has a Cognitive Complexity of 14 (exceeds 5 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

                      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 14 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def run
                          # Converting the string into a hash.
                          filter_list = config[:exclude_tags].split(/}\s?{/).map do |x|
                            x.gsub(/[{}]/, '')
                          end
                      Severity: Minor
                      Found in bin/check-sensu-client.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 14 (exceeds 5 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

                      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 14 (exceeds 5 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

                      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 42 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def run
                          filter = Filter.parse(config[:filter])
                          options = if filter.empty?
                                      {}
                                    else
                      Severity: Minor
                      Found in bin/check-instance-health.rb - About 1 hr to fix

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

                          def run
                            warning = 0
                            critical = 0
                            result = ''
                            if config[:load_balancer].nil?
                        Severity: Minor
                        Found in bin/check-elb-instances-inservice.rb - About 1 hr to fix
                          Severity
                          Category
                          Status
                          Source
                          Language