sensu-plugins/sensu-plugins-network-checks

View on GitHub

Showing 25 of 33 total issues

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

  def run
    hosts = config[:hosts].split(',')
    okarray = []
    hosts.each do |host|
      case config[:pattern]
Severity: Minor
Found in bin/check-banner.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 expiration_results has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

  def expiration_results
    domains = config[:domain].split(',')
    warning_days = config[:warning].to_i
    critical_days = config[:critical].to_i
    max_retries = 4
Severity: Minor
Found in bin/check-whois-domain-expiration-multi.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 23 (exceeds 5 allowed). Consider refactoring.
Open

  def run
    # Metrics borrowed from hoardd: https://github.com/coredump/hoardd

    metrics = %w[rxBytes
                 rxPackets
Severity: Minor
Found in bin/metrics-interface.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 19 (exceeds 5 allowed). Consider refactoring.
Open

  def run
    timestamp = Time.now.to_i

    Dir.glob('/sys/class/net/*').each do |iface_path|
      next if File.file?(iface_path)
Severity: Minor
Found in bin/metrics-net.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
    c = DNSBL::Client.new

    if config[:ip]
      ip_add = config[:ip]
Severity: Minor
Found in bin/check-rbl.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 acquire_banner has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

  def acquire_banner(host)
    Timeout.timeout(config[:timeout]) do
      sock = TCPSocket.new(host, config[:port])

      if config[:ssl]
Severity: Minor
Found in bin/check-banner.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
    result = []
    pt = Net::Ping::External.new(config[:host], nil, config[:timeout])

    config[:count].times do |i|
Severity: Minor
Found in bin/check-ping.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 netstat has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

  def netstat(protocols = ['tcp'])
    state_counts = Hash.new(0)
    TCP_STATES.each_pair { |_hex, name| state_counts[name] = 0 }

    protocols.select { |p| File.exist?('/proc/net/' + p) }.each do |protocol|
Severity: Minor
Found in bin/check-netstat-tcp.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 portbinds has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def portbinds
    default_protocol = config[:hard] ? 'both' : 'tcp'
    binds = []

    config[:portbinds].split(',').each do |portbind|
Severity: Minor
Found in bin/check-ports-bind.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 expiration_results has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def expiration_results
    domains = config[:domain].split(',')
    warning_days = config[:warning].to_i
    critical_days = config[:critical].to_i
    max_retries = 4
Severity: Minor
Found in bin/check-whois-domain-expiration-multi.rb - About 1 hr to fix

    Method netstat has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

      def netstat(protocol, pattern, state_counts)
        File.open('/proc/net/' + protocol).each do |line|
          line.strip!
          if m = line.match(pattern) # rubocop:disable AssignmentInCondition
            connection_state = m[5]
    Severity: Minor
    Found in bin/metrics-netstat-tcp.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 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def run
        c = DNSBL::Client.new
    
        if config[:ip]
          ip_add = config[:ip]
    Severity: Minor
    Found in bin/check-rbl.rb - About 1 hr to fix

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

        def run
          sar = `sar -n DEV #{config[:interval]} 1 | grep #{config[:average_key]} | grep -v IFACE`
          if sar.nil? || sar.empty?
            unknown 'sar is not installed or in $PATH'
          end
      Severity: Minor
      Found in bin/metrics-netif.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 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def run
          # Metrics borrowed from hoardd: https://github.com/coredump/hoardd
      
          metrics = %w[rxBytes
                       rxPackets
      Severity: Minor
      Found in bin/metrics-interface.rb - About 1 hr to fix

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

          def run
            result = []
            pt = Net::Ping::External.new(config[:host], nil, config[:timeout])
        
            config[:count].times do |i|
        Severity: Minor
        Found in bin/check-ping.rb - About 1 hr to fix

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

            def run
              timestamp = Time.now.to_i
          
              Dir.glob('/sys/class/net/*').each do |iface_path|
                next if File.file?(iface_path)
          Severity: Minor
          Found in bin/metrics-net.rb - About 1 hr to fix

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

              def expiration_results
                domains = config[:domain].split(',')
                warning_days = config[:warning].to_i
                critical_days = config[:critical].to_i
                results = {
            Severity: Minor
            Found in bin/check-jsonwhois-domain-expiration.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 10 (exceeds 5 allowed). Consider refactoring.
            Open

              def run
                stdout, stderr = Open3.capture3(
                  ENV,
                  "nmap -P0 -p #{config[:ports]} #{config[:host]}"
                )
            Severity: Minor
            Found in bin/check-ports-nmap.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 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def run
                stdout, stderr = Open3.capture3(
                  ENV,
                  "nmap -P0 -p #{config[:ports]} #{config[:host]}"
                )
            Severity: Minor
            Found in bin/check-ports-nmap.rb - About 1 hr to fix

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

                def run
                  ports = config[:ports].split(',').flat_map do |port|
                    # Port range
                    if port =~ /^[0-9]+(-[0-9]+)$/
                      first_port, last_port = port.split('-')
              Severity: Minor
              Found in bin/check-ports.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

              Severity
              Category
              Status
              Source
              Language