rapid7/nexpose-client

View on GitHub
lib/nexpose/common.rb

Summary

Maintainability
D
2 days
Test Coverage

Method from_hash has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
Open

    def self.from_hash(hash)
      start = nil
      start = Nexpose::ISO8601.to_time(hash[:start_date]) if hash[:start_date]
      repeat_scan_hash = hash[:repeat_scan]
      if repeat_scan_hash.nil?
Severity: Minor
Found in lib/nexpose/common.rb - About 4 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 to_h has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

    def to_h
      schedule_hash = {
        enabled: @enabled,
        scan_template_id: @scan_template_id,
        maximum_scan_duration: @max_duration
Severity: Minor
Found in lib/nexpose/common.rb - About 4 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 common.rb has 298 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Nexpose
  # Constants useful across the Nexpose module.
  module Scope
    GLOBAL = 'global'
    SILO   = 'silo'
Severity: Minor
Found in lib/nexpose/common.rb - About 3 hrs to fix

    Method as_xml has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        def as_xml
          xml = REXML::Element.new('Schedule')
          xml.attributes['enabled']       = @enabled ? 1 : 0
          xml.attributes['type']          = @type
          xml.attributes['interval']      = @interval
    Severity: Minor
    Found in lib/nexpose/common.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 parse has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def self.parse(xml)
          schedule = Schedule.new(xml.attributes['type'],
                                  xml.attributes['interval'].to_i,
                                  xml.attributes['start'],
                                  xml.attributes['enabled'] != '0')
    Severity: Minor
    Found in lib/nexpose/common.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 from_hash has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def self.from_hash(hash)
          start = nil
          start = Nexpose::ISO8601.to_time(hash[:start_date]) if hash[:start_date]
          repeat_scan_hash = hash[:repeat_scan]
          if repeat_scan_hash.nil?
    Severity: Minor
    Found in lib/nexpose/common.rb - About 1 hr to fix

      Method to_h has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def to_h
            schedule_hash = {
              enabled: @enabled,
              scan_template_id: @scan_template_id,
              maximum_scan_duration: @max_duration
      Severity: Minor
      Found in lib/nexpose/common.rb - About 1 hr to fix

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

            def to_xml
              xml = '<Email'
              xml << %( toAllAuthorized='#{@to_all_authorized ? 1 : 0}')
              xml << %( sendToOwnerAs='#{@send_to_owner_as}') if @send_to_owner_as
              xml << %( sendToAclAs='#{@send_to_acl_as}') if @send_to_acl_as
        Severity: Minor
        Found in lib/nexpose/common.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 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def initialize(type, interval, start, enabled = true, scan_template_id = nil)
        Severity: Minor
        Found in lib/nexpose/common.rb - About 35 mins to fix

          There are no issues that match your filters.

          Category
          Status