puppetlabs/facter

View on GitHub

Showing 117 of 386 total issues

Method write_cache has a Cognitive Complexity of 9 (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/facter/framework/core/cache_manager.rb - About 55 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 construct_reject_lists has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def construct_reject_lists(blocked_facts, facts)
      reject_list_core = []
      reject_list_legacy = []

      blocked_facts.each do |blocked|
Severity: Minor
Found in lib/facter/framework/core/fact_loaders/fact_loader.rb - About 55 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 get_fact_group has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def get_fact_group(fact_name)
      fact = get_fact(fact_name)
      return fact[:group] if fact

      # @groups.detect { |k, v| break k if Array(v).find { |f| fact_name =~ /^#{f}.*/ } }
Severity: Minor
Found in lib/facter/framework/config/fact_groups.rb - About 55 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 resolve_fact has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def resolve_fact(searched_fact)
      fact_name = if searched_fact.file
                    File.basename(searched_fact.file)
                  else
                    searched_fact.name
Severity: Minor
Found in lib/facter/framework/core/cache_manager.rb - About 55 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 which has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

        def which(bin)
          if absolute_path?(bin)
            return bin if File.executable?(bin) && FileTest.file?(bin)
          else
            search_paths.each do |dir|
Severity: Minor
Found in lib/facter/custom_facts/core/execution/posix.rb - About 55 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_searched_facts has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

      def load_searched_facts(collection, searched_facts, weight)
        searched_facts.each do |fact|
          parser = LegacyFacter::Util::Parser.parser_for(fact.file)
          next if parser.nil?

Severity: Minor
Found in lib/facter/custom_facts/util/directory_loader.rb - About 55 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 8 (exceeds 5 allowed). Consider refactoring.
Open

        def expand_command(command)
          exe = nil
          args = nil

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

          def retrieve_info(fact_name)
            ssh_dir = determine_ssh_dir
            return unless ssh_dir && File.directory?(ssh_dir)

            ssh_list = []
Severity: Minor
Found in lib/facter/resolvers/windows/ssh.rb - About 45 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 detect_domains has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

        def detect_domains
          domains = []
          xen_command = find_command
          return unless xen_command

Severity: Minor
Found in lib/facter/resolvers/xen.rb - About 45 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 setcode has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def setcode(string = nil, &block)
        if string
          @code = proc do
            output = Facter::Core::Execution.execute(string, on_fail: nil)
            if output.nil? || output.empty?
Severity: Minor
Found in lib/facter/custom_facts/util/resolution.rb - About 45 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 populate_with_mtu_and_mac! has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

          def populate_with_mtu_and_mac!(interfaces)
            output = Facter::Core::Execution.execute('netstat -in', logger: log)
            output.each_line do |line|
              next if /Name\s/.match?(line)

Severity: Minor
Found in lib/facter/resolvers/aix/networking.rb - About 45 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 8 (exceeds 5 allowed). Consider refactoring.
Open

        def read_partitions(fact_name)
          return unless File.readable?(BLOCK_PATH)

          block_devices = Dir.entries(BLOCK_PATH).reject { |dir| dir =~ /^\.+/ }
          @fact_list[:partitions] = {} unless block_devices.empty?
Severity: Minor
Found in lib/facter/resolvers/partitions.rb - About 45 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_version_6 has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

          def check_version_6(version, consumerrel)
            hash = {}
            hash['6.3'] = consumerrel ? '8.1' : '2012 R2'
            hash['6.2'] = consumerrel ? '8' : '2012'
            hash['6.1'] = consumerrel ? '7' : '2008 R2'
Severity: Minor
Found in lib/facter/util/facts/windows_release_finder.rb - About 45 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_cudv has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

          def query_cudv(fact_name)
            odmquery = Facter::Util::Aix::ODMQuery.new
            odmquery.equals('PdDvLn', 'logical_volume/lvsubclass/lvtype')

            result = odmquery.execute
Severity: Minor
Found in lib/facter/resolvers/aix/partitions.rb - About 45 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 8 (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/facter/resolvers/windows/networking.rb - About 45 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 get_adapter_addresses has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

          def get_adapter_addresses(size_ptr, adapter_addresses, flags)
            error = nil
            3.times do
              error = NetworkingFFI::GetAdaptersAddresses(NetworkingFFI::AF_UNSPEC, flags,
                                                          FFI::Pointer::NULL, adapter_addresses, size_ptr)
Severity: Minor
Found in lib/facter/resolvers/windows/networking.rb - About 45 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 facts_already_cached? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def facts_already_cached?(cache_file_name, data)
      if File.readable?(cache_file_name)
        file = Facter::Util::FileHelper.safe_read(cache_file_name)
        begin
          cached_data = JSON.parse(file) unless file.nil?
Severity: Minor
Found in lib/facter/framework/core/cache_manager.rb - About 45 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 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

          def make_request(url, headers, timeouts, request_type, proxy)
Severity: Minor
Found in lib/facter/util/resolvers/http.rb - About 35 mins to fix

    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 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

    Severity
    Category
    Status
    Source
    Language