theforeman/smart-proxy

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

Summary

Maintainability
A
2 hrs
Test Coverage

Method find_record has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def find_record record
      subnets.each do |s|
        s.records.each do |v|
          return v if record.is_a?(String) and (v.ip == record or v.mac == record)
          return v if record.is_a?(Proxy::DHCP::Record) and v == record
Severity: Minor
Found in lib/proxy/dhcp/server.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 find_subnet has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def find_subnet value
      subnets.each do |s|
        return s if value.is_a?(String) and s.network == value
        return s if value.is_a?(Proxy::DHCP::Record) and s.include?(value.ip)
        return s if value.is_a?(IPAddr) and s.include?(value)
Severity: Minor
Found in lib/proxy/dhcp/server.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 addRecord has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def addRecord options = {}
      ip = validate_ip options[:ip]
      mac = validate_mac options[:mac]
      name = options[:hostname] || raise(Proxy::DHCP::Error, "Must provide hostname")
      net = options.delete("network")
Severity: Minor
Found in lib/proxy/dhcp/server.rb - About 35 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