theforeman/smart-proxy

View on GitHub
lib/proxy/dhcp/server/ms.rb

Summary

Maintainability
B
4 hrs
Test Coverage

Method validate_response has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    def validate_response cmd, operand, response
      unless response[-3..-2].join=~/Command completed successfully/
        logger.error "Invoke failed:\n" + response.join("\n")
        scopeIpAddress, ip = cmd.match(/ScopeIpAddress=([^&]+)&ReservedIP=([^&]+)/)[1..2]

Severity: Minor
Found in lib/proxy/dhcp/server/ms.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 loadSubnetData has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def loadSubnetData subnet
      raise "invalid Subnet" unless subnet.is_a? Proxy::DHCP::Subnet
      cmd = "ListReservation" + "&ScopeIpAddress=#{subnet.network}"
      operand = "enumerate #{subnet.network} on #{@name}"

Severity: Minor
Found in lib/proxy/dhcp/server/ms.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 invoke has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def invoke cmd
      userAgent = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; .NET CLR 1.1.4322; .NET CLR 1.0.3705; .NET CLR 2.0.50727; InfoPath.1; MS-RTC LM 8)'
      header  = "https://#{@gateway}/NetShManager/NetShManager.aspx?ServerName=#{@name}&"
      cmd     = "CommandName=/" + cmd
      command = "curl -q -k --silent --user '#{@username}:#{@password}' --user-agent '#{userAgent}' '#{header}#{cmd}'; "
Severity: Minor
Found in lib/proxy/dhcp/server/ms.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