Method has too many lines. [85/10] Open
def setup
properties = {}
setup_username_command = Generamba::CLI::SetupUsernameCommand.new
setup_username_command.setup_username
- 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 setup is too high. [68.37/15] Open
def setup
properties = {}
setup_username_command = Generamba::CLI::SetupUsernameCommand.new
setup_username_command.setup_username
- 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
has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring. Open
def setup
properties = {}
setup_username_command = Generamba::CLI::SetupUsernameCommand.new
setup_username_command.setup_username
- 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
Perceived complexity for setup is too high. [24/7] Open
def setup
properties = {}
setup_username_command = Generamba::CLI::SetupUsernameCommand.new
setup_username_command.setup_username
- 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 setup is too high. [22/6] Open
def setup
properties = {}
setup_username_command = Generamba::CLI::SetupUsernameCommand.new
setup_username_command.setup_username
- 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 setup
has 85 lines of code (exceeds 25 allowed). Consider refactoring. Open
def setup
properties = {}
setup_username_command = Generamba::CLI::SetupUsernameCommand.new
setup_username_command.setup_username
Trailing whitespace detected. Open
- Exclude checks
Useless assignment to variable - create_logical_groups
. Open
create_logical_groups = nil
- 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. [139/80] Open
test_target = ask_index("Select the appropriate target for adding your TESTS (type the index):\n" + targets_prompt,project.targets)
- Exclude checks
Indent the first parameter one step more than the start of the previous line. Open
values: properties,
title: 'Summary for generamba setup'
- Read upRead up
- Exclude checks
This cop checks the indentation of the first parameter in a method call. Parameters after the first one are checked by Style/AlignParameters, not by this cop.
Example:
# bad
some_method(
first_param,
second_param)
# good
some_method(
first_param,
second_param)
Use 2 spaces for indentation in an array, relative to the start of the line where the left square bracket is. Open
'{name: rviper_controller}',
- Read upRead up
- Exclude checks
This cop checks the indentation of the first element in an array literal where the opening bracket and the first element are on separate lines. The other elements' indentations are handled by the AlignArray cop.
By default, array literals that are arguments in a method call with parentheses, and where the opening square bracket of the array is on the same line as the opening parenthesis of the method call, shall have their first element indented one step (two spaces) more than the position inside the opening parenthesis.
Other array literals shall have their first element indented one step more than the start of the line where the opening square bracket is.
This default style is called 'specialinsideparentheses'. Alternative styles are 'consistent' and 'align_brackets'. Here are examples:
Example: EnforcedStyle: specialinsideparentheses (default)
# The `special_inside_parentheses` style enforces that the first
# element in an array literal where the opening bracket and first
# element are on seprate lines is indented one step (two spaces) more
# than the position inside the opening parenthesis.
#bad
array = [
:value
]
and_in_a_method_call([
:no_difference
])
#good
array = [
:value
]
but_in_a_method_call([
:its_like_this
])
Example: EnforcedStyle: consistent
# The `consistent` style enforces that the first element in an array
# literal where the opening bracket and the first element are on
# seprate lines is indented the same as an array literal which is not
# defined inside a method call.
#bad
# consistent
array = [
:value
]
but_in_a_method_call([
:its_like_this
])
#good
array = [
:value
]
and_in_a_method_call([
:no_difference
])
Example: EnforcedStyle: align_brackets
# The `align_brackets` style enforces that the opening and closing
# brackets are indented to the same position.
#bad
# align_brackets
and_now_for_something = [
:completely_different
]
#good
# align_brackets
and_now_for_something = [
:completely_different
]
Trailing whitespace detected. Open
- Exclude checks
Line is too long. [114/80] Open
is_right_project_name = yes?("The name of your project is #{project_name}. Do you want to use it? (yes/no)")
- Exclude checks
Final newline missing. Open
end
- Exclude checks
Extra empty line detected at method body end. Open
end
- Read upRead up
- Exclude checks
This cops checks if empty lines exist around the bodies of methods.
Example:
# good
def foo
# ...
end
# bad
def bar
# ...
end
Line is too long. [92/80] Open
properties[CREATE_LOGICAL_GROUPS_KEY] = create_logical_groups if create_logical_groups
- Exclude checks
Space missing after comma. Open
project_target = ask_index("Select the appropriate target for adding your MODULES (type the index):\n" + targets_prompt,project.targets)
- Read upRead up
- Exclude checks
Checks for comma (,) not followed by some kind of space.
Example:
# bad
[1,2]
{ foo:bar,}
# good
[1, 2]
{ foo:bar, }
Operator =
should be surrounded by a single space. Open
properties[PROJECT_PREFIX_KEY] = ask('The project prefix (if any):')
- Read upRead up
- Exclude checks
Checks that operators have space around them, except for ** which should not have surrounding space.
Example:
# bad
total = 3*4
"apple"+"juice"
my_number = 38/4
a ** b
# good
total = 3 * 4
"apple" + "juice"
my_number = 38 / 4
a**b
Space missing after comma. Open
test_target = ask_index("Select the appropriate target for adding your TESTS (type the index):\n" + targets_prompt,project.targets)
- Read upRead up
- Exclude checks
Checks for comma (,) not followed by some kind of space.
Example:
# bad
[1,2]
{ foo:bar,}
# good
[1, 2]
{ foo:bar, }
Use nested module/class definitions instead of compact style. Open
module Generamba::CLI
- Read upRead up
- Exclude checks
This cop checks the style of children definitions at classes and modules. Basically there are two different styles:
Example: EnforcedStyle: nested (default)
# good
# have each child on its own line
class Foo
class Bar
end
end
Example: EnforcedStyle: compact
# good
# combine definitions as much as possible
class Foo::Bar
end
The compact style is only forced for classes/modules with one child.
Line is too long. [153/80] Open
properties[PROJECT_NAME_KEY] = is_right_project_name ? project_name : ask_non_empty_string('The project name:', 'Project name should not be empty')
- Exclude checks
Unnecessary spacing detected. Open
properties[PROJECT_PREFIX_KEY] = ask('The project prefix (if any):')
- Read upRead up
- Exclude checks
This cop checks for extra/unnecessary whitespace.
Example:
# good if AllowForAlignment is true
name = "RuboCop"
# Some comment and an empty line
website += "/bbatsov/rubocop" unless cond
puts "rubocop" if debug
# bad for any configuration
set_app("RuboCop")
website = "https://github.com/bbatsov/rubocop"
Line is too long. [105/80] Open
project.targets.each_with_index { |element, i| targets_prompt += ("#{i}. #{element.name}" + "\n") }
- Exclude checks
Line is too long. [101/80] Open
project_file_path = ask('The default path for creating new modules (in the filesystem):')
- Exclude checks
Line is too long. [100/80] Open
project_group_path = ask('The default path for creating new modules (in Xcode groups):')
- Exclude checks
Trailing whitespace detected. Open
- Exclude checks
Line is too long. [214/80] Open
puts('Rambafile successfully created!\n Go on and find some templates in our catalog using `generamba template list` command.\n Add any of them to the Rambafile and run `generamba template install`.'.green)
- Exclude checks
Line is too long. [91/80] Open
test_group_path = ask('The default path for creating tests (in Xcode groups):')
- Exclude checks
Line is too long. [82/80] Open
project_group_path = ask('The default path for creating new modules:')
- Exclude checks
Line is too long. [115/80] Open
create_logical_groups = yes?('Do you want to create Groups in Xcode without folders in filesystem? (yes/no)')
- Exclude checks
Line is too long. [142/80] Open
project_target = ask_index("Select the appropriate target for adding your MODULES (type the index):\n" + targets_prompt,project.targets)
- Exclude checks
Line is too long. [108/80] Open
should_add_templates = yes?('Do you want to add some well known templates to the Rambafile? (yes/no)')
- Exclude checks
Line is too long. [133/80] Open
should_use_same_paths = yes?('Do you want to use the same paths for your files both in Xcode and the filesystem? (yes/no)')
- Exclude checks
Line is too long. [82/80] Open
properties[CARTFILE_PATH_KEY] = ask_file_with_path('Cartfile', 'Cartfile')
- Exclude checks
Line is too long. [92/80] Open
test_file_path = ask('The default path for creating tests (in the filesystem):')
- Exclude checks
Line is too long. [108/80] Open
should_add_all_modules_by_one_path = yes?('Do you want to add all your modules by one path? (yes/no)')
- Exclude checks
Line is too long. [91/80] Open
puts('Rambafile successfully created! Now run `generamba template install`.'.green)
- Exclude checks
Missing top-level class documentation comment. Open
class Application < Thor
- Read upRead up
- Exclude checks
This cop checks for missing top-level documentation of classes and modules. Classes with no body are exempt from the check and so are namespace modules - modules that have nothing in their bodies except classes, other modules, or constant definitions.
The documentation requirement is annulled if the class or module has a "#:nodoc:" comment next to it. Likewise, "#:nodoc: all" does the same for all its children.
Example:
# bad
class Person
# ...
end
# good
# Description/Explanation of Person class
class Person
# ...
end
Line is too long. [83/80] Open
properties[PROJECT_GROUP_PATH_KEY] = project_group_path if project_group_path
- Exclude checks
Line is too long. [90/80] Open
properties[COMPANY_KEY] = ask('The company name which will be used in the headers:')
- Exclude checks