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
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 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 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 install_from_tar
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def install_from_tar(filename, expected_version, installed_version)
temp_app_dir = "#{Chef::Config[:file_cache_path]}/#{new_resource.app}"
Mixlib::Archive.new(filename).extract(Chef::Config[:file_cache_path])
validate_downloaded temp_app_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 action_create
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def action_create
download_and_install
create_app_directories unless new_resource.updated_by_last_action?
manage_metaconf unless new_resource.permissions.empty?
manage_lookups unless new_resource.lookups.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 should_install?
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def should_install?(expected_version, installed_version, tar_version) # rubocop:disable Metrics/CyclomaticComplexity
fail "Downloaded tarball for #{new_resource.app} does not contain a version in app.conf!" unless tar_version.version
# If we specify an expected version (see warning in should download), the tar version must match exactly OR the expected version is the base version of the (prerelease) tar version
if expected_version.version && tar_version != expected_version && !(expected_version.type == :base && tar_version.base == expected_version.base) # rubocop:disable Style/IfUnlessModifier
- 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"