lib/sensu/settings/loader.rb
Class Loader
has 33 methods (exceeds 20 allowed). Consider refactoring. Open
Open
class Loader
class Error < RuntimeError; end
# @!attribute [r] warnings
# @return [Array] loader warnings.
File loader.rb
has 303 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
require "sensu/settings/validator"
require "sensu/json"
require "tmpdir"
require "socket"
require "digest"
Method load_file
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
Open
def load_file(file, must_exist=true)
if File.file?(file) && File.readable?(file)
begin
warning("loading config file", :file => file)
contents = read_config_file(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
Method load_file
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def load_file(file, must_exist=true)
if File.file?(file) && File.readable?(file)
begin
warning("loading config file", :file => file)
contents = read_config_file(file)
Method deep_diff
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
def deep_diff(hash_one, hash_two)
keys = hash_one.keys.concat(hash_two.keys).uniq
keys.inject(Hash.new) do |diff, key|
unless hash_one[key] == hash_two[key]
if hash_one[key].is_a?(Hash) && hash_two[key].is_a?(Hash)
- 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"