sensu-plugins/sensu-plugins-elasticsearch

View on GitHub

Showing 69 of 69 total issues

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

  def run
    options = {}
    unless config[:level].nil?
      options[:level] = config[:level]
    end
Severity: Minor
Found in bin/check-es-cluster-health.rb - About 1 hr to fix

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

      def run
        response = client.search(build_request_options)
        if config[:invert]
          if response['aggregations']['average']['value'] < config[:crit]
            critical "Query average (#{response['aggregations']['average']['value']}) was below critical threshold. #{kibana_info}"
    Severity: Minor
    Found in bin/check-es-query-average.rb - About 1 hr to fix

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

        def run
          response = client.count(build_request_options)
          if config[:invert]
            if response['count'] < config[:crit]
              critical "Query count (#{response['count']}) was below critical threshold. #{kibana_info}"
      Severity: Minor
      Found in bin/check-es-query-count.rb - About 1 hr to fix

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

          def run
            # If only one cluster is given, no need to check the indexes
            ok 'All indexes are unique' if config[:cluster].length == 1
        
            port = ':9200'
        Severity: Minor
        Found in bin/check-es-indexes.rb - About 1 hr to fix

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

            def get_es_resource(resource)
              headers = {}
              if config[:user] && config[:password]
                auth = 'Basic ' + Base64.strict_encode64("#{config[:user]}:#{config[:password]}").chomp
                headers = { 'Authorization' => auth }
          Severity: Minor
          Found in bin/metrics-es-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 acquire_es_resource has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

            def acquire_es_resource(resource)
              headers = {}
              if config[:user] && config[:password]
                auth = 'Basic ' + Base64.strict_encode64("#{config[:user]}:#{config[:password]}").chomp
                headers = { 'Authorization' => auth }
          Severity: Minor
          Found in bin/check-es-heap.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 get_es_resource has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

            def get_es_resource(resource)
              headers = {}
              if config[:user] && config[:password]
                auth = 'Basic ' + Base64.strict_encode64("#{config[:user]}:#{config[:password]}").chomp
                headers = { 'Authorization' => auth }
          Severity: Minor
          Found in bin/check-es-file-descriptors.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 get_es_resource has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

            def get_es_resource(resource)
              headers = {}
              if config[:user] && config[:password]
                auth = 'Basic ' + Base64.strict_encode64("#{config[:user]}:#{config[:password]}").chomp
                headers = { 'Authorization' => auth }
          Severity: Minor
          Found in bin/metrics-es-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 get_es_resource has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

            def get_es_resource(resource)
              headers = {}
              if config[:user] && config[:password]
                auth = 'Basic ' + Base64.strict_encode64("#{config[:user]}:#{config[:password]}").chomp
                headers = { 'Authorization' => auth }
          Severity: Minor
          Found in bin/metrics-es-node-graphite.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 get_es_resource has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

            def get_es_resource(resource)
              headers = {}
              if config[:user] && config[:password]
                auth = 'Basic ' + Base64.strict_encode64("#{config[:user]}:#{config[:password]}").chomp
                headers = { 'Authorization' => auth }
          Severity: Minor
          Found in bin/check-es-cluster-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 get_es_resource has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

            def get_es_resource(resource)
              headers = {}
              if config[:user] && config[:password]
                auth = 'Basic ' + Base64.strict_encode64("#{config[:user]}:#{config[:password]}").chomp
                headers = { 'Authorization' => auth }
          Severity: Minor
          Found in bin/check-es-circuit-breakers.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 get_es_resource has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

            def get_es_resource(resource)
              headers = {}
              if config[:user] && config[:password]
                auth = 'Basic ' + Base64.strict_encode64("#{config[:user]}:#{config[:password]}").chomp
                headers = { 'Authorization' => auth }
          Severity: Minor
          Found in bin/check-es-node-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 breaker_status has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

            def breaker_status
              breakers = {}
              status = if config[:localhost]
                         get_es_resource('/_nodes/_local/stats/breaker')
                       else
          Severity: Minor
          Found in bin/check-es-circuit-breakers.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 get_es_resource has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def get_es_resource(resource)
              headers = {}
              if config[:user] && config[:password]
                auth = 'Basic ' + Base64.strict_encode64("#{config[:user]}:#{config[:password]}").chomp
                headers = { 'Authorization' => auth }
          Severity: Minor
          Found in bin/check-es-file-descriptors.rb - About 1 hr to fix

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

              def run
                fieldcounts = indexfieldcount
                limits = fieldlimitsetting
            
                warnings = {}
            Severity: Minor
            Found in bin/check-es-indices-field-count.rb - About 1 hr to fix

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

                def run
                  node_fs_stats = client.nodes.stats metric: 'fs,indices'
                  nodes_being_used = node_fs_stats['nodes'].values.select { |node| node['indices']['store']['size_in_bytes'] > 0 }
              
                  # TODO: come back and cleanup all these rubocop disables with a little refactor
              Severity: Minor
              Found in bin/check-es-indices-sizes.rb - About 1 hr to fix

                Method get_es_resource has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def get_es_resource(resource)
                    headers = {}
                    if config[:user] && config[:password]
                      auth = 'Basic ' + Base64.strict_encode64("#{config[:user]}:#{config[:password]}").chomp
                      headers = { 'Authorization' => auth }
                Severity: Minor
                Found in bin/check-es-node-status.rb - About 1 hr to fix

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

                    def run
                      es_version = Gem::Version.new(acquire_es_version)
                  
                      if es_version >= Gem::Version.new('1.0.0')
                        ln = get_es_resource('/_nodes/_local')
                  Severity: Minor
                  Found in bin/metrics-es-node.rb - About 1 hr to fix

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

                      def run
                        stats = acquire_status
                    
                        if stats.code == 200
                          if config[:all]
                    Severity: Minor
                    Found in bin/check-es-node-status.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 acquire_heap_usage has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def acquire_heap_usage(heap_used, heap_max, node_name)
                        if config[:percentage]
                          heap_usage = ((100 * heap_used) / heap_max).to_i
                          output = if config[:all]
                                     "Node #{node_name}: Heap used in bytes #{heap_used} (#{heap_usage}% full)\n"
                    Severity: Minor
                    Found in bin/check-es-heap.rb - About 45 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