rapid7/nexpose-client

View on GitHub
lib/nexpose/report.rb

Summary

Maintainability
D
2 days
Test Coverage

File report.rb has 412 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Nexpose

  class Connection
    include XMLUtils

Severity: Minor
Found in lib/nexpose/report.rb - About 5 hrs to fix

    Method generate has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

        def generate(connection, timeout = 300, raw = false)
          xml = %(<ReportAdhocGenerateRequest session-id="#{connection.session_id}">)
          xml << to_xml
          xml << '</ReportAdhocGenerateRequest>'
          response = connection.execute(xml, '1.1', timeout: timeout, raw: raw)
    Severity: Minor
    Found in lib/nexpose/report.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 generate_report has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def generate_report(report_id, wait = false)
          xml = make_xml('ReportGenerateRequest', { 'report-id' => report_id })
          response = execute(xml)
          if response.success
            response.res.elements.each('//ReportSummary') do |summary|
    Severity: Minor
    Found in lib/nexpose/report.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 generate has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def generate(connection, timeout = 300, raw = false)
          xml = %(<ReportAdhocGenerateRequest session-id="#{connection.session_id}">)
          xml << to_xml
          xml << '</ReportAdhocGenerateRequest>'
          response = connection.execute(xml, '1.1', timeout: timeout, raw: raw)
    Severity: Minor
    Found in lib/nexpose/report.rb - About 1 hr to fix

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

          def initialize(config_id, name, template_id, status, generated_on, uri, scope)
      Severity: Major
      Found in lib/nexpose/report.rb - About 50 mins to fix

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

            def self.build(connection, site_id, site_name, type, format, generate_now = false)
        Severity: Minor
        Found in lib/nexpose/report.rb - About 45 mins to fix

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

              def to_xml
                xml = %(<ReportConfig format="#{@format}" id="#{@id}" name="#{replace_entities(@name)}" template-id="#{@template_id}")
                xml << %( owner="#{@owner}") if @owner
                xml << %( timezone="#{@time_zone}") if @time_zone
                xml << %( language="#{@language}") if @language
          Severity: Minor
          Found in lib/nexpose/report.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 initialize has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def initialize(name, template_id, format, id = -1, owner = nil, time_zone = nil)
          Severity: Minor
          Found in lib/nexpose/report.rb - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                            if part.header.to_s =~ %r(text/xml)
                              return part.content.unpack('m*')[0].to_s
                            elsif part.header.to_s =~ %r(text/html)
                              return part.content.unpack('m*')[0].to_s
                            end
            Severity: Major
            Found in lib/nexpose/report.rb - About 45 mins to fix

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

                  def initialize(id, config_id, status, generated_on, uri)
              Severity: Minor
              Found in lib/nexpose/report.rb - About 35 mins to fix

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

                    def initialize(template_id, format, site_id = nil, owner = nil, time_zone = nil)
                Severity: Minor
                Found in lib/nexpose/report.rb - About 35 mins to fix

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

                      def self.parse(xml)
                        xml.elements.each('//Generate') do |generate|
                          if generate.attributes['after-scan'] == '1'
                            return Frequency.new(true, false)
                          else
                  Severity: Minor
                  Found in lib/nexpose/report.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