Showing 52 of 64 total issues
Method do_flattened_environments
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def do_flattened_environments(cookbooks, environments)
flatenvs = environments.map(&:keys).flatten
envfiles = []
flatenvs.each do |env|
Spiceweasel::Log.debug("environment: #{env}")
Method resolve_cookbooks
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.resolve_cookbooks(berkshelf_cookbooks = {})
require "solve"
loader = Chef::CookbookLoader.new(Spiceweasel::Config[:cookbook_dir])
loader.load_cookbooks
books = loader.cookbooks_by_name
Method parse_and_validate_options
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def parse_and_validate_options
ARGV << "-h" if ARGV.empty?
begin
parse_options
# Load knife configuration if using knife config
Method cluster_process_nodes
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def cluster_process_nodes(cluster, environment, cookbooks, environments, roles, knifecommands, rootoptions)
Spiceweasel::Log.debug("cluster::cluster_process_nodes '#{environment}' '#{cluster[environment]}'")
cluster[environment].each do |node|
node_name = node.keys.first
options = node[node_name]["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
Method determine_cloud_provider
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def determine_cloud_provider(count, create_command_options, name, options, provider, run_list)
count.to_i.times do |i|
if provider.eql?("vsphere")
server = node_numerate("knife #{provider}#{Spiceweasel::Config[:knife_options]} vm clone #{options}", i + 1, count)
elsif provider.eql?("kvm")
- 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 validate_metadata_or_get_knife_commands_wrapper
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def validate_metadata_or_get_knife_commands_wrapper(name, options, version)
if File.directory?("cookbooks")
if @loader.cookbooks_by_name[name]
validate_metadata(name, version) unless Spiceweasel::Config[:novalidation]
else
- 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_and_validate_input
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def parse_and_validate_input(file) # rubocop:disable CyclomaticComplexity
begin
Spiceweasel::Log.debug("file: #{file}")
unless File.file?(file)
STDERR.puts "ERROR: #{file} is an invalid manifest file, please check your 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 process_providers
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def process_providers(names, count, name, options, run_list, create_command_options, knifecommands) # rubocop:disable CyclomaticComplexity
Method cluster_process_nodes
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def cluster_process_nodes(cluster, environment, cookbooks, environments, roles, knifecommands, rootoptions)
Method initialize
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def initialize(nodes, cookbooks, environments, roles, knifecommands, rootoptions) # rubocop:disable CyclomaticComplexity
Method initialize
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def initialize(clusters, cookbooks, environments, roles, knifecommands, rootoptions)
Method determine_cloud_provider
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def determine_cloud_provider(count, create_command_options, name, options, provider, run_list)
Avoid deeply nested control flow statements. Open
if bundler?
parallel += "bundle exec knife #{provider}#{Spiceweasel::Config[:knife_options]} server create #{options}".gsub(/\{\{n\}\}/, "{}")
else
parallel += "knife #{provider}#{Spiceweasel::Config[:knife_options]} server create #{options}".gsub(/\{\{n\}\}/, "{}")
end
Avoid deeply nested control flow statements. Open
if bundler?
parallel += "bundle exec knife #{provider}#{Spiceweasel::Config[:knife_options]} server create #{name} #{options}".gsub(/\{\{n\}\}/, "{}")
else
parallel += "knife #{provider}#{Spiceweasel::Config[:knife_options]} server create #{name} #{options}".gsub(/\{\{n\}\}/, "{}")
end
Method parse_objects
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def self.parse_objects # rubocop:disable CyclomaticComplexity
objects = {}
# BERKSHELF
berksfile = parse_berkshelf(objects)
- 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 process_parallel
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def process_parallel(count, create_command_options, name, options, provider, run_list)
Method evaluate_configuration
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def evaluate_configuration(create, delete, manifest)
case
when Spiceweasel::Config[:extractjson]
puts JSON.pretty_generate(manifest)
when Spiceweasel::Config[:extractyaml]
- 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 do_execute_rebuild
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def do_execute_rebuild(create, delete)
if Spiceweasel::Config[:execute]
Execute.new(delete)
Execute.new(create)
else
- 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 do_google_numeric_provider
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def do_google_numeric_provider(create_command_options, names, options, provided_names, run_list)
Method validate_provider
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def validate_provider(provider, names, _count, options, knifecommands)