app/helpers/application_helper.rb
Do not use instance variables in helpers. Open
Open
@javascript_files = ((@javascript_files || []) + [files]).flatten.uniq
- Exclude checks
Do not use instance variables in helpers. Open
Open
javascript_include_tag *@javascript_files if @javascript_files
- Exclude checks
Do not use instance variables in helpers. Open
Open
@javascript_files = ((@javascript_files || []) + [files]).flatten.uniq
- Exclude checks
Do not use instance variables in helpers. Open
Open
javascript_include_tag *@javascript_files if @javascript_files
- Exclude checks
Ambiguous splat operator. Parenthesize the method arguments if it's surely a splat operator, or add a whitespace to the right of the *
if it should be a multiplication. (https://rubystyle.guide#method-invocation-parens) Open
Open
javascript_include_tag *@javascript_files if @javascript_files
- Read upRead up
- Exclude checks
Checks for ambiguous operators in the first argument of a method invocation without parentheses.
Example:
# bad
# The `*` is interpreted as a splat operator but it could possibly be
# a `*` method invocation (i.e. `do_something.*(some_array)`).
do_something *some_array
Example:
# good
# With parentheses, there's no ambiguity.
do_something(*some_array)
Use a guard clause (return unless object.errors[method].any?
) instead of wrapping the code inside a conditional expression. (https://rubystyle.guide#no-nested-conditionals) Open
Open
if object.errors[method].any?
- Read upRead up
- Exclude checks
Use a guard clause instead of wrapping the code inside a conditional expression
A condition with an elsif
or else
branch is allowed unless
one of return
, break
, next
, raise
, or fail
is used
in the body of the conditional expression.
NOTE: Autocorrect works in most cases except with if-else statements
that contain logical operators such as foo || raise('exception')
Example:
# bad
def test
if something
work
end
end
# good
def test
return unless something
work
end
# also good
def test
work if something
end
# bad
if something
raise 'exception'
else
ok
end
# good
raise 'exception' if something
ok
# bad
if something
foo || raise('exception')
else
ok
end
# good
foo || raise('exception') if something
ok
Example: AllowConsecutiveConditionals: false (default)
# bad
def test
if foo?
work
end
if bar? # <- reports an offense
work
end
end
Example: AllowConsecutiveConditionals: true
# good
def test
if foo?
work
end
if bar?
work
end
end
# bad
def test
if foo?
work
end
do_something
if bar? # <- reports an offense
work
end
end