Showing 36 of 36 total issues
Method configure_authentication
has a Cognitive Complexity of 66 (exceeds 5 allowed). Consider refactoring. Open
def self.configure_authentication(node, hash) # rubocop:disable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity, Metrics/MethodLength
hash = hash.clone
auth_stanzas = { 'authentication' => hash }
fail 'authSettings is managed by chef. Don\'t set it yourself!' if hash.key?('authSettings')
- 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 configure_outputs
has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring. Open
def self.configure_outputs(node) # rubocop:disable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity, Metrics/MethodLength
output_stanzas = {}
if %i[search_head forwarder cluster_master shc_deployer].include? node['splunk']['node_type']
output_stanzas['tcpout'] = {
- 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 configure_roles
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
def self.configure_roles(hash) # rubocop:disable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity, Metrics/MethodLength
user_prefs = {}
authorize = {}
hash.each do |stanza, values|
- 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 configure_authentication
has 96 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.configure_authentication(node, hash) # rubocop:disable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity, Metrics/MethodLength
hash = hash.clone
auth_stanzas = { 'authentication' => hash }
fail 'authSettings is managed by chef. Don\'t set it yourself!' if hash.key?('authSettings')
Method load
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
def self.load(string, options = {}) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
opts = {
pick_context: nil,
handle_load_failure: false
}.merge(options)
- 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 splunk_app.rb
has 295 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'chef/provider'
require 'chef/resource'
require 'fileutils'
require 'mixlib/archive'
Method manage_lookups
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def manage_lookups
new_resource.lookups.each do |file_name, value|
if value && !value.empty?
fail "Unsupported lookup file format for #{file_name} in the app #{new_resource.app}" unless file_name =~ /\.(?:csv\.gz|csv|kmz)$/i
- 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
Consider simplifying this complex logical expression. Open
if %i[index default].include?(stanza_type) && daily_mb && ((!s2_enabled_index && !hash.key?('maxTotalDataSizeMB')) || (s2_enabled_index && !hash.key?('maxGlobalDataSizeMB')))
settings = CernerSplunk.my_cluster_data(node).fetch('settings', {})
replication_factor = settings['replication_factor'] || 1
indexer_count = settings['_cerner_splunk_indexer_count'] || 1
# If the frozen time isn't specified, splunk defaults to 6 years
Method convert_stanzas
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def self.convert_stanzas(input)
(CernerSplunk::ConfTemplate.collapse_proc input || {}).inject({}) do |file_data, (stanza, stanza_value)|
label = "Stanza #{stanza}"
stanza_value = CernerSplunk::ConfTemplate.collapse_proc stanza_value, label: label, arguments: { stanza: stanza }
fail "Unexpected value (#{stanza_value.class} '#{stanza_value}') for #{label}" unless stanza_value.nil? || stanza_value.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"
Further reading
Method configure_outputs
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.configure_outputs(node) # rubocop:disable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity, Metrics/MethodLength
output_stanzas = {}
if %i[search_head forwarder cluster_master shc_deployer].include? node['splunk']['node_type']
output_stanzas['tcpout'] = {
Method configure_roles
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.configure_roles(hash) # rubocop:disable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity, Metrics/MethodLength
user_prefs = {}
authorize = {}
hash.each do |stanza, values|
Method to_value
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def self.to_value(array, _options = {}) # rubocop:disable Metrics/CyclomaticComplexity
case array
when nil
nil
when Array
- 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 merge_hashes
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def self.merge_hashes(*hashes) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
hashes.collect(&:keys).flatten.uniq.each_with_object({}) do |app_name, result|
app_hash = {}
merger = proc { |_key, v1, v2| v1.is_a?(Hash) && v2.is_a?(Hash) ? v1.merge(v2, &merger) : v2 }
- 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 initialize
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def initialize(version)
@version = version.chomp.empty? ? nil : version.chomp unless version.nil?
@base, @prerelease = @version.split(' ', 2) unless @version.nil?
@type = @prerelease.nil? ? :base : :prerelease unless @version.nil?
end
- 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 delayable_attribute
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def delayable_attribute(attr_name, validation = {})
class_eval(<<-SHIM, __FILE__, __LINE__ + 1)
def #{attr_name}(arg=nil,&block)
_set_or_return_#{attr_name}(arg,block)
end
- 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 insert_procs
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def insert_procs(filename, contents)
return contents unless contents.is_a? Hash
contents.inject({}) do |retval, (stanza, attributes)|
retval[stanza] = attributes.inject({}) do |stanzavals, (key, value)|
- 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
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.load(string, options = {}) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
opts = {
pick_context: nil,
handle_load_failure: false
}.merge(options)
Method manage_file
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def manage_file(path, contents)
if contents.is_a?(Hash) && !contents.empty?
file = Chef::Resource::Template.new(path, run_context)
file.cookbook('cerner_splunk')
file.source('generic.conf.erb')
- 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 convert_monitors
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def self.convert_monitors(monitors, default_index = nil, base = {})
monitors.inject(base) do |stanzas, element|
type = element['type'] || element[:type] || 'monitor'
path = element['path'] || element[:path]
- 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 collapse_proc
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def self.collapse_proc(initial, depth: 10, arguments: {}, label: nil)
value = initial
message_suffix = " evaluating #{label}" unless label.nil?
while value.is_a? Proc
fail "Proc depth exceeded#{message_suffix}" if depth <= 0
- 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"