Assignment Branch Condition size for generate_module is too high. [59.21/15] Open
def generate_module(name, code_module, template)
# Setting up Xcode objects
project = XcodeprojHelper.obtain_project(code_module.xcodeproj_path)
# Configuring file paths
- 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. [38/10] Open
def generate_module(name, code_module, template)
# Setting up Xcode objects
project = XcodeprojHelper.obtain_project(code_module.xcodeproj_path)
# Configuring file paths
- 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. [37/10] Open
def process_files_if_needed(files, code_module, template, project, targets, group_path, dir_path, root_path, processed_groups = [])
# It's possible that current project doesn't test targets configured, so it doesn't need to generate tests.
# The same is for files property - a template can have only test or project files
if targets.count == 0 || files == nil || files.count == 0 || dir_path == nil || group_path == nil
return
- 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 process_files_if_needed is too high. [39.22/15] Open
def process_files_if_needed(files, code_module, template, project, targets, group_path, dir_path, root_path, processed_groups = [])
# It's possible that current project doesn't test targets configured, so it doesn't need to generate tests.
# The same is for files property - a template can have only test or project files
if targets.count == 0 || files == nil || files.count == 0 || dir_path == nil || group_path == nil
return
- 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 generate_module is too high. [17/6] Open
def generate_module(name, code_module, template)
# Setting up Xcode objects
project = XcodeprojHelper.obtain_project(code_module.xcodeproj_path)
# Configuring file paths
- 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.
Perceived complexity for generate_module is too high. [18/7] Open
def generate_module(name, code_module, template)
# Setting up Xcode objects
project = XcodeprojHelper.obtain_project(code_module.xcodeproj_path)
# Configuring file paths
- 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
Method process_files_if_needed
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def process_files_if_needed(files, code_module, template, project, targets, group_path, dir_path, root_path, processed_groups = [])
# It's possible that current project doesn't test targets configured, so it doesn't need to generate tests.
# The same is for files property - a template can have only test or project files
if targets.count == 0 || files == nil || files.count == 0 || dir_path == nil || group_path == nil
return
- 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
Cyclomatic complexity for process_files_if_needed is too high. [13/6] Open
def process_files_if_needed(files, code_module, template, project, targets, group_path, dir_path, root_path, processed_groups = [])
# It's possible that current project doesn't test targets configured, so it doesn't need to generate tests.
# The same is for files property - a template can have only test or project files
if targets.count == 0 || files == nil || files.count == 0 || dir_path == nil || group_path == nil
return
- 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.
Perceived complexity for process_files_if_needed is too high. [14/7] Open
def process_files_if_needed(files, code_module, template, project, targets, group_path, dir_path, root_path, processed_groups = [])
# It's possible that current project doesn't test targets configured, so it doesn't need to generate tests.
# The same is for files property - a template can have only test or project files
if targets.count == 0 || files == nil || files.count == 0 || dir_path == nil || group_path == nil
return
- 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
Method generate_module
has a Cognitive Complexity of 18 (exceeds 5 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
- 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 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
Method process_files_if_needed
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def process_files_if_needed(files, code_module, template, project, targets, group_path, dir_path, root_path, processed_groups = [])
# It's possible that current project doesn't test targets configured, so it doesn't need to generate tests.
# The same is for files property - a template can have only test or project files
if targets.count == 0 || files == nil || files.count == 0 || dir_path == nil || group_path == nil
return
Method process_files_if_needed
has 9 arguments (exceeds 4 allowed). Consider refactoring. Open
def process_files_if_needed(files, code_module, template, project, targets, group_path, dir_path, root_path, processed_groups = [])
Block has too many lines. [31/25] Open
files.each do |file|
unless file[TEMPLATE_FILE_PATH_KEY]
directory_name = file[TEMPLATE_NAME_KEY].gsub(/^\/|\/$/, '')
file_group = dir_path.join(directory_name)
- 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.
Avoid parameter lists longer than 5 parameters. [9/5] Open
def process_files_if_needed(files, code_module, template, project, targets, group_path, dir_path, root_path, processed_groups = [])
- Read upRead up
- Exclude checks
This cop checks for methods with too many parameters. The maximum number of parameters is configurable. Keyword arguments can optionally be excluded from the total count.
Align the parameters of a method call if they span more than one line. Open
project,
- Read upRead up
- Exclude checks
Here we check if the parameters on a multi-line method call or definition are aligned.
Example: EnforcedStyle: withfirstparameter (default)
# good
foo :bar,
:baz
# bad
foo :bar,
:baz
Example: EnforcedStyle: withfixedindentation
# good
foo :bar,
:baz
# bad
foo :bar,
:baz
Align the parameters of a method call if they span more than one line. Open
template,
- Read upRead up
- Exclude checks
Here we check if the parameters on a multi-line method call or definition are aligned.
Example: EnforcedStyle: withfirstparameter (default)
# good
foo :bar,
:baz
# bad
foo :bar,
:baz
Example: EnforcedStyle: withfixedindentation
# good
foo :bar,
:baz
# bad
foo :bar,
:baz
Align the parameters of a method call if they span more than one line. Open
project,
- Read upRead up
- Exclude checks
Here we check if the parameters on a multi-line method call or definition are aligned.
Example: EnforcedStyle: withfirstparameter (default)
# good
foo :bar,
:baz
# bad
foo :bar,
:baz
Example: EnforcedStyle: withfixedindentation
# good
foo :bar,
:baz
# bad
foo :bar,
:baz
Use 2 (not 1) spaces for indentation. Open
class ModuleGenerator
- Read upRead up
- Exclude checks
This cops checks for indentation that doesn't use the specified number of spaces.
See also the IndentationConsistency cop which is the companion to this one.
Example:
# bad
class A
def test
puts 'hello'
end
end
# good
class A
def test
puts 'hello'
end
end
Example: IgnoredPatterns: ['^\s*module']
# bad
module A
class B
def test
puts 'hello'
end
end
end
# good
module A
class B
def test
puts 'hello'
end
end
end
Align the parameters of a method call if they span more than one line. Open
code_module,
- Read upRead up
- Exclude checks
Here we check if the parameters on a multi-line method call or definition are aligned.
Example: EnforcedStyle: withfirstparameter (default)
# good
foo :bar,
:baz
# bad
foo :bar,
:baz
Example: EnforcedStyle: withfixedindentation
# good
foo :bar,
:baz
# bad
foo :bar,
:baz
Tab detected. Open
code_module,
- Exclude checks
Tab detected. Open
# Creating code files
- Exclude checks
Tab detected. Open
group_path,
- Exclude checks
Tab detected. Open
code_module.project_file_root)
- Exclude checks
Use 2 (not 1) spaces for indentation. Open
def generate_module(name, code_module, template)
- Read upRead up
- Exclude checks
This cops checks for indentation that doesn't use the specified number of spaces.
See also the IndentationConsistency cop which is the companion to this one.
Example:
# bad
class A
def test
puts 'hello'
end
end
# good
class A
def test
puts 'hello'
end
end
Example: IgnoredPatterns: ['^\s*module']
# bad
module A
class B
def test
puts 'hello'
end
end
end
# good
module A
class B
def test
puts 'hello'
end
end
end
Line is too long. [103/80] Open
puts "Project group path: #{code_module.project_group_path}".green if code_module.project_group_path
- Exclude checks
Tab detected. Open
template,
- Exclude checks
Tab detected. Open
end
- Exclude checks
Line is too long. [95/80] Open
FileUtils.mkdir_p File.dirname(file_path) if !code_module.create_logical_groups
- Exclude checks
Tab detected. Open
project,
- Exclude checks
Tab detected. Open
# Creating test files
- Exclude checks
Tab detected. Open
[code_module.project_group_path])
- Exclude checks
Tab detected. Open
unless file[TEMPLATE_FILE_PATH_KEY]
- Exclude checks
Tab detected. Open
file_group = nil if file_group == '.'
- Exclude checks
Line is too long. [100/80] Open
puts "Project file path: #{code_module.project_file_path}".green if code_module.project_file_path
- Exclude checks
Tab detected. Open
file_group = File.dirname(file[TEMPLATE_NAME_KEY])
- Exclude checks
Tab detected. Open
file_is_resource = file[TEMPLATE_FILE_IS_RESOURCE_KEY]
- Exclude checks
Tab detected. Open
dir_path,
- Exclude checks
Use targets.count.zero?
instead of targets.count == 0
. Open
if targets.count == 0 || files == nil || files.count == 0 || dir_path == nil || group_path == nil
- Read upRead up
- Exclude checks
This cop checks for usage of comparison operators (==
,
>
, <
) to test numbers as zero, positive, or negative.
These can be replaced by their respective predicate methods.
The cop can also be configured to do the reverse.
The cop disregards #nonzero?
as it its value is truthy or falsey,
but not true
and false
, and thus not always interchangeable with
!= 0
.
The cop ignores comparisons to global variables, since they are often
populated with objects which can be compared with integers, but are
not themselves Interger
polymorphic.
Example: EnforcedStyle: predicate (default)
# bad
foo == 0
0 > foo
bar.baz > 0
# good
foo.zero?
foo.negative?
bar.baz.positive?
Example: EnforcedStyle: comparison
# bad
foo.zero?
foo.negative?
bar.baz.positive?
# good
foo == 0
0 > foo
bar.baz > 0
Line is too long. [100/80] Open
if targets.count == 0 || files == nil || files.count == 0 || dir_path == nil || group_path == nil
- Exclude checks
Line is too long. [123/80] Open
XcodeprojHelper.add_group_to_project(project, group_path, dir_path, directory_name, code_module.create_logical_groups)
- Exclude checks
Align the parameters of a method call if they span more than one line. Open
code_module.project_file_path,
- Read upRead up
- Exclude checks
Here we check if the parameters on a multi-line method call or definition are aligned.
Example: EnforcedStyle: withfirstparameter (default)
# good
foo :bar,
:baz
# bad
foo :bar,
:baz
Example: EnforcedStyle: withfixedindentation
# good
foo :bar,
:baz
# bad
foo :bar,
:baz
Align the parameters of a method call if they span more than one line. Open
code_module.test_targets,
- Read upRead up
- Exclude checks
Here we check if the parameters on a multi-line method call or definition are aligned.
Example: EnforcedStyle: withfirstparameter (default)
# good
foo :bar,
:baz
# bad
foo :bar,
:baz
Example: EnforcedStyle: withfixedindentation
# good
foo :bar,
:baz
# bad
foo :bar,
:baz
Align the parameters of a method call if they span more than one line. Open
group_path,
- Read upRead up
- Exclude checks
Here we check if the parameters on a multi-line method call or definition are aligned.
Example: EnforcedStyle: withfirstparameter (default)
# good
foo :bar,
:baz
# bad
foo :bar,
:baz
Example: EnforcedStyle: withfixedindentation
# good
foo :bar,
:baz
# bad
foo :bar,
:baz
Tab detected. Open
code_module.project_file_path,
- Exclude checks
Tab detected. Open
code_module.test_file_path,
- Exclude checks
Align the parameters of a method call if they span more than one line. Open
code_module.project_targets,
- Read upRead up
- Exclude checks
Here we check if the parameters on a multi-line method call or definition are aligned.
Example: EnforcedStyle: withfirstparameter (default)
# good
foo :bar,
:baz
# bad
foo :bar,
:baz
Example: EnforcedStyle: withfixedindentation
# good
foo :bar,
:baz
# bad
foo :bar,
:baz
Align the parameters of a method call if they span more than one line. Open
code_module.project_file_root)
- Read upRead up
- Exclude checks
Here we check if the parameters on a multi-line method call or definition are aligned.
Example: EnforcedStyle: withfirstparameter (default)
# good
foo :bar,
:baz
# bad
foo :bar,
:baz
Example: EnforcedStyle: withfixedindentation
# good
foo :bar,
:baz
# bad
foo :bar,
:baz
Use 2 (not 4) spaces for indentation. Open
file_path = root_path
- Read upRead up
- Exclude checks
This cops checks for indentation that doesn't use the specified number of spaces.
See also the IndentationConsistency cop which is the companion to this one.
Example:
# bad
class A
def test
puts 'hello'
end
end
# good
class A
def test
puts 'hello'
end
end
Example: IgnoredPatterns: ['^\s*module']
# bad
module A
class B
def test
puts 'hello'
end
end
end
# good
module A
class B
def test
puts 'hello'
end
end
end
Tab detected. Open
project = XcodeprojHelper.obtain_project(code_module.xcodeproj_path)
- Exclude checks
Tab detected. Open
puts "Name: #{name}".green
- Exclude checks
Tab detected. Open
if code_module.test_targets && code_module.test_group_path && code_module.test_file_path
- Exclude checks
Tab detected. Open
files.each do |file|
- Exclude checks
Tab detected. Open
targets,
- Exclude checks
Align the parameters of a method call if they span more than one line. Open
code_module.project_group_path,
- Read upRead up
- Exclude checks
Here we check if the parameters on a multi-line method call or definition are aligned.
Example: EnforcedStyle: withfirstparameter (default)
# good
foo :bar,
:baz
# bad
foo :bar,
:baz
Example: EnforcedStyle: withfixedindentation
# good
foo :bar,
:baz
# bad
foo :bar,
:baz
Tab detected. Open
end
- Exclude checks
Line is too long. [96/80] Open
FileUtils.mkdir_p code_module.project_file_root if code_module.project_file_root
- Exclude checks
Line is too long. [91/80] Open
if code_module.test_targets && code_module.test_group_path && code_module.test_file_path
- Exclude checks
Tab detected. Open
# Generating the content of the code file and it's name
- Exclude checks
Inconsistent indentation detected. Open
if code_module.project_file_root && code_module.test_file_root
FileUtils.mkdir_p code_module.project_file_root if code_module.project_file_root
FileUtils.mkdir_p code_module.test_file_root if code_module.test_file_root
else
FileUtils.mkdir_p code_module.project_file_path if code_module.project_file_path
- Read upRead up
- Exclude checks
This cops checks for inconsistent indentation.
Example:
class A
def test
puts 'hello'
puts 'world'
end
end
Inconsistent indentation detected. Open
if code_module.create_logical_groups
file_path = root_path
else
file_path = dir_path
file_path = file_path.join(file_group) if file_group
- Read upRead up
- Exclude checks
This cops checks for inconsistent indentation.
Example:
class A
def test
puts 'hello'
puts 'world'
end
end
Use 2 (not 1) spaces for indentation. Open
project = XcodeprojHelper.obtain_project(code_module.xcodeproj_path)
- Read upRead up
- Exclude checks
This cops checks for indentation that doesn't use the specified number of spaces.
See also the IndentationConsistency cop which is the companion to this one.
Example:
# bad
class A
def test
puts 'hello'
end
end
# good
class A
def test
puts 'hello'
end
end
Example: IgnoredPatterns: ['^\s*module']
# bad
module A
class B
def test
puts 'hello'
end
end
end
# good
module A
class B
def test
puts 'hello'
end
end
end
Line is too long. [93/80] Open
file_name, file_content = ContentGenerator.create_file(file, module_info.scope, template)
- Exclude checks
Tab detected. Open
project,
- Exclude checks
Tab detected. Open
end
- Exclude checks
Tab detected. Open
FileUtils.mkdir_p root_path
- Exclude checks
Tab detected. Open
file_name, file_content = ContentGenerator.create_file(file, module_info.scope, template)
- Exclude checks
Tab detected. Open
XcodeprojHelper.add_file_to_project_and_targets(project,
- Exclude checks
Tab detected. Open
file_group,
- Exclude checks
Trailing whitespace detected. Open
- Exclude checks
Useless assignment to variable - file_group
. Open
file_group = dir_path.join(directory_name)
- Read upRead up
- Exclude checks
This cop checks for every useless assignment to local variable in every
scope.
The basic idea for this cop was from the warning of ruby -cw
:
assigned but unused variable - foo
Currently this cop has advanced logic that detects unreferenced reassignments and properly handles varied cases such as branch, loop, rescue, ensure, etc.
Example:
# bad
def some_method
some_var = 1
do_something
end
Example:
# good
def some_method
some_var = 1
do_something(some_var)
end
Line is too long. [100/80] Open
if code_module.project_targets && code_module.project_group_path && code_module.project_file_path
- Exclude checks
Align the parameters of a method call if they span more than one line. Open
targets,
- Read upRead up
- Exclude checks
Here we check if the parameters on a multi-line method call or definition are aligned.
Example: EnforcedStyle: withfirstparameter (default)
# good
foo :bar,
:baz
# bad
foo :bar,
:baz
Example: EnforcedStyle: withfixedindentation
# good
foo :bar,
:baz
# bad
foo :bar,
:baz
Incorrect indentation detected (column 4 instead of 16). Open
# Creating the file in the filesystem
- Read upRead up
- Exclude checks
This cops checks the indentation of comments.
Example:
# bad
# comment here
def method_name
end
# comment here
a = 'hello'
# yet another comment
if true
true
end
# good
# comment here
def method_name
end
# comment here
a = 'hello'
# yet another comment
if true
true
end
Extra empty line detected at module body beginning. Open
# Responsible for creating the whole code module using information from the CLI
- Read upRead up
- Exclude checks
This cops checks if empty lines around the bodies of modules match the configuration.
Example: EnforcedStyle: empty_lines
# good
module Foo
def bar
# ...
end
end
Example: EnforcedStyle: emptylinesexcept_namespace
# good
module Foo
module Bar
# ...
end
end
Example: EnforcedStyle: emptylinesspecial
# good
module Foo
def bar; end
end
Example: EnforcedStyle: noemptylines (default)
# good
module Foo
def bar
# ...
end
end
Use 2 (not 1) spaces for indentation. Open
if targets.count == 0 || files == nil || files.count == 0 || dir_path == nil || group_path == nil
- Read upRead up
- Exclude checks
This cops checks for indentation that doesn't use the specified number of spaces.
See also the IndentationConsistency cop which is the companion to this one.
Example:
# bad
class A
def test
puts 'hello'
end
end
# good
class A
def test
puts 'hello'
end
end
Example: IgnoredPatterns: ['^\s*module']
# bad
module A
class B
def test
puts 'hello'
end
end
end
# good
module A
class B
def test
puts 'hello'
end
end
end
Use 2 (not 1) spaces for indentation. Open
directory_name = file[TEMPLATE_NAME_KEY].gsub(/^\/|\/$/, '')
- Read upRead up
- Exclude checks
This cops checks for indentation that doesn't use the specified number of spaces.
See also the IndentationConsistency cop which is the companion to this one.
Example:
# bad
class A
def test
puts 'hello'
end
end
# good
class A
def test
puts 'hello'
end
end
Example: IgnoredPatterns: ['^\s*module']
# bad
module A
class B
def test
puts 'hello'
end
end
end
# good
module A
class B
def test
puts 'hello'
end
end
end
Tab detected. Open
return
- Exclude checks
Tab detected. Open
directory_name = file[TEMPLATE_NAME_KEY].gsub(/^\/|\/$/, '')
- Exclude checks
Tab detected. Open
root_path,
- Exclude checks
Use files.count.zero?
instead of files.count == 0
. Open
if targets.count == 0 || files == nil || files.count == 0 || dir_path == nil || group_path == nil
- Read upRead up
- Exclude checks
This cop checks for usage of comparison operators (==
,
>
, <
) to test numbers as zero, positive, or negative.
These can be replaced by their respective predicate methods.
The cop can also be configured to do the reverse.
The cop disregards #nonzero?
as it its value is truthy or falsey,
but not true
and false
, and thus not always interchangeable with
!= 0
.
The cop ignores comparisons to global variables, since they are often
populated with objects which can be compared with integers, but are
not themselves Interger
polymorphic.
Example: EnforcedStyle: predicate (default)
# bad
foo == 0
0 > foo
bar.baz > 0
# good
foo.zero?
foo.negative?
bar.baz.positive?
Example: EnforcedStyle: comparison
# bad
foo.zero?
foo.negative?
bar.baz.positive?
# good
foo == 0
0 > foo
bar.baz > 0
Align the parameters of a method call if they span more than one line. Open
code_module.test_file_root,
- Read upRead up
- Exclude checks
Here we check if the parameters on a multi-line method call or definition are aligned.
Example: EnforcedStyle: withfirstparameter (default)
# good
foo :bar,
:baz
# bad
foo :bar,
:baz
Example: EnforcedStyle: withfixedindentation
# good
foo :bar,
:baz
# bad
foo :bar,
:baz
Align the parameters of a method call if they span more than one line. Open
dir_path,
- Read upRead up
- Exclude checks
Here we check if the parameters on a multi-line method call or definition are aligned.
Example: EnforcedStyle: withfirstparameter (default)
# good
foo :bar,
:baz
# bad
foo :bar,
:baz
Example: EnforcedStyle: withfixedindentation
# good
foo :bar,
:baz
# bad
foo :bar,
:baz
Align the parameters of a method call if they span more than one line. Open
file_name,
- Read upRead up
- Exclude checks
Here we check if the parameters on a multi-line method call or definition are aligned.
Example: EnforcedStyle: withfirstparameter (default)
# good
foo :bar,
:baz
# bad
foo :bar,
:baz
Example: EnforcedStyle: withfixedindentation
# good
foo :bar,
:baz
# bad
foo :bar,
:baz
Extra empty line detected at class body beginning. Open
def generate_module(name, code_module, template)
- Read upRead up
- Exclude checks
This cops checks if empty lines around the bodies of classes match the configuration.
Example: EnforcedStyle: empty_lines
# good
class Foo
def bar
# ...
end
end
Example: EnforcedStyle: emptylinesexcept_namespace
# good
class Foo
class Bar
# ...
end
end
Example: EnforcedStyle: emptylinesspecial
# good
class Foo
def bar; end
end
Example: EnforcedStyle: noemptylines (default)
# good
class Foo
def bar
# ...
end
end
Use 2 (not 4) spaces for indentation. Open
FileUtils.mkdir_p code_module.project_file_root if code_module.project_file_root
- Read upRead up
- Exclude checks
This cops checks for indentation that doesn't use the specified number of spaces.
See also the IndentationConsistency cop which is the companion to this one.
Example:
# bad
class A
def test
puts 'hello'
end
end
# good
class A
def test
puts 'hello'
end
end
Example: IgnoredPatterns: ['^\s*module']
# bad
module A
class B
def test
puts 'hello'
end
end
end
# good
module A
class B
def test
puts 'hello'
end
end
end
Tab detected. Open
puts('Creating code files...')
- Exclude checks
Tab detected. Open
process_files_if_needed(template.code_files,
- Exclude checks
Tab detected. Open
code_module.project_group_path,
- Exclude checks
Tab detected. Open
puts "Project group path: #{code_module.project_group_path}".green if code_module.project_group_path
- Exclude checks
Tab detected. Open
# The same is for files property - a template can have only test or project files
- Exclude checks
Tab detected. Open
module_info = ModuleInfoGenerator.new(code_module)
- Exclude checks
Line is too long. [96/80] Open
FileUtils.mkdir_p code_module.project_file_path if code_module.project_file_path
- Exclude checks
Line is too long. [133/80] Open
def process_files_if_needed(files, code_module, template, project, targets, group_path, dir_path, root_path, processed_groups = [])
- Exclude checks
Line is too long. [139/80] Open
XcodeprojHelper.clear_group(project, targets, group_path, code_module.create_logical_groups) unless processed_groups.include? group_path
- Exclude checks
Align the parameters of a method call if they span more than one line. Open
template,
- Read upRead up
- Exclude checks
Here we check if the parameters on a multi-line method call or definition are aligned.
Example: EnforcedStyle: withfirstparameter (default)
# good
foo :bar,
:baz
# bad
foo :bar,
:baz
Example: EnforcedStyle: withfixedindentation
# good
foo :bar,
:baz
# bad
foo :bar,
:baz
Align the parameters of a method call if they span more than one line. Open
code_module.test_group_path,
- Read upRead up
- Exclude checks
Here we check if the parameters on a multi-line method call or definition are aligned.
Example: EnforcedStyle: withfirstparameter (default)
# good
foo :bar,
:baz
# bad
foo :bar,
:baz
Example: EnforcedStyle: withfixedindentation
# good
foo :bar,
:baz
# bad
foo :bar,
:baz
Align the parameters of a method call if they span more than one line. Open
[code_module.project_group_path])
- Read upRead up
- Exclude checks
Here we check if the parameters on a multi-line method call or definition are aligned.
Example: EnforcedStyle: withfirstparameter (default)
# good
foo :bar,
:baz
# bad
foo :bar,
:baz
Example: EnforcedStyle: withfixedindentation
# good
foo :bar,
:baz
# bad
foo :bar,
:baz
Align the parameters of a method call if they span more than one line. Open
file_group,
- Read upRead up
- Exclude checks
Here we check if the parameters on a multi-line method call or definition are aligned.
Example: EnforcedStyle: withfirstparameter (default)
# good
foo :bar,
:baz
# bad
foo :bar,
:baz
Example: EnforcedStyle: withfixedindentation
# good
foo :bar,
:baz
# bad
foo :bar,
:baz
Use 2 (not 1) spaces for indentation. Open
return
- Read upRead up
- Exclude checks
This cops checks for indentation that doesn't use the specified number of spaces.
See also the IndentationConsistency cop which is the companion to this one.
Example:
# bad
class A
def test
puts 'hello'
end
end
# good
class A
def test
puts 'hello'
end
end
Example: IgnoredPatterns: ['^\s*module']
# bad
module A
class B
def test
puts 'hello'
end
end
end
# good
module A
class B
def test
puts 'hello'
end
end
end
Use 2 (not 1) spaces for indentation. Open
unless file[TEMPLATE_FILE_PATH_KEY]
- Read upRead up
- Exclude checks
This cops checks for indentation that doesn't use the specified number of spaces.
See also the IndentationConsistency cop which is the companion to this one.
Example:
# bad
class A
def test
puts 'hello'
end
end
# good
class A
def test
puts 'hello'
end
end
Example: IgnoredPatterns: ['^\s*module']
# bad
module A
class B
def test
puts 'hello'
end
end
end
# good
module A
class B
def test
puts 'hello'
end
end
end
Use 2 (not 4) spaces for indentation. Open
file_path = dir_path
- Read upRead up
- Exclude checks
This cops checks for indentation that doesn't use the specified number of spaces.
See also the IndentationConsistency cop which is the companion to this one.
Example:
# bad
class A
def test
puts 'hello'
end
end
# good
class A
def test
puts 'hello'
end
end
Example: IgnoredPatterns: ['^\s*module']
# bad
module A
class B
def test
puts 'hello'
end
end
end
# good
module A
class B
def test
puts 'hello'
end
end
end
Tab detected. Open
# Responsible for creating the whole code module using information from the CLI
- Exclude checks
Tab detected. Open
code_module,
- Exclude checks
Tab detected. Open
puts "Project file path: #{code_module.project_file_path}".green if code_module.project_file_path
- Exclude checks
Tab detected. Open
puts "Test file path: #{code_module.test_file_path}".green if code_module.test_file_path
- Exclude checks
Tab detected. Open
end
- Exclude checks
Prefer the use of the nil?
predicate. Open
if targets.count == 0 || files == nil || files.count == 0 || dir_path == nil || group_path == nil
- Read upRead up
- Exclude checks
This cop checks for comparison of something with nil using ==.
Example:
# bad
if x == nil
end
# good
if x.nil?
end
Inconsistent indentation detected. Open
FileUtils.mkdir_p File.dirname(file_path) if !code_module.create_logical_groups
- Read upRead up
- Exclude checks
This cops checks for inconsistent indentation.
Example:
class A
def test
puts 'hello'
puts 'world'
end
end
Use 2 (not 1) spaces for indentation. Open
f.write(file_content)
- Read upRead up
- Exclude checks
This cops checks for indentation that doesn't use the specified number of spaces.
See also the IndentationConsistency cop which is the companion to this one.
Example:
# bad
class A
def test
puts 'hello'
end
end
# good
class A
def test
puts 'hello'
end
end
Example: IgnoredPatterns: ['^\s*module']
# bad
module A
class B
def test
puts 'hello'
end
end
end
# good
module A
class B
def test
puts 'hello'
end
end
end
Tab detected. Open
class ModuleGenerator
- Exclude checks
Align the parameters of a method call if they span more than one line. Open
file_is_resource)
- Read upRead up
- Exclude checks
Here we check if the parameters on a multi-line method call or definition are aligned.
Example: EnforcedStyle: withfirstparameter (default)
# good
foo :bar,
:baz
# bad
foo :bar,
:baz
Example: EnforcedStyle: withfixedindentation
# good
foo :bar,
:baz
# bad
foo :bar,
:baz
Extra blank line detected. Open
# Creating test files
- Read upRead up
- Exclude checks
This cops checks for two or more consecutive blank lines.
Example:
# bad - It has two empty lines.
some_method
# one empty line
# two empty lines
some_method
# good
some_method
# one empty line
some_method
Tab detected. Open
project.save
- Exclude checks
Tab detected. Open
# It's possible that current project doesn't test targets configured, so it doesn't need to generate tests.
- Exclude checks
Tab detected. Open
XcodeprojHelper.add_group_to_project(project, group_path, dir_path, directory_name, code_module.create_logical_groups)
- Exclude checks
Tab detected. Open
file_path = file_path.join(file_name) if file_name
- Exclude checks
Tab detected. Open
end
- Exclude checks
Line is too long. [90/80] Open
FileUtils.mkdir_p code_module.test_file_root if code_module.test_file_root
- Exclude checks
Line is too long. [91/80] Open
puts "Test file path: #{code_module.test_file_path}".green if code_module.test_file_path
- Exclude checks
Line is too long. [110/80] Open
# It's possible that current project doesn't test targets configured, so it doesn't need to generate tests.
- Exclude checks
Prefer the use of the nil?
predicate. Open
if targets.count == 0 || files == nil || files.count == 0 || dir_path == nil || group_path == nil
- Read upRead up
- Exclude checks
This cop checks for comparison of something with nil using ==.
Example:
# bad
if x == nil
end
# good
if x.nil?
end
Use %r
around regular expression. Open
directory_name = file[TEMPLATE_NAME_KEY].gsub(/^\/|\/$/, '')
- Read upRead up
- Exclude checks
This cop enforces using // or %r around regular expressions.
Example: EnforcedStyle: slashes (default)
# bad
snake_case = %r{^[\dA-Z_]+$}
# bad
regex = %r{
foo
(bar)
(baz)
}x
# good
snake_case = /^[\dA-Z_]+$/
# good
regex = /
foo
(bar)
(baz)
/x
Example: EnforcedStyle: percent_r
# bad
snake_case = /^[\dA-Z_]+$/
# bad
regex = /
foo
(bar)
(baz)
/x
# good
snake_case = %r{^[\dA-Z_]+$}
# good
regex = %r{
foo
(bar)
(baz)
}x
Example: EnforcedStyle: mixed
# bad
snake_case = %r{^[\dA-Z_]+$}
# bad
regex = /
foo
(bar)
(baz)
/x
# good
snake_case = /^[\dA-Z_]+$/
# good
regex = %r{
foo
(bar)
(baz)
}x
Example: AllowInnerSlashes: false (default)
# If `false`, the cop will always recommend using `%r` if one or more
# slashes are found in the regexp string.
# bad
x =~ /home\//
# good
x =~ %r{home/}
Example: AllowInnerSlashes: true
# good
x =~ /home\//
Use 2 (not 4) spaces for indentation. Open
FileUtils.mkdir_p code_module.project_file_path if code_module.project_file_path
- Read upRead up
- Exclude checks
This cops checks for indentation that doesn't use the specified number of spaces.
See also the IndentationConsistency cop which is the companion to this one.
Example:
# bad
class A
def test
puts 'hello'
end
end
# good
class A
def test
puts 'hello'
end
end
Example: IgnoredPatterns: ['^\s*module']
# bad
module A
class B
def test
puts 'hello'
end
end
end
# good
module A
class B
def test
puts 'hello'
end
end
end
Tab detected. Open
code_module.test_file_root,
- Exclude checks
Tab detected. Open
if targets.count == 0 || files == nil || files.count == 0 || dir_path == nil || group_path == nil
- Exclude checks
Tab detected. Open
f.write(file_content)
- Exclude checks
Align the parameters of a method call if they span more than one line. Open
root_path,
- Read upRead up
- Exclude checks
Here we check if the parameters on a multi-line method call or definition are aligned.
Example: EnforcedStyle: withfirstparameter (default)
# good
foo :bar,
:baz
# bad
foo :bar,
:baz
Example: EnforcedStyle: withfixedindentation
# good
foo :bar,
:baz
# bad
foo :bar,
:baz
Align the parameters of a method call if they span more than one line. Open
code_module,
- Read upRead up
- Exclude checks
Here we check if the parameters on a multi-line method call or definition are aligned.
Example: EnforcedStyle: withfirstparameter (default)
# good
foo :bar,
:baz
# bad
foo :bar,
:baz
Example: EnforcedStyle: withfixedindentation
# good
foo :bar,
:baz
# bad
foo :bar,
:baz
Align the parameters of a method call if they span more than one line. Open
code_module.test_file_path,
- Read upRead up
- Exclude checks
Here we check if the parameters on a multi-line method call or definition are aligned.
Example: EnforcedStyle: withfirstparameter (default)
# good
foo :bar,
:baz
# bad
foo :bar,
:baz
Example: EnforcedStyle: withfixedindentation
# good
foo :bar,
:baz
# bad
foo :bar,
:baz
Tab detected. Open
def generate_module(name, code_module, template)
- Exclude checks
Tab detected. Open
code_module.test_targets,
- Exclude checks
Tab detected. Open
process_files_if_needed(template.test_files,
- Exclude checks
Tab detected. Open
end
- Exclude checks
Tab detected. Open
code_module.test_group_path,
- Exclude checks
Tab detected. Open
# Creating the file in the Xcode project
- Exclude checks
Use 2 (not 1) spaces for indentation. Open
puts('Creating code files...')
- Read upRead up
- Exclude checks
This cops checks for indentation that doesn't use the specified number of spaces.
See also the IndentationConsistency cop which is the companion to this one.
Example:
# bad
class A
def test
puts 'hello'
end
end
# good
class A
def test
puts 'hello'
end
end
Example: IgnoredPatterns: ['^\s*module']
# bad
module A
class B
def test
puts 'hello'
end
end
end
# good
module A
class B
def test
puts 'hello'
end
end
end
Tab detected. Open
puts 'Module successfully created!'
- Exclude checks
Tab detected. Open
file_name,
- Exclude checks
Tab detected. Open
# Setting up Xcode objects
- Exclude checks
Tab detected. Open
file_group = dir_path.join(directory_name)
- Exclude checks
Prefer the use of the nil?
predicate. Open
if targets.count == 0 || files == nil || files.count == 0 || dir_path == nil || group_path == nil
- Read upRead up
- Exclude checks
This cop checks for comparison of something with nil using ==.
Example:
# bad
if x == nil
end
# good
if x.nil?
end
Tab detected. Open
if code_module.project_targets && code_module.project_group_path && code_module.project_file_path
- Exclude checks
Tab detected. Open
end
- Exclude checks
Tab detected. Open
code_module.project_targets,
- Exclude checks
Tab detected. Open
puts('Creating test files...')
- Exclude checks
Tab detected. Open
end
- Exclude checks
Tab detected. Open
puts "Test group path: #{code_module.test_group_path}".green if code_module.test_group_path
- Exclude checks
Tab detected. Open
def process_files_if_needed(files, code_module, template, project, targets, group_path, dir_path, root_path, processed_groups = [])
- Exclude checks
Tab detected. Open
next
- Exclude checks
Line is too long. [94/80] Open
puts "Test group path: #{code_module.test_group_path}".green if code_module.test_group_path
- Exclude checks
Favor unless
over if
for negative conditions. Open
FileUtils.mkdir_p File.dirname(file_path) if !code_module.create_logical_groups
- Read upRead up
- Exclude checks
Checks for uses of if with a negated condition. Only ifs without else are considered. There are three different styles:
- both
- prefix
- postfix
Example: EnforcedStyle: both (default)
# enforces `unless` for `prefix` and `postfix` conditionals
# bad
if !foo
bar
end
# good
unless foo
bar
end
# bad
bar if !foo
# good
bar unless foo
Example: EnforcedStyle: prefix
# enforces `unless` for just `prefix` conditionals
# bad
if !foo
bar
end
# good
unless foo
bar
end
# good
bar if !foo
Example: EnforcedStyle: postfix
# enforces `unless` for just `postfix` conditionals
# bad
bar if !foo
# good
bar unless foo
# good
if !foo
bar
end
Use 2 (not 1) spaces for indentation. Open
puts('Creating test files...')
- Read upRead up
- Exclude checks
This cops checks for indentation that doesn't use the specified number of spaces.
See also the IndentationConsistency cop which is the companion to this one.
Example:
# bad
class A
def test
puts 'hello'
end
end
# good
class A
def test
puts 'hello'
end
end
Example: IgnoredPatterns: ['^\s*module']
# bad
module A
class B
def test
puts 'hello'
end
end
end
# good
module A
class B
def test
puts 'hello'
end
end
end
Tab detected. Open
template,
- Exclude checks
Tab detected. Open
# Saving the current changes in the Xcode project
- Exclude checks
Tab detected. Open
XcodeprojHelper.clear_group(project, targets, group_path, code_module.create_logical_groups) unless processed_groups.include? group_path
- Exclude checks
Tab detected. Open
# Creating the file in the filesystem
- Exclude checks
Tab detected. Open
File.open(file_path, 'w+') do |f|
- Exclude checks
Tab detected. Open
end
- Exclude checks
Tab detected. Open
file_is_resource)
- Exclude checks
Line is too long. [90/80] Open
FileUtils.mkdir_p code_module.test_file_path if code_module.test_file_path
- Exclude checks
Line is too long. [84/80] Open
# The same is for files property - a template can have only test or project files
- Exclude checks