sensu-plugins/sensu-plugins-elasticsearch

View on GitHub

Showing 53 of 69 total issues

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

  def run
    # invert various stats depending on if some flags are set
    os_stat = !config[:disable_os_stats]
    process_stats = !config[:disable_process_stats]
    jvm_stats = !config[:disable_jvm_stats]
Severity: Minor
Found in bin/metrics-es-node-graphite.rb - About 1 day 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 133 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def run
    # invert various stats depending on if some flags are set
    os_stat = !config[:disable_os_stats]
    process_stats = !config[:disable_process_stats]
    jvm_stats = !config[:disable_jvm_stats]
Severity: Major
Found in bin/metrics-es-node-graphite.rb - About 5 hrs to fix

    Method run has a Cognitive Complexity of 26 (exceeds 5 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 3 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 a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

      def run
        dividend_query = config[:dividend]
        divisor_query = config[:divisor]
        config.delete(:dividend)
        config.delete(:divisor)
    Severity: Minor
    Found in bin/check-es-query-ratio.rb - About 3 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 a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

      def run
        fieldcounts = indexfieldcount
        limits = fieldlimitsetting
    
        warnings = {}
    Severity: Minor
    Found in bin/check-es-indices-field-count.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 build_request_options has 66 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def build_request_options
        end_time = (Time.now.utc - config[:offset])
        options = {
    
          index: indices(end_time),
    Severity: Major
    Found in lib/sensu-plugins-elasticsearch/elasticsearch-query.rb - About 2 hrs to fix

      Method run has a Cognitive Complexity of 19 (exceeds 5 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 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 a Cognitive Complexity of 19 (exceeds 5 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 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 indices has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

        def indices(end_time)
          if !config[:index].nil?
            return config[:index]
          elsif !config[:date_index].nil?
            indices = []
      Severity: Minor
      Found in lib/sensu-plugins-elasticsearch/elasticsearch-query.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 kibana_info has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

        def kibana_info
          kibana_date_format = '%Y-%m-%dT%H:%M:%S.%LZ'
          unless config[:kibana_url].nil?
            index = config[:index]
            unless config[:date_index].nil?
      Severity: Minor
      Found in bin/check-es-query-average.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 kibana_info has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

        def kibana_info
          kibana_date_format = '%Y-%m-%dT%H:%M:%S.%LZ'
          unless config[:kibana_url].nil?
            index = config[:index]
            unless config[:date_index].nil?
      Severity: Minor
      Found in bin/check-es-query-count.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 kibana_info has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

        def kibana_info
          kibana_date_format = '%Y-%m-%dT%H:%M:%S.%LZ'
          unless config[:kibana_url].nil?
            index = config[:index]
            unless config[:date_index].nil?
      Severity: Minor
      Found in bin/check-es-query-ratio.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 44 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def run
          dividend_query = config[:dividend]
          divisor_query = config[:divisor]
          config.delete(:dividend)
          config.delete(:divisor)
      Severity: Minor
      Found in bin/check-es-query-ratio.rb - About 1 hr to fix

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

          def es_date_math_string(end_time)
            if config[:minutes_previous].zero? && \
               config[:hours_previous].zero? && \
               config[:days_previous].zero? && \
               config[:weeks_previous].zero? && \
        Severity: Minor
        Found in lib/sensu-plugins-elasticsearch/elasticsearch-query.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
            if !config[:master_only] || master?
              case acquire_status
              when 'green'
                ok 'Cluster is green'
        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 run has a Cognitive Complexity of 13 (exceeds 5 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

        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 build_request_options has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

          def build_request_options
            end_time = (Time.now.utc - config[:offset])
            options = {
        
              index: indices(end_time),
        Severity: Minor
        Found in lib/sensu-plugins-elasticsearch/elasticsearch-query.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 build_indices_with_sizes has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

          def build_indices_with_sizes
            indices_fs_stats = client.indices.stats store: true
            pattern_regex = Regexp.new(config[:pattern_regex])
        
            index_with_sizes = indices_fs_stats['indices'].keys.each_with_object({}) do |key, hash|
        Severity: Minor
        Found in bin/check-es-indices-sizes.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 indices has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def indices(end_time)
            if !config[:index].nil?
              return config[:index]
            elsif !config[:date_index].nil?
              indices = []
        Severity: Minor
        Found in lib/sensu-plugins-elasticsearch/elasticsearch-query.rb - About 1 hr to fix

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

            def kibana_info
              kibana_date_format = '%Y-%m-%dT%H:%M:%S.%LZ'
              unless config[:kibana_url].nil?
                index = config[:index]
                unless config[:date_index].nil?
          Severity: Minor
          Found in bin/check-es-query-count.rb - About 1 hr to fix
            Severity
            Category
            Status
            Source
            Language