Showing 2,704 of 2,705 total issues
Assignment Branch Condition size for toKitten is too high. [150.6/75] Open
def toKitten(**_args)
bok = {
"cloud" => "AWS",
"credentials" => @credentials,
"cloud_id" => @cloud_id,
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Method printSchema
has a Cognitive Complexity of 135 (exceeds 75 allowed). Consider refactoring. Open
def self.printSchema(kitten_rb, class_hierarchy, schema, in_array = false, required = false, prefix: nil)
return if schema.nil?
if schema["type"] == "object"
printme = []
- 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
Assignment Branch Condition size for method_missing is too high. [146.1/75] Open
def method_missing(method_sym, *arguments)
# make sure error symbols are loaded for our exception handling later
require "aws-sdk-lambda"
require "aws-sdk-rds"
require "aws-sdk-ec2"
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Method has too many lines. [270/200] Open
def self.validateConfig(cluster, configurator)
ok = true
start = Time.now
cluster['size'] = MU::Cloud.resourceClass("AWS", "Server").validateInstanceType(cluster["instance_type"], cluster["region"])
ok = false if cluster['size'].nil?
- Read upRead up
- Exclude checks
This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Assignment Branch Condition size for generate_methods is too high. [143.8/75] Open
def generate_methods(integrations = true)
resp = MU::Cloud::AWS.apig(region: @region, credentials: @credentials).get_resources(
rest_api_id: @cloud_id,
)
root_resource = resp.items.first.id
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Assignment Branch Condition size for manageUser is too high. [142.9/75] Open
def self.manageUser(chef_user, name: nil, email: nil, orgs: [], remove_orgs: [], admin: false, ldap_user: nil, pass: nil)
orgs = [] if orgs.nil?
remove_orgs = [] if remove_orgs.nil?
# In this shining future, there are no situations where we will *not* have
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Method validateConfig
has a Cognitive Complexity of 129 (exceeds 75 allowed). Consider refactoring. Open
def self.validateConfig(pool, configurator)
ok = true
if pool["termination_policy"]
valid_policies = MU::Cloud::AWS.autoscale(region: pool['region']).describe_termination_policy_types.termination_policy_types
- 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
Assignment Branch Condition size for resolveReferences is too high. [140.3/75] Open
def resolveReferences(cfg, deploy, parent)
mask_deploy_id = false
check_deploy_id = Proc.new { |cfgblob|
(deploy and
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Method common_properties
has 354 lines of code (exceeds 150 allowed). Consider refactoring. Open
def self.common_properties
{
"name" => {"type" => "string"},
"ansible_vars" => {
"type" => "object",
Assignment Branch Condition size for validateConfig is too high. [139.4/75] Open
def self.validateConfig(queue, configurator)
ok = true
if queue['failqueue']
if (!queue['failqueue']['create'] and !queue['failqueue'].has_key?("name")) or
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Assignment Branch Condition size for create is too high. [139.5/75] Open
def create
MU.setVar("curRegion", @region) if !@region.nil?
createUpdateLaunchConfig
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Assignment Branch Condition size for menu is too high. [139.2/75] Open
def menu(tree = $CONFIGURABLES, map = $MENU_MAP, submenu_name = nil, in_use_names = [])
begin
optlist = displayCurrentOpts(tree)
begin
if submenu_name
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Method processReference
has 352 lines of code (exceeds 150 allowed). Consider refactoring. Open
def self.processReference(vpc_block, parent_type, parent, configurator, sibling_vpcs: [], dflt_region: MU.curRegion, dflt_project: nil, credentials: nil)
if !vpc_block.is_a?(Hash) and vpc_block.kind_of?(MU::Cloud::VPC)
return true
end
Method cloudFormationBase
has 351 lines of code (exceeds 150 allowed). Consider refactoring. Open
def self.cloudFormationBase(type, cloudobj = nil, name: nil, tags: [], scrub_mu_isms: false)
desc = {}
tags = [] if tags.nil?
realtags = []
havenametag = false
Assignment Branch Condition size for cloudFormationBase is too high. [138.3/75] Open
def self.cloudFormationBase(type, cloudobj = nil, name: nil, tags: [], scrub_mu_isms: false)
desc = {}
tags = [] if tags.nil?
realtags = []
havenametag = false
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Assignment Branch Condition size for cleanup is too high. [138.8/75] Open
def self.cleanup(noop: false, deploy_id: MU.deploy_id, ignoremaster: false, region: MU.curRegion, credentials: nil, flags: {})
if (deploy_id.nil? or deploy_id.empty?) and (!flags or !flags["vpc_id"])
raise MuError, "Can't touch ELBs without MU-ID or vpc_id flag"
end
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Perceived complexity for dependencies is too high. [98/35] Open
def dependencies(use_cache: false, debug: false)
@dependencies ||= {}
@loadbalancers ||= []
@firewall_rules ||= []
- Read upRead up
- Exclude checks
This cop tries to produce a complexity score that's a measure of the
complexity the reader experiences when looking at a method. For that
reason it considers when
nodes as something that doesn't add as much
complexity as an if
or a &&
. Except if it's one of those special
case
/when
constructs where there's no expression after case
. Then
the cop treats it as an if
/elsif
/elsif
... and lets all the when
nodes count. In contrast to the CyclomaticComplexity cop, this cop
considers else
nodes as adding complexity.
Example:
def my_method # 1
if cond # 1
case var # 2 (0.8 + 4 * 0.2, rounded)
when 1 then func_one
when 2 then func_two
when 3 then func_three
when 4..10 then func_other
end
else # 1
do_something until a && b # 2
end # ===
end # 7 complexity points
Block has too many lines. [204/100] Open
deploys.each { |muid|
mommacat = MU::MommaCat.new(muid)
if mommacat.original_config.nil?
MU.log "Failed to locate original config data for #{muid}", MU::WARN
- Read upRead up
- Exclude checks
This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.
Cyclomatic complexity for method_missing is too high. [92/30] Open
def method_missing(method_sym, *arguments)
retries = 0
actual_resource = nil
enable_on_fail = true
- Read upRead up
- Exclude checks
This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.
An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.
Assignment Branch Condition size for cleanup is too high. [137.8/75] Open
def self.cleanup(noop: false, deploy_id: MU.deploy_id, ignoremaster: false, credentials: nil, flags: {})
MU.log "AWS::User.cleanup: need to support flags['known']", MU::DEBUG, details: flags
# XXX this doesn't belong here; maybe under roles, maybe as its own stupid first-class resource
resp = MU::Cloud::AWS.iam(credentials: credentials).list_policies(
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric