rapid7/nexpose-client

View on GitHub
lib/nexpose/scan.rb

Summary

Maintainability
D
1 day
Test Coverage

File scan.rb has 490 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Nexpose
  class Connection
    include XMLUtils

    # Perform an ad hoc scan of a single device.
Severity: Minor
Found in lib/nexpose/scan.rb - About 7 hrs to fix

    Class Connection has 27 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Connection
        include XMLUtils
    
        # Perform an ad hoc scan of a single device.
        #
    Severity: Minor
    Found in lib/nexpose/scan.rb - About 3 hrs to fix

      Method initialize has 10 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def initialize(scan_id, site_id, engine_id, status, start_time, end_time, message, tasks, nodes, vulnerabilities)
      Severity: Major
      Found in lib/nexpose/scan.rb - About 1 hr to fix

        Method initialize has 8 arguments (exceeds 4 allowed). Consider refactoring.
        Open

              def initialize(vuln_exploit, vuln_version, vuln_potential, not_vuln_exploit, not_vuln_version, error, disabled, other)
        Severity: Major
        Found in lib/nexpose/scan.rb - About 1 hr to fix

          Method initialize has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def initialize(scan_id, site_id, engine_id, status, start_time, end_time)
          Severity: Minor
          Found in lib/nexpose/scan.rb - About 45 mins to fix

            Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                  def initialize(live, dead, filtered, unresolved, other)
            Severity: Minor
            Found in lib/nexpose/scan.rb - About 35 mins to fix

              Method stop_scan has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def stop_scan(scan_id, wait_sec = 0)
                    r = execute(make_xml('ScanStopRequest', 'scan-id' => scan_id))
                    if r.success
                      so_far = 0
                      while so_far < wait_sec
              Severity: Minor
              Found in lib/nexpose/scan.rb - About 25 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 parse has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                    def self.parse(scan_id, rexml)
                      return nil unless rexml
                      map = {}
                      rexml.elements.each("//ScanSummary[contains(@scan-id,'#{scan_id}')]/vulnerabilities") do |vuln|
                        status = map[vuln.attributes['status']]
              Severity: Minor
              Found in lib/nexpose/scan.rb - About 25 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

              There are no issues that match your filters.

              Category
              Status