File report.rb
has 412 lines of code (exceeds 250 allowed). Consider refactoring. Open
module Nexpose
class Connection
include XMLUtils
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)
- Read upRead up
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|
- Read upRead up
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)
Method initialize
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def initialize(config_id, name, template_id, status, generated_on, uri, scope)
Method build
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def self.build(connection, site_id, site_name, type, format, generate_now = false)
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
- Read upRead up
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)
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
Method initialize
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def initialize(id, config_id, status, generated_on, uri)
Method initialize
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def initialize(template_id, format, site_id = nil, owner = nil, time_zone = nil)
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
- Read upRead up
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"