lib/related_items_test_unit_helper.rb
Method has too many lines. [18/10] Open
Open
def self.included(base)
base.class_eval do
context "A #{@base_class}" do
setup do
@related_item = Module.class_eval(@base_class).create! @new_model
- 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 included is too high. [16.79/15] Open
Open
def self.included(base)
base.class_eval do
context "A #{@base_class}" do
setup do
@related_item = Module.class_eval(@base_class).create! @new_model
- 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
Use the return of the conditional for variable assignment and comparison. Open
Open
unless @base_class == 'Topic'
relations = @topic_related_to.send(@base_class.tableize)
else
relations = @topic_related_to.related_topics
end
- Exclude checks
Do not use unless
with else
. Rewrite these with the positive case first. Open
Open
unless @base_class == 'Topic'
relations = @topic_related_to.send(@base_class.tableize)
else
relations = @topic_related_to.related_topics
end
- Read upRead up
- Exclude checks
This cop looks for unless expressions with else clauses.
Example:
# bad
unless foo_bar.nil?
# do something...
else
# do a different thing...
end
# good
if foo_bar.present?
# do something...
else
# do a different thing...
end
Redundant curly braces around a hash parameter. Open
Open
@topic_related_to = Basket.find(1).topics.create!({ title: 'The topic that the item is related to', topic_type_id: 1 })
- Read upRead up
- Exclude checks
This cop checks for braces around the last parameter in a method call
if the last parameter is a hash.
It supports braces
, no_braces
and context_dependent
styles.
Example: EnforcedStyle: braces
# The `braces` style enforces braces around all method
# parameters that are hashes.
# bad
some_method(x, y, a: 1, b: 2)
# good
some_method(x, y, {a: 1, b: 2})
Example: EnforcedStyle: no_braces (default)
# The `no_braces` style checks that the last parameter doesn't
# have braces around it.
# bad
some_method(x, y, {a: 1, b: 2})
# good
some_method(x, y, a: 1, b: 2)
Example: EnforcedStyle: context_dependent
# The `context_dependent` style checks that the last parameter
# doesn't have braces around it, but requires braces if the
# second to last parameter is also a hash literal.
# bad
some_method(x, y, {a: 1, b: 2})
some_method(x, y, {a: 1, b: 2}, a: 1, b: 2)
# good
some_method(x, y, a: 1, b: 2)
some_method(x, y, {a: 1, b: 2}, {a: 1, b: 2})