puppetlabs/facter-ng

View on GitHub

Showing 65 of 200 total issues

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 !!@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
      Severity: Major
      Found in lib/custom_facts/util/confine.rb - About 30 mins to fix

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

              def self.setup_default_ext_facts_dirs
                if LegacyFacter::Util::Root.root?
                  windows_dir = windows_data_dir
                  Facter::Options[:default_external_dir] = if windows_dir
                                                             [File.join(windows_dir, 'PuppetLabs', 'facter', 'facts.d')]
        Severity: Minor
        Found in lib/custom_facts/util/config.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 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 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 read_ipaddress has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

                  def read_ipaddress(fact_name)
                    ip = nil
                    primary_interface = read_primary_interface
                    unless primary_interface.nil?
                      output = Facter::Core::Execution.execute("ifconfig #{primary_interface}", logger: log)
        Severity: Minor
        Found in lib/resolvers/solaris/ipaddress_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 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 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 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 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 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

        Severity
        Category
        Status
        Source
        Language