Showing 117 of 386 total issues
File file_loader.rb
has 921 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'open3'
require 'json'
require 'yaml'
require 'hocon'
require 'hocon/config_value_factory'
File config.rb
has 401 lines of code (exceeds 250 allowed). Consider refactoring. Open
module Facter
module Config
unless defined?(OS_HIERARCHY)
OS_HIERARCHY = [
{
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?
- Read upRead up
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'
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)
- Read upRead up
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?
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)
- Read upRead up
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 Log
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
class Log
@@logger = nil
@@message_callback = nil
@@has_errors = false
@@debug_messages = []
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
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)
- Read upRead up
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)
- Read upRead up
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 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
- Read upRead up
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
- Read upRead up
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_commit
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def parse_commit(commit)
prs = client.commit_pulls('puppetlabs/facter', commit.sha, { accept: 'application/vnd.github.groot-preview+json' })
prs.each do |pr|
next if pr[:state] != 'closed' && pr[:merged_at].nil?
- Read upRead up
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 find_in_interfaces
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def find_in_interfaces(interfaces)
return if interfaces.nil?
interfaces.each do |iface_name, interface|
interface[:bindings]&.each do |binding|
- Read upRead up
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 37 lines of code (exceeds 25 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
Method call_the_resolver
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def call_the_resolver
provider = case Facter::Util::Facts::Posix::VirtualDetector.platform
when 'hyperv'
metadata = Facter::Resolvers::Az.resolve(:metadata)
'azure' unless metadata.nil? || metadata.empty?
- Read upRead up
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|
- Read upRead up
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|
- Read upRead up
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
- Read upRead up
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"