puppetlabs/facter-ng

View on GitHub

Showing 65 of 200 total issues

Avoid too many return statements within this method.
Open

            return !!@block.call(value)
Severity: Major
Found in lib/custom_facts/util/confine.rb - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

          return false if value[/[0-9]+\.[0-9]+\./]
    Severity: Major
    Found in lib/framework/formatters/yaml_fact_formatter.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

                  return false
      Severity: Major
      Found in lib/custom_facts/util/confine.rb - About 30 mins to fix

        Method error has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def error(msg, colorize = false)
              @@has_errors = true
        
              if msg.nil? || msg.empty?
                empty_message_error(msg)
        Severity: Minor
        Found in lib/framework/logging/logger.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

        Method validate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def self.validate(options)
              DUPLICATED_OPTIONS_RULES.each do |key, value|
                if options.include?(key) && options.include?(value)
                  write_error_and_exit("option #{value} cannot be specified more than once.")
                end
        Severity: Minor
        Found in lib/framework/core/options/options_validator.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

        Method normalize_string has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

                def normalize_string(value)
                  value = value.encode(Encoding::UTF_8)
        
                  unless value.valid_encoding?
                    raise NormalizationError, "String #{value.inspect} doesn't match the reported encoding #{value.encoding}"
        Severity: Minor
        Found in lib/custom_facts/util/normalization.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

        Method read_facts has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

                  def read_facts(fact_name)
                    files = %w[bios_date bios_vendor bios_version board_vendor board_name board_serial
                               chassis_asset_tag chassis_type sys_vendor product_name product_serial
                               product_uuid]
                    return unless File.directory?('/sys/class/dmi')
        Severity: Minor
        Found in lib/resolvers/dmi_resolver.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

        Method debug has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def debug(msg)
                return unless debugging?
        
                if msg.nil? || msg.empty?
                  invoker = caller(1..1).first.slice(/.*:\d+/)
        Severity: Minor
        Found in lib/custom_facts/core/logging.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

        Method info has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def info(msg)
              if msg.nil? || msg.empty?
                empty_message_error(msg)
              elsif @@message_callback
                @@message_callback.call(:info, msg)
        Severity: Minor
        Found in lib/framework/logging/logger.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

        Method read_selinux_config has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

                def read_selinux_config
                  file_lines = Util::FileHelper.safe_readlines('/etc/selinux/config')
        
                  file_lines.map do |line|
                    @fact_list[:config_mode] = line.split('=').last.strip if line =~ /^SELINUX=/
        Severity: Minor
        Found in lib/resolvers/selinux_resolver.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

        Method iterate_list has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

                def iterate_list(adapter_addresses)
                  net_interface = {}
                  IpAdapterAddressesLh.read_list(adapter_addresses) do |adapter_address|
                    if adapter_down?(adapter_address)
                      adapter_address = IpAdapterAddressesLh.new(adapter_address[:Next])
        Severity: Minor
        Found in lib/resolvers/windows/networking_resolver.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

        Method found_fact? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def found_fact?(fact_name, query_fact)
                fact_with_wildcard = fact_name.include?('.*') && !query_fact.include?('.')
        
                processed_equery_fact = query_fact.gsub('\\', '\\\\\\\\')
        
        
        Severity: Minor
        Found in lib/framework/parsers/query_parser.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

        Method address_to_string has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def address_to_string(addr)
              return if addr[:lpSockaddr] == FFI::Pointer::NULL
        
              size = FFI::MemoryPointer.new(NetworkingFFI::INET6_ADDRSTRLEN + 1)
              buffer = FFI::MemoryPointer.new(:wchar, NetworkingFFI::INET6_ADDRSTRLEN + 1)
        Severity: Minor
        Found in lib/resolvers/windows/ffi/network_utils.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

        Method query_cuat has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

                  def query_cuat(name)
                    odmquery = Facter::ODMQuery.new
                    odmquery.equals('name', name)
        
                    result = odmquery.execute
        Severity: Minor
        Found in lib/resolvers/aix/processors.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

        Method extract_vm_and_info has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

                def extract_vm_and_info(output_docker, output_lxc, lxc_from_environ)
                  vm = nil
                  if output_docker
                    vm = 'docker'
                    info = output_docker[1]
        Severity: Minor
        Found in lib/resolvers/docker_lxc.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

        Method warn has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def warn(msg)
              if msg.nil? || msg.empty?
                empty_message_error(msg)
              elsif @@message_callback
                @@message_callback.call(:warn, msg)
        Severity: Minor
        Found in lib/framework/logging/logger.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

        Method sysctl_by_name has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def self.sysctl_by_name(type, name)
                oldp = FFI::Pointer::NULL
                oldlenp = FFI::MemoryPointer.new(:size_t)
        
                newp = FFI::Pointer::NULL
        Severity: Minor
        Found in lib/resolvers/freebsd/ffi/ffi_helper.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

        Method read_partitions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

                def read_partitions(fact_name)
                  @fact_list[:partitions] = {}
                  return {} unless File.readable?(BLOCK_PATH)
        
                  block_devices = Dir.entries(BLOCK_PATH).reject { |dir| dir =~ /^\.+/ }
        Severity: Minor
        Found in lib/resolvers/partitions.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

        Method create_or_return_resolution has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def create_or_return_resolution(resolution_name, resolution_type)
                resolve = resolution(resolution_name)
        
                if resolve
                  if resolution_type != resolve.resolution_type
        Severity: Minor
        Found in lib/custom_facts/util/fact.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

        Method execute_command has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

                def execute_command(command, on_fail, logger = nil)
                  begin
                    out, stderr, _status_ = Open3.capture3(command.to_s)
                    log_stderr(stderr, command, logger)
                  rescue StandardError => e
        Severity: Minor
        Found in lib/custom_facts/core/execution/base.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

        Severity
        Category
        Status
        Source
        Language