sensu-plugins/sensu-plugins-http

View on GitHub

Showing 30 of 45 total issues

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

  def run
    if config[:url]
      uri = URI.parse(config[:url])
      config[:host] = uri.host
      config[:port] = uri.port
Severity: Minor
Found in bin/check-http.rb - About 1 hr to fix

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

      def run
        found = false
        attempts = 0
        until found || attempts >= 10
          attempts += 1
    Severity: Minor
    Found in bin/metrics-http-json-deep.rb - About 1 hr to fix

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

        def run
          merge_s3_config
      
          url = config[:url]
          threshold = config[:threshold]
      Severity: Minor
      Found in bin/check-last-modified.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 run has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def run
          if config[:url]
            uri = URI.parse(config[:url])
            config[:host] = uri.host
            config[:path] = uri.path
      Severity: Minor
      Found in bin/check-http-json.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

      Avoid deeply nested control flow statements.
      Open

                if config[:redirectto] == res['Location'] # rubocop:disable Metrics/BlockNesting
                  ok "#{res.code} found redirect to #{res['Location']}" + body
                else
                  critical "Expected redirect to #{config[:redirectto]} instead redirected to #{res['Location']}" + body
                end
      Severity: Major
      Found in bin/check-http.rb - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                ok("#{res.code}, #{size} bytes" + body) unless config[:response_code]
        Severity: Major
        Found in bin/check-http.rb - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                  if Digest::SHA256.hexdigest(res.body).eql? config[:sha256checksum]
                    ok "#{res.code}, checksum match #{config[:sha256checksum]} in #{size} bytes" + body
                  else
                    critical "#{res.code}, checksum did not match #{config[:sha256checksum]} in #{size} bytes: #{res.body[0...200]}..."
                  end
          Severity: Major
          Found in bin/check-http.rb - About 45 mins to fix

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

              def run
                if config[:url]
                  uri = URI.parse(config[:url])
                  config[:host] = uri.host
                  config[:port] = uri.port
            Severity: Minor
            Found in bin/check-http.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

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

              def run
                if config[:url]
                  uri = URI.parse(config[:url])
                  config[:host] = uri.host
                  config[:path] = uri.path
            Severity: Minor
            Found in bin/check-http-cors.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

            Method deep_value has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def deep_value(hash, scheme = '')
                hash.each do |key, value|
                  ekey = key.gsub(/\s/, '_')
                  if value.is_a?(Hash)
                    deep_value(value, "#{scheme}.#{ekey}")
            Severity: Minor
            Found in bin/metrics-http-json-deep.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