puppetlabs/facter

View on GitHub

Showing 117 of 386 total issues

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/facter/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 call_the_resolver has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

        def call_the_resolver
          virtual = Facter::Resolvers::Windows::Virtualization.resolve(:virtual)
          provider = case virtual
                     when 'hyperv'
                       metadata = Facter::Resolvers::Az.resolve(:metadata)
Severity: Minor
Found in lib/facter/facts/windows/cloud/provider.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/facter/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 load_facts_ttls has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def load_facts_ttls
      @facts_ttls ||= {}
      return if @groups_ttls == []

      @groups_ttls.reduce(:merge).each do |group, ttls|
Severity: Minor
Found in lib/facter/framework/config/fact_groups.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/facter/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 true? has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

      def true?
        if @block && !@fact
          begin
            return !!@block.call
          rescue StandardError => e
Severity: Minor
Found in lib/facter/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 read_mounts has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

          def read_mounts(fact_name)
            @mounts = []
            @auto_home_paths = []
            begin
              Facter::Util::Resolvers::FilesystemHelper.read_mountpoints&.each do |fs|
Severity: Minor
Found in lib/facter/resolvers/solaris/mountpoints.rb - About 1 hr to fix

    Method mac_from_bonded_interface has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

              def mac_from_bonded_interface(interface_name)
                master = bond_master_of(interface_name)
                return unless master
    
                output = Facter::Util::FileHelper.safe_read("/proc/net/bonding/#{master}", nil)
    Severity: Minor
    Found in lib/facter/util/linux/socket_parser.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/facter/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 partitions has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

          def partitions
            parts = Facter::Resolvers::Partitions.resolve(:partitions)
            # We should exit early if we are running on a node with no partitions
            # (e.g. a diskless, netbooted VM)
            return nil unless parts
    Severity: Minor
    Found in lib/facter/facts/linux/partitions.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_facts has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

              def read_facts(fact_name)
                files = %w[bios_date bios_vendor bios_version board_asset_tag board_vendor board_name
                           board_serial chassis_asset_tag chassis_type sys_vendor product_name
                           product_serial product_uuid product_version]
                return unless File.directory?('/sys/class/dmi')
    Severity: Minor
    Found in lib/facter/resolvers/dmi.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_fact has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def read_fact(searched_fact, fact_group)
          data = nil
          Facter::Framework::Benchmarking::Timer.measure(searched_fact.name, 'cached') do
            data = read_group_json(fact_group)
          end
    Severity: Minor
    Found in lib/facter/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 prepended has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

          def self.prepended(receiver)
            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/facter/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 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/facter/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 build_release_facts has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

              def build_release_facts(fact_name)
                result = Facter::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/facter/resolvers/solaris/os_release.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 parse_routes has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

              def parse_routes(output, ipv4_type)
                routes = []
                output.each_line do |line|
                  parts = line.split(' ').compact
                  next if parts.include?('linkdown')
    Severity: Minor
    Found in lib/facter/util/linux/routing_table.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 parse_instance has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

            def parse_instance(gce_data)
              instance_data = gce_data['instance']
              return if instance_data.nil? || instance_data.empty?
    
              # See https://cloud.google.com/compute/docs/metadata for information about these values
    Severity: Minor
    Found in lib/facter/resolvers/gce.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 10 (exceeds 5 allowed). Consider refactoring.
    Open

              def read_mounts(fact_name)
                @mounts = []
                @auto_home_paths = []
                begin
                  Facter::Util::Resolvers::FilesystemHelper.read_mountpoints&.each do |fs|
    Severity: Minor
    Found in lib/facter/resolvers/solaris/mountpoints.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 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

    Severity
    Category
    Status
    Source
    Language