theforeman/smart-proxy

View on GitHub

Showing 56 of 56 total issues

Method puppet_environments has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
Open

      def puppet_environments
        Initializer.load
        conf = Puppet.settings.instance_variable_get(:@values)

        env = { }
Severity: Minor
Found in lib/proxy/puppet/environment.rb - About 5 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 run! has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
Open

    def self.run!(options={})
      set options
      handler      = detect_rack_handler
      handler_name = handler.name.gsub(/.*::/, '')

Severity: Minor
Found in lib/sinatra-patch.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 ast_to_value has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

      def ast_to_value value
        unless value.class.name.start_with? "Puppet::Parser::AST::"
          # Native Ruby types
          case value
            # Supported with exact JSON equivalent
Severity: Minor
Found in lib/proxy/puppet/puppet_class.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 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

Class Subnet has 28 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Subnet
    attr_reader :network, :netmask, :server, :timestamp
    attr_accessor :options

    include Proxy::DHCP
Severity: Minor
Found in lib/proxy/dhcp/subnet.rb - About 3 hrs to fix

    Method bmc_setup has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

      def bmc_setup
    
        raise "Smart Proxy is not configured to support BMC control" unless SETTINGS.bmc
    
        # Either use the default provider or allow user to specify provider in request
    Severity: Minor
    Found in lib/bmc_api.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 21 (exceeds 5 allowed). Consider refactoring.
    Open

        def report msg, response, error_only
          if response.grep(/completed successfully/).empty?
            if response.grep /class name being used is unknown/
              logger.info "Vendor class not found"
            else
    Severity: Minor
    Found in lib/proxy/dhcp/server/native_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

    Class IPMI has 24 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class IPMI < Base
          include Proxy::Log
    
          def self.installed?(provider)
            # check with the lib to see if at least one provider is installed
    Severity: Minor
    Found in lib/proxy/bmc/ipmi.rb - About 2 hrs to fix

      Class Base has 24 methods (exceeds 20 allowed). Consider refactoring.
      Open

          class Base
      
            # This is the base class for bmc control.  Treat this class as an interface
            def initialize(args)
              @host = connect(args)
      Severity: Minor
      Found in lib/proxy/bmc/base.rb - About 2 hrs to fix

        Method dhcp_setup has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

          def dhcp_setup
            raise "Smart Proxy is not configured to support DHCP" unless SETTINGS.dhcp
            case SETTINGS.dhcp_vendor.downcase
            when "isc"
              require 'proxy/dhcp/server/isc'
        Severity: Minor
        Found in lib/dhcp_api.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 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 create has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

            def create
              nsupdate "connect"
        
              @resolver = Resolv::DNS.new(:nameserver => @server)
              case @type
        Severity: Minor
        Found in lib/proxy/dns/nsupdate.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 puppet_environments has 60 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def puppet_environments
                Initializer.load
                conf = Puppet.settings.instance_variable_get(:@values)
        
                env = { }
        Severity: Major
        Found in lib/proxy/puppet/environment.rb - About 2 hrs to fix

          Method scan_manifest has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

                def scan_manifest manifest, filename = '', parser = nil
                  klasses = []
                  # Get a Puppet Parser to parse the manifest source
                  unless parser
                    Initializer.load
          Severity: Minor
          Found in lib/proxy/puppet/puppet_class.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 ast_to_value has 52 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def ast_to_value value
                  unless value.class.name.start_with? "Puppet::Parser::AST::"
                    # Native Ruby types
                    case value
                      # Supported with exact JSON equivalent
          Severity: Major
          Found in lib/proxy/puppet/puppet_class.rb - About 2 hrs to fix

            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 tcp_pingable? has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

                def tcp_pingable? ip
                  # This code is from net-ping, and stripped down for use here
                  # We don't need all the ldap dependencies net-ping brings in
            
                  @service_check = true
            Severity: Minor
            Found in lib/proxy/dhcp/subnet.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 a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

                def loadSubnetData subnet
                  super
                  cmd = "scope #{subnet.network} show reservedip"
                  msg = "Enumerated hosts on #{subnet.network}"
            
            
            Severity: Minor
            Found in lib/proxy/dhcp/server/native_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 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 log_halt has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                def log_halt code=nil, exception=nil
                  message = exception.is_a?(String) ? exception : exception.to_s
                  begin
                    if block_given?
                      return yield
            Severity: Minor
            Found in lib/helpers.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

            Severity
            Category
            Status
            Source
            Language