sensu-plugins/sensu-plugins-http

View on GitHub

Showing 30 of 45 total issues

Method handle_response has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
Open

  def handle_response(res, size, body)
    case res.code
    when /^2/
      if config[:redirectto]
        critical "Expected redirect to #{config[:redirectto]} but got #{res.code}" + body
Severity: Minor
Found in bin/check-http.rb - About 7 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 acquire_resource has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
Open

  def acquire_resource
    http = Net::HTTP.new(config[:host], config[:port])

    if config[:ssl]
      http.use_ssl = true
Severity: Minor
Found in bin/check-http-json.rb - About 6 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 acquire_resource has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
Open

  def acquire_resource
    http = nil

    if config[:no_proxy]
      http = Net::HTTP.new(config[:host], config[:port], nil, nil)
Severity: Minor
Found in bin/check-http.rb - About 6 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 deep_value has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
Open

  def deep_value(data, desired_key, parent = '')
    case data
    when Array
      data.each_with_index do |value, index|
        arr_key = parent + '[' + index.to_s + ']'
Severity: Minor
Found in bin/check-http-json.rb - About 6 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

File check-http.rb has 338 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'sensu-plugins-http'
require 'sensu-plugin/check/cli'
require 'net/http'
require 'net/https'
require 'digest'
Severity: Minor
Found in bin/check-http.rb - About 4 hrs to fix

    Method acquire_resource has 89 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def acquire_resource
        http = nil
    
        if config[:no_proxy]
          http = Net::HTTP.new(config[:host], config[:port], nil, nil)
    Severity: Major
    Found in bin/check-http.rb - About 3 hrs to fix

      Method acquire_resource has 69 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def acquire_resource
          http = Net::HTTP.new(config[:host], config[:port])
      
          if config[:ssl]
            http.use_ssl = true
      Severity: Major
      Found in bin/check-http-json.rb - About 2 hrs to fix

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

          def run
            puts "args config: #{config}" if config[:debug]
        
            scheme = config[:scheme].to_s
            metric_pair_input = config[:metric].to_s
        Severity: Minor
        Found in bin/metrics-http-json.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 17 (exceeds 5 allowed). Consider refactoring.
        Open

          def run
            if config[:help]
              puts usage_details
              ok
            end
        Severity: Minor
        Found in bin/metrics-libcurl.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 16 (exceeds 5 allowed). Consider refactoring.
        Open

          def run
            uri = URI.parse(config[:url])
            http = Net::HTTP.new(uri.host, uri.port)
            http.use_ssl = true
            http.verify_mode = if config[:insecure]
        Severity: Minor
        Found in bin/check-https-cert.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
            if config[:help]
              puts usage_details
              ok
            end
        Severity: Major
        Found in bin/metrics-libcurl.rb - About 2 hrs to fix

          Method handle_response has 49 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def handle_response(res, size, body)
              case res.code
              when /^2/
                if config[:redirectto]
                  critical "Expected redirect to #{config[:redirectto]} but got #{res.code}" + body
          Severity: Minor
          Found in bin/check-http.rb - About 1 hr to fix

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

              def run
                puts "args config: #{config}" if config[:debug]
            
                scheme = config[:scheme].to_s
                metric_pair_input = config[:metric].to_s
            Severity: Minor
            Found in bin/metrics-http-json.rb - About 1 hr to fix

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

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

                def follow_uri(uri, total_redirects, get_redirects, auth_count)
                  location = URI(uri)
                  http = Net::HTTP.new(location.host, location.port)
              
                  if location.port == 443
              Severity: Minor
              Found in bin/check-head-redirect.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 follow_uri has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

                def follow_uri(uri, total_redirects, get_redirects, auth_count)
                  location = URI(uri)
                  http = Net::HTTP.new(location.host, location.port)
              
                  if location.port == 443
              Severity: Minor
              Found in bin/check-last-modified.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 32 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def run
                  uri = URI.parse(config[:url])
                  http = Net::HTTP.new(uri.host, uri.port)
                  http.use_ssl = true
                  http.verify_mode = if config[:insecure]
              Severity: Minor
              Found in bin/check-https-cert.rb - About 1 hr to fix

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

                  def request_http
                    http = Net::HTTP.new(config[:host], config[:port])
                
                    if config[:ssl]
                      http.use_ssl = true
                Severity: Minor
                Found in bin/check-http-cors.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 follow_uri has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def follow_uri(uri, total_redirects, get_redirects, auth_count)
                    location = URI(uri)
                    http = Net::HTTP.new(location.host, location.port)
                
                    if location.port == 443
                Severity: Minor
                Found in bin/check-head-redirect.rb - About 1 hr to fix

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

                    def follow_uri(uri, total_redirects, get_redirects, auth_count)
                      location = URI(uri)
                      http = Net::HTTP.new(location.host, location.port)
                  
                      if location.port == 443
                  Severity: Minor
                  Found in bin/check-last-modified.rb - About 1 hr to fix
                    Severity
                    Category
                    Status
                    Source
                    Language