puppetlabs/facter-ng

View on GitHub

Showing 65 of 200 total issues

Method which has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

        def which(bin)
          if absolute_path?(bin)
            return bin if File.executable?(bin)
          else
            search_paths.each do |dir|
Severity: Minor
Found in lib/custom_facts/core/execution/windows.rb - About 2 hrs 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_from_other_directories has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

        def retrieve_from_other_directories(interface_name)
          DIRS.each do |dir|
            next unless File.readable?(dir)

            lease_files = Dir.entries(dir).select { |file| file =~ /dhclient.*\.lease/ }
Severity: Minor
Found in lib/resolvers/networking_linux_resolver.rb - About 1 hr 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 search has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def search(json_data, searched_element, path)
      # we hit a dead end, the os was not found on this branch
      # and we cannot go deeper
      return unless json_data

Severity: Minor
Found in lib/framework/detector/os_hierarchy.rb - About 1 hr 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_proc_status has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

        def read_proc_status
          proc_status_content = Facter::Util::FileHelper.safe_readlines('/proc/self/status', nil)
          return unless proc_status_content

          proc_status_content.each do |line|
Severity: Minor
Found in lib/resolvers/open_vz.rb - About 1 hr 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_mounts has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

          def read_mounts # rubocop:disable Metrics/AbcSize
            mounts = {}
            FilesystemHelper.read_mountpoints.each do |fs|
              device = fs.name
              filesystem = fs.mount_type
Severity: Minor
Found in lib/resolvers/macosx/mountpoints_resolver.rb - About 1 hr 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 deep_merge has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

      def deep_merge(left, right, path = [])
        ret = nil

        if left.is_a?(Hash) && right.is_a?(Hash)
          ret = left.merge(right) do |key, left_val, right_val|
Severity: Minor
Found in lib/custom_facts/util/values.rb - About 1 hr 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_vserver has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

        def retrieve_vserver
          proc_status_content = Facter::Util::FileHelper.safe_readlines('/proc/self/status', nil)
          return unless proc_status_content

          proc_status_content.each do |line|
Severity: Minor
Found in lib/resolvers/virt_what.rb - About 1 hr 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_env has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

      def load_env(fact = nil)
        # Load from the environment, if possible
        @environment_vars.each do |name, value|
          # Skip anything that doesn't match our regex.
          next unless name =~ /^facter_?(\w+)$/i
Severity: Minor
Found in lib/custom_facts/util/loader.rb - About 1 hr 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 build_release_facts has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

        def build_release_facts(fact_name)
          result = Util::FileHelper.safe_read('/etc/release', nil)
          return @fact_list[fact_name] = nil if result.nil?

          @os_version_regex_patterns.each do |os_version_regex|
Severity: Minor
Found in lib/resolvers/solaris/solaris_os_release_resolver.rb - About 1 hr 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 prepended has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def self.prepended(receiver) # rubocop:disable Metrics/AbcSize
    exclude, print_caller = parse_options(ENV['API_DEBUG'])

    receiver_methods = receiver.instance_methods - Object.methods
    receiver_methods.each do |meth|
Severity: Minor
Found in lib/util/api_debugger.rb - About 1 hr 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_cli has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

      def augment_cli(file_cli_conf)
        return unless file_cli_conf

        @options[:debug] = file_cli_conf['debug'] unless file_cli_conf['debug'].nil?
        @options[:trace] = file_cli_conf['trace'] unless file_cli_conf['trace'].nil?
Severity: Minor
Found in lib/framework/core/options/config_file_options.rb - About 1 hr 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 10 (exceeds 5 allowed). Consider refactoring.
Open

        def execute(command, options = {})
          on_fail = options.fetch(:on_fail, :raise)
          expand = options.fetch(:expand, true)
          logger = options[:logger]

Severity: Minor
Found in lib/custom_facts/core/execution/base.rb - About 1 hr 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 true? has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

      def true?
        if @block && !@fact
          begin
            return !!@block.call
          rescue StandardError => e
Severity: Minor
Found in lib/custom_facts/util/confine.rb - About 1 hr 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 10 (exceeds 5 allowed). Consider refactoring.
Open

    def resolve_fact(searched_fact)
      group_name =  if searched_fact.file
                      searched_fact.name
                    else
                      @fact_groups.get_fact_group(searched_fact.name)
Severity: Minor
Found in lib/framework/core/cache_manager.rb - About 1 hr 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_for_os has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def load_for_os(operating_system)
      # select only classes
      classes = ClassDiscoverer.instance.discover_classes(operating_system)

      classes.each do |class_name|
Severity: Minor
Found in lib/framework/core/fact_loaders/internal_fact_loader.rb - About 1 hr 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_for_metadata has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

        def query_for_metadata(url, container)
          metadata = get_data_from(url)
          metadata.each_line do |line|
            next if line.empty?

Severity: Minor
Found in lib/resolvers/ec2.rb - About 1 hr 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 9 (exceeds 5 allowed). Consider refactoring.
Open

      def augment_external(global_conf)
        return unless global_conf

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

      def augment_custom(file_global_conf)
        return unless file_global_conf

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

    def bury(*args)
      raise ArgumentError, '2 or more arguments required' if args.count < 2

      if args.count == 2
        self[args[0]] = args[1]
Severity: Minor
Found in lib/models/fact_collection.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

Severity
Category
Status
Source
Language