Class has too many lines. [105/100] Open
class ArrayFormatter < BaseFormatter
attr_reader :array, :inspector, :options
def initialize(array, inspector)
@array = array
- Read upRead up
- Exclude checks
This cop checks if the length a class 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 find_method(name)
object = array.instance_variable_get('@__awesome_methods__')
meth = begin
object.method(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.
Use %
instead of %Q
. Open
%Q([\n#{data.join(",\n")}\n#{outdent}])
- Read upRead up
- Exclude checks
This cop checks if usage of %() or %Q() matches configuration.
Example: EnforcedStyle: bare_percent (default)
# bad
%Q(He said: "#{greeting}")
%q{She said: 'Hi'}
# good
%(He said: "#{greeting}")
%{She said: 'Hi'}
Example: EnforcedStyle: percent_q
# bad
%|He said: "#{greeting}"|
%/She said: 'Hi'/
# good
%Q|He said: "#{greeting}"|
%q/She said: 'Hi'/
Redundant return
detected. To return multiple values, use an array. Open
return name_and_args[0].map(&:size).max, name_and_args[1].map(&:size).max
- Read upRead up
- Exclude checks
This cop checks for redundant return
expressions.
Example:
def test
return something
end
def test
one
two
three
return something
end
It should be extended to handle methods whose body is if/else or a case expression with a default branch.
Line is too long. [81/80] Open
return name_and_args[0].map(&:size).max, name_and_args[1].map(&:size).max
- Exclude checks
Missing top-level class documentation comment. Open
class ArrayFormatter < BaseFormatter
- 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
Do not use unless
with else
. Rewrite these with the positive case first. Open
data = unless should_be_limited?
generate_printable_array
else
limited(generate_printable_array, width(array))
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
Surrounding space missing in default value assignment. Open
def generic_prefix(iteration, width, padding='')
- Read upRead up
- Exclude checks
Checks that the equals signs in parameter default assignments have or don't have surrounding space depending on configuration.
Example:
# bad
def some_method(arg1=:default, arg2=nil, arg3=[])
# do something...
end
# good
def some_method(arg1 = :default, arg2 = nil, arg3 = [])
# do something...
end