puppetlabs/facter

View on GitHub

Showing 117 of 386 total issues

Method augment_facts has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def augment_facts(ttls, groups)
        fact_groups = Facter::FactGroups.new

        @options[:blocked_facts] = fact_groups.blocked_facts unless fact_groups.blocked_facts.nil?
        @options[:block_list] = fact_groups.block_list
Severity: Minor
Found in lib/facter/framework/core/options/config_file_options.rb - About 35 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 expand_command has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

        def expand_command(command)
          exe = nil
          args = nil

          if (match = command.match(DOUBLE_QUOTED_COMMAND))
Severity: Minor
Found in lib/facter/custom_facts/core/execution/windows.rb - About 35 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 has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

        def execute(command, options = {})
          on_fail, expand, logger, timeout = extract_options(options)

          expanded_command = if !expand && builtin_command?(command) || logger
                               command
Severity: Minor
Found in lib/facter/custom_facts/core/execution/base.rb - About 35 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 puppet_facts has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def puppet_facts
      require 'puppet'

      # don't allow puppet logger to be injected in Facter
      Options[:allow_external_loggers] = false
Severity: Minor
Found in lib/facter.rb - About 35 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 7 (exceeds 5 allowed). Consider refactoring.
Open

        def self.address_to_string(sockaddr, mask = nil)
          if sockaddr[:sa_family] == FFI::AF_INET
            in_addr_ip = FFI::SockaddrIn.new(sockaddr.to_ptr)

            if mask && sockaddr[:sa_family] == mask[:sa_family]
Severity: Minor
Found in lib/facter/resolvers/aix/ffi/ffi_helper.rb - About 35 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 conflicting_configs has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def self.conflicting_configs(options)
      no_ruby = !options[:ruby]
      no_custom_facts = !options[:custom_facts]
      puppet = options[:puppet]
      custom_dir = options[:custom_dir].nil? ? false : options[:custom_dir].any?
Severity: Minor
Found in lib/facter/framework/core/options/options_validator.rb - About 35 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 make_request has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

          def make_request(url, headers, timeouts, request_type, proxy)
            require 'net/http'

            uri = URI.parse(url)
            http = http_obj(uri, timeouts, proxy)
Severity: Minor
Found in lib/facter/util/resolvers/http.rb - About 35 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 check_other_facts has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def check_other_facts
        isa = Facter::Resolvers::Uname.resolve(:processor)
        klass = isa == 'sparc' ? 'DmiSparc' : 'Dmi'

        product_name = Facter::Resolvers::Solaris.const_get(klass).resolve(:product_name)
Severity: Minor
Found in lib/facter/facts/solaris/virtual.rb - About 35 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 load_directory_entries has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def load_directory_entries(_collection)
        cm = Facter::CacheManager.new
        facts = []
        entries.each do |file|
          basename = File.basename(file)
Severity: Minor
Found in lib/facter/custom_facts/util/directory_loader.rb - About 35 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_release_file has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

        def read_release_file(fact_name, options)
          release_file = options[:release_file]
          return unless release_file

          output = Facter::Util::FileHelper.safe_read(release_file, nil)
Severity: Minor
Found in lib/facter/resolvers/specific_release_file.rb - About 35 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 7 (exceeds 5 allowed). Consider refactoring.
Open

    def debug(msg)
      return unless debugging_active?

      if @@message_callback && Options[:allow_external_loggers]
        @@message_callback.call(:debug, msg)
Severity: Minor
Found in lib/facter/framework/logging/logger.rb - About 35 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 parse_exception has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def parse_exception(exception, error_message)
      if exception.is_a?(Exception)
        error_message << exception.message if error_message.empty?

        if Options[:trace] && !exception.backtrace.nil?
Severity: Minor
Found in lib/facter.rb - About 35 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 confine has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def confine(confines = nil, &block)
        case confines
        when Hash
          confines.each do |fact, values|
            @confines.push LegacyFacter::Util::Confine.new(fact, *values)
Severity: Minor
Found in lib/facter/custom_facts/core/suitable.rb - About 35 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 popen_rune has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

        def self.popen_rune(cmd, opts, child_io, parent_io) # :nodoc:
          pid = spawn(*cmd, opts)
          child_io.each(&:close)
          result = [*parent_io, pid]
          if defined? yield
Severity: Minor
Found in lib/facter/custom_facts/core/execution/popen3.rb - About 35 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 augment_custom has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def augment_custom(file_global_conf)
        return unless file_global_conf

        if Options.cli? && !file_global_conf['no-custom-facts'].nil?
          @options[:no_custom_facts] = file_global_conf['no-custom-facts']
Severity: Minor
Found in lib/facter/framework/core/options/config_file_options.rb - About 35 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 retrieve_version has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

        def retrieve_version(output)
          if output[/(Rawhide)$/]
            'Rawhide'
          elsif output['release']
            output.strip =~ /release (\d[\d.]*)/ ? Regexp.last_match(1) : nil
Severity: Minor
Found in lib/facter/resolvers/release_from_first_line.rb - About 35 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 augment_external has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def augment_external(global_conf)
        return unless global_conf

        if Options.cli? && !global_conf['no-external-facts'].nil?
          @options[:no_external_facts] = global_conf['no-external-facts']
Severity: Minor
Found in lib/facter/framework/core/options/config_file_options.rb - About 35 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 release_hash_from_string has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

        def release_hash_from_string(output, include_patch: false)
          return unless output

          versions = output.split('.')
          {}.tap do |release|
Severity: Minor
Found in lib/facter/util/facts/facts_utils.rb - About 35 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 sort_by_weight has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def sort_by_weight(resolutions)
        # sort resolutions:
        # - descending by weight
        # - multiple facts have the same weight but different types, the :external fact take precedence
        # - multiple facts with the same weight and type, the order is preserved.
Severity: Minor
Found in lib/facter/custom_facts/util/fact.rb - About 35 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 mac_from has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

          def mac_from(ifaddr)
            if Socket.const_defined? :PF_LINK
              ifaddr.addr&.getnameinfo&.first # sometimes it returns localhost or ip
            elsif Socket.const_defined? :PF_PACKET
              return if ifaddr.addr.nil?
Severity: Minor
Found in lib/facter/util/linux/socket_parser.rb - About 35 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