puppetlabs/facter

View on GitHub

Showing 390 of 390 total issues

File file_loader.rb has 927 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'open3'
require 'json'
require 'yaml'
require 'hocon'
require 'hocon/config_value_factory'
Severity: Major
Found in lib/facter/framework/core/file_loader.rb - About 2 days to fix

    File config.rb has 403 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module Facter
      module Config
        unless defined?(OS_HIERARCHY)
          OS_HIERARCHY = [
            {
    Severity: Minor
    Found in lib/facter/config.rb - About 5 hrs to fix

      Method read_interfaces has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
      Open

              def self.read_interfaces
                ksize = Libc.getkerninfo(KINFO_RT_IFLIST, nil, nil, 0)
      
                log.debug('getkerninfo call was unsuccessful') if ksize.zero?
      
      
      Severity: Minor
      Found in lib/facter/resolvers/aix/ffi/ffi_helper.rb - About 4 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

      File facter.rb has 307 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      require 'pathname'
      require_relative 'util/api_debugger' if ENV['API_DEBUG']
      
      require_relative 'facter/version'
      require_relative 'facter/framework/core/file_loader'
      Severity: Minor
      Found in lib/facter.rb - About 3 hrs to fix

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

                def which(bin)
                  # `echo` is allowed for facter 3.x compatibility, otherwise
                  # all commands much be found on the PATH or absolute.
                  return bin if /^echo$/i.match?(bin)
        
        
        Severity: Minor
        Found in lib/facter/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 read_interfaces has 58 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                def self.read_interfaces
                  ksize = Libc.getkerninfo(KINFO_RT_IFLIST, nil, nil, 0)
        
                  log.debug('getkerninfo call was unsuccessful') if ksize.zero?
        
        
        Severity: Major
        Found in lib/facter/resolvers/aix/ffi/ffi_helper.rb - About 2 hrs to fix

          Method read_facts has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

                    def read_facts
                      FILE_PATHS.each do |key, file|
                        @fact_list[:disks].each do |disk, value|
                          file_path = File.join(DIR, disk, file)
          
          
          Severity: Minor
          Found in lib/facter/resolvers/disks.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

          Class Collection has 21 methods (exceeds 20 allowed). Consider refactoring.
          Open

              class Collection
                def initialize(internal_loader, external_loader)
                  @facts = {}
                  @internal_loader = internal_loader
                  @external_loader = external_loader
          Severity: Minor
          Found in lib/facter/custom_facts/util/collection.rb - About 2 hrs to fix

            Class Log has 21 methods (exceeds 20 allowed). Consider refactoring.
            Open

              class Log
                @@logger = nil
                @@message_callback = nil
                @@has_errors = false
                @@debug_messages = Set.new
            Severity: Minor
            Found in lib/facter/framework/logging/logger.rb - About 2 hrs to fix

              Similar blocks of code found in 6 locations. Consider refactoring.
              Open

                module Openwrt
                  module Os
                    class Release
                      FACT_NAME = 'os.release'
                      ALIASES = %w[operatingsystemmajrelease operatingsystemrelease].freeze
              Severity: Major
              Found in lib/facter/facts/openwrt/os/release.rb and 5 other locations - About 2 hrs to fix
              lib/facter/facts/azurelinux/os/release.rb on lines 4..30
              lib/facter/facts/linuxmint/os/release.rb on lines 4..30
              lib/facter/facts/mageia/os/release.rb on lines 4..31
              lib/facter/facts/mariner/os/release.rb on lines 4..30
              lib/facter/facts/slackware/os/release.rb on lines 4..30

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 79.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 6 locations. Consider refactoring.
              Open

                module Mariner
                  module Os
                    class Release
                      FACT_NAME = 'os.release'
                      ALIASES = %w[operatingsystemmajrelease operatingsystemrelease].freeze
              Severity: Major
              Found in lib/facter/facts/mariner/os/release.rb and 5 other locations - About 2 hrs to fix
              lib/facter/facts/azurelinux/os/release.rb on lines 4..30
              lib/facter/facts/linuxmint/os/release.rb on lines 4..30
              lib/facter/facts/mageia/os/release.rb on lines 4..31
              lib/facter/facts/openwrt/os/release.rb on lines 4..30
              lib/facter/facts/slackware/os/release.rb on lines 4..30

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 79.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 6 locations. Consider refactoring.
              Open

                module Linuxmint
                  module Os
                    class Release
                      FACT_NAME = 'os.release'
                      ALIASES = %w[operatingsystemmajrelease operatingsystemrelease].freeze
              Severity: Major
              Found in lib/facter/facts/linuxmint/os/release.rb and 5 other locations - About 2 hrs to fix
              lib/facter/facts/azurelinux/os/release.rb on lines 4..30
              lib/facter/facts/mageia/os/release.rb on lines 4..31
              lib/facter/facts/mariner/os/release.rb on lines 4..30
              lib/facter/facts/openwrt/os/release.rb on lines 4..30
              lib/facter/facts/slackware/os/release.rb on lines 4..30

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 79.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 6 locations. Consider refactoring.
              Open

                module Azurelinux
                  module Os
                    class Release
                      FACT_NAME = 'os.release'
                      ALIASES = %w[operatingsystemmajrelease operatingsystemrelease].freeze
              Severity: Major
              Found in lib/facter/facts/azurelinux/os/release.rb and 5 other locations - About 2 hrs to fix
              lib/facter/facts/linuxmint/os/release.rb on lines 4..30
              lib/facter/facts/mageia/os/release.rb on lines 4..31
              lib/facter/facts/mariner/os/release.rb on lines 4..30
              lib/facter/facts/openwrt/os/release.rb on lines 4..30
              lib/facter/facts/slackware/os/release.rb on lines 4..30

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 79.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 6 locations. Consider refactoring.
              Open

                module Mageia
                  module Os
                    class Release
                      FACT_NAME = 'os.release'
                      ALIASES = %w[operatingsystemmajrelease operatingsystemrelease].freeze
              Severity: Major
              Found in lib/facter/facts/mageia/os/release.rb and 5 other locations - About 2 hrs to fix
              lib/facter/facts/azurelinux/os/release.rb on lines 4..30
              lib/facter/facts/linuxmint/os/release.rb on lines 4..30
              lib/facter/facts/mariner/os/release.rb on lines 4..30
              lib/facter/facts/openwrt/os/release.rb on lines 4..30
              lib/facter/facts/slackware/os/release.rb on lines 4..30

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 79.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 6 locations. Consider refactoring.
              Open

                module Slackware
                  module Os
                    class Release
                      FACT_NAME = 'os.release'
                      ALIASES = %w[operatingsystemmajrelease operatingsystemrelease].freeze
              Severity: Major
              Found in lib/facter/facts/slackware/os/release.rb and 5 other locations - About 2 hrs to fix
              lib/facter/facts/azurelinux/os/release.rb on lines 4..30
              lib/facter/facts/linuxmint/os/release.rb on lines 4..30
              lib/facter/facts/mageia/os/release.rb on lines 4..31
              lib/facter/facts/mariner/os/release.rb on lines 4..30
              lib/facter/facts/openwrt/os/release.rb on lines 4..30

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 79.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Method load_for_os has a Cognitive Complexity of 15 (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|
                      fact_name = class_name::FACT_NAME
              Severity: Minor
              Found in lib/facter/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 add_flags has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

                        def add_flags
                          flags = Facter::Util::Linux::IfInet6.read_flags
                          flags.each_pair do |iface, ips|
                            next unless @fact_list[:interfaces].key?(iface)
              
              
              Severity: Minor
              Found in lib/facter/resolvers/linux/networking.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_dhclient_leases has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

                        def search_dhclient_leases(interface_name)
                          @log.debug("Attempt to get DHCP for interface #{interface_name}, from dhclient leases")
              
                          DIRS.each do |dir|
                            next unless File.readable?(dir)
              Severity: Minor
              Found in lib/facter/util/linux/dhcp.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_command has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

                      def execute_command(command, on_fail = nil, logger = nil, timeout = nil)
                        timeout ||= DEFAULT_EXECUTION_TIMEOUT
                        begin
                          # Set LC_ALL and LANG to force i18n to C for the duration of this exec;
                          # this ensures that any code that parses the
              Severity: Minor
              Found in lib/facter/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

              Similar blocks of code found in 7 locations. Consider refactoring.
              Open

                module Ovs
                  module Os
                    class Release
                      FACT_NAME = 'os.release'
                      ALIASES = %w[operatingsystemmajrelease operatingsystemrelease].freeze
              Severity: Major
              Found in lib/facter/facts/ovs/os/release.rb and 6 other locations - About 1 hr to fix
              lib/facter/facts/alpine/os/release.rb on lines 4..24
              lib/facter/facts/devuan/os/release.rb on lines 4..24
              lib/facter/facts/gentoo/os/release.rb on lines 4..24
              lib/facter/facts/meego/os/release.rb on lines 4..24
              lib/facter/facts/oel/os/release.rb on lines 4..24
              lib/facter/facts/ol/os/release.rb on lines 4..24

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 70.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Severity
              Category
              Status
              Source
              Language