theforeman/smart-proxy

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

Summary

Maintainability
C
1 day
Test Coverage

Method loadSubnetData has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

    def loadSubnetData subnet
      super
      conf = format((@config+@leases).split("\n"))
      # scan for host statements
      conf.scan(/host\s+(\S+\s*\{[^}]+\})/) do |host|
Severity: Minor
Found in lib/proxy/dhcp/server/isc.rb - About 3 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 report has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    def report msg, response=""
      if response.nil? or (!response.empty? and !response.grep(/can't|no more|not connected|Syntax error/).empty?)
        logger.error "Omshell failed:\n" + (response.nil? ? "No response from DHCP server" : response.join(", "))
        msg.sub! /Removed/,    "remove"
        msg.sub! /Added/,      "add"
Severity: Minor
Found in lib/proxy/dhcp/server/isc.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 loadSubnetData has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def loadSubnetData subnet
      super
      conf = format((@config+@leases).split("\n"))
      # scan for host statements
      conf.scan(/host\s+(\S+\s*\{[^}]+\})/) do |host|
Severity: Minor
Found in lib/proxy/dhcp/server/isc.rb - About 1 hr to fix

    Method parse_record_options has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def parse_record_options text
          options = {}
          case text
            # standard record values
          when /^hardware\s+ethernet\s+(\S+)/
    Severity: Minor
    Found in lib/proxy/dhcp/server/isc.rb - About 1 hr to fix

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

          def read_config file
            logger.debug "Reading config file #{file}"
            config = []
            File.readlines(file).each do |line|
              if /^include\s+"(.*)"\s*;/ =~ line.strip
      Severity: Minor
      Found in lib/proxy/dhcp/server/isc.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 omcmd has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def omcmd cmd, msg=nil
            if cmd == "connect"
              @om = IO.popen("/bin/sh -c '/usr/bin/omshell 2>&1'", "r+")
              @om.puts "key #{SETTINGS.dhcp_key_name} \"#{SETTINGS.dhcp_key_secret}\"" if SETTINGS.dhcp_key_name and SETTINGS.dhcp_key_secret
              @om.puts "server #{name}"
      Severity: Minor
      Found in lib/proxy/dhcp/server/isc.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