puppetlabs/facter-ng

View on GitHub

Showing 65 of 200 total issues

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

    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

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

              def find_first_real_value(resolutions)
                resolutions.each do |resolve|
                  begin
                    value = resolve.value
                  rescue Facter::ResolveCustomFactError
        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 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 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

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

              def self.sysctl(type, oids)
                name = FFI::MemoryPointer.new(:uint, oids.size)
                name.write_array_of_uint(oids)
                namelen = oids.size
        
        
        Severity: Minor
        Found in lib/resolvers/bsd/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 write_cache has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def write_cache
              unless File.directory?(@cache_dir)
                require 'fileutils'
                FileUtils.mkdir_p(@cache_dir)
              end
        Severity: Minor
        Found in lib/framework/core/cache_manager.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 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 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

        Severity
        Category
        Status
        Source
        Language