Showing 840 of 840 total issues
Perceived complexity for add_file_to_project_and_targets is too high. [9/7] Open
def self.add_file_to_project_and_targets(project, targets_name, group_path, dir_path, file_group_path, file_name, root_path, file_is_resource = false)
if root_path
file_path = root_path
else
- 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
Cyclomatic complexity for prepare_parameters_for_displaying is too high. [8/6] Open
def self.prepare_parameters_for_displaying(code_module, template_name)
params = {}
params['Targets'] = code_module.project_targets.join(',') if code_module.project_targets
params['Module path'] = code_module.project_file_path if code_module.project_file_path
- 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.
Method has too many lines. [12/10] Open
def self.obtain_user_preferences_path
home_path = Pathname.new(ENV['HOME'])
.join(GENERAMBA_HOME_DIR)
path_exists = Dir.exist?(home_path)
- 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 update_catalogs_if_needed is too high. [16.76/15] Open
def update_catalogs_if_needed(catalogs, templates)
needs_update = templates.any? {|template| template.type == TemplateDeclarationType::CATALOG_TEMPLATE}
return unless needs_update
- 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. [11/10] Open
def search_templates_in_a_catalog(catalog_path, search_term)
template_names = []
catalog_path.children.select { |child|
File.directory?(child) && child.split.last.to_s[0] != '.'
- 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 search_templates_in_a_catalog is too high. [16.06/15] Open
def search_templates_in_a_catalog(catalog_path, search_term)
template_names = []
catalog_path.children.select { |child|
File.directory?(child) && child.split.last.to_s[0] != '.'
- 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 install_templates is too high. [16.61/15] Open
def install_templates(rambafile)
# We always clear previously installed templates to avoid conflicts in different versions
clear_installed_templates
templates = rambafile[TEMPLATES_KEY]
- 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. [11/10] Open
def self.validate_spec(template_name, template_path)
spec_path = self.obtain_spec_path(template_name, template_path)
spec_source = IO.read(spec_path)
spec_template = Liquid::Template.parse(spec_source)
- 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 validate_spec is too high. [16.64/15] Open
def self.validate_spec(template_name, template_path)
spec_path = self.obtain_spec_path(template_name, template_path)
spec_source = IO.read(spec_path)
spec_template = Liquid::Template.parse(spec_source)
- 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. [11/10] Open
def remove_all_catalogs
catalogs_path = Pathname.new(ENV['HOME'])
.join(GENERAMBA_HOME_DIR)
.join(CATALOGS_DIR)
if Dir.exist?(catalogs_path) == false
- 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.
Method has too many lines. [11/10] Open
def self.check_all_required_dependencies_has_in_cartfile(dependencies, cartfile_path)
return if !dependencies || dependencies.count == 0 || !cartfile_path
cartfile_string = File.read(cartfile_path)
- 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.
Perceived complexity for prepare_parameters_for_displaying is too high. [8/7] Open
def self.prepare_parameters_for_displaying(code_module, template_name)
params = {}
params['Targets'] = code_module.project_targets.join(',') if code_module.project_targets
params['Module path'] = code_module.project_file_path if code_module.project_file_path
- 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
Assignment Branch Condition size for setup_file_and_group_paths is too high. [16.49/15] Open
def setup_file_and_group_paths(file_path, group_path, path_type)
if file_path || group_path
variable_name = "#{path_type}_file_path"
if file_path || !instance_variable_get("@#{variable_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
Cyclomatic complexity for add_file_to_project_and_targets is too high. [7/6] Open
def self.add_file_to_project_and_targets(project, targets_name, group_path, dir_path, file_group_path, file_name, root_path, file_is_resource = false)
if root_path
file_path = root_path
else
- 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.
Method has too many lines. [11/10] Open
def list
downloader = CatalogDownloader.new
catalog_template_list_helper = CatalogTemplateListHelper.new
templates = []
- 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.
Method has too many lines. [11/10] Open
def setup_username
username = Generamba::UserPreferences.obtain_username
unless username
puts('The author name is not configured!'.red)
git_username = Git.init.config['user.name']
- 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 retrieve_group_or_create_if_needed is too high. [16.55/15] Open
def self.retrieve_group_or_create_if_needed(group_path, dir_path, file_group_path, project, create_group_if_not_exists, group_is_logical = false)
group_names = path_names_from_path(group_path)
group_components_count = group_names.count
group_names += path_names_from_path(file_group_path) if file_group_path
- 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 setup_file_and_group_paths
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def setup_file_and_group_paths(file_path, group_path, path_type)
if file_path || group_path
variable_name = "#{path_type}_file_path"
if file_path || !instance_variable_get("@#{variable_name}")
- 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 initialize is too high. [15.59/15] Open
def initialize(name, options = nil)
spec_path = TemplateHelper.obtain_spec(name)
unless options
spec = YAML.load_file(spec_path)
- 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 generate_module
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
def generate_module(name, code_module, template)
# Setting up Xcode objects
project = XcodeprojHelper.obtain_project(code_module.xcodeproj_path)
# Configuring file paths