Showing 95 of 95 total issues
unterminated string meets end of file
(Using Ruby 2.5 parser; configure using TargetRubyVersion
parameter, under AllCops
) Open
<%= section -%>
- Exclude checks
Ambiguous block operator. Parenthesize the method arguments if it's surely a block operator, or add a whitespace to the right of the &
if it should be a binary AND. Open
SectionBuilder.new(container.current_revision, section_class).build &block
- Read upRead up
- Exclude checks
This cop 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)
unexpected token tLT
(Using Ruby 2.5 parser; configure using TargetRubyVersion
parameter, under AllCops
) Open
<%- content_sections("page").each do |section| -%>
- Exclude checks
Favor modifier if
usage when having a single-line body. Another good alternative is the usage of control flow &&
/||
. Open
if @project.errors.present?
- Read upRead up
- Exclude checks
Checks for if and unless statements that would fit on one line
if written as a modifier if/unless. The maximum line length is
configured in the Metrics/LineLength
cop.
Example:
# bad
if condition
do_stuff(bar)
end
unless qux.empty?
Foo.do_something
end
# good
do_stuff(bar) if condition
Foo.do_something unless qux.empty?
Method Ninetails::PropertyType#serialized_values=
is defined at both app/components/ninetails/property_type.rb:3 and app/components/ninetails/property_type.rb:19. Open
def serialized_values=(values)
- Read upRead up
- Exclude checks
This cop checks for duplicated instance (or singleton) method definitions.
Example:
# bad
def duplicated
1
end
def duplicated
2
end
Example:
# bad
def duplicated
1
end
alias duplicated other_duplicated
Example:
# good
def duplicated
1
end
def other_duplicated
2
end
Use Hash#key?
instead of Hash#has_key?
. Open
if values.is_a?(Hash) && !values.with_indifferent_access.has_key?(:reference)
- Read upRead up
- Exclude checks
This cop (by default) checks for uses of methods Hash#haskey? and
Hash#hasvalue? where it enforces Hash#key? and Hash#value?
It is configurable to enforce the inverse, using verbose
method
names also.
Example: EnforcedStyle: short (default)
# bad Hash#haskey? Hash#hasvalue?
# good Hash#key? Hash#value?
Example: EnforcedStyle: verbose
# bad Hash#key? Hash#value?
# good Hash#haskey? Hash#hasvalue?
Pass &:delete_all
as an argument to each
instead of a block. Open
].each do |model|
model.delete_all
end
- Read upRead up
- Exclude checks
Use symbols as procs when possible.
Example:
# bad
something.map { |s| s.upcase }
# good
something.map(&:upcase)
Favor modifier if
usage when having a single-line body. Another good alternative is the usage of control flow &&
/||
. Open
if folder.errors.present?
- Read upRead up
- Exclude checks
Checks for if and unless statements that would fit on one line
if written as a modifier if/unless. The maximum line length is
configured in the Metrics/LineLength
cop.
Example:
# bad
if condition
do_stuff(bar)
end
unless qux.empty?
Foo.do_something
end
# good
do_stuff(bar) if condition
Foo.do_something unless qux.empty?
unexpected token tLT
(Using Ruby 2.5 parser; configure using TargetRubyVersion
parameter, under AllCops
) Open
<%= section -%>
- Exclude checks
Unused method argument - block
. If it's necessary, use _
or _block
as an argument name to indicate that it won't be used. Open
def method_missing(method, *args, &block)
- Read upRead up
- Exclude checks
This cop checks for unused method arguments.
Example:
# bad
def some_method(used, unused, _unused_but_allowed)
puts used
end
Example:
# good
def some_method(used, _unused, _unused_but_allowed)
puts used
end
Use a guard clause instead of wrapping the code inside a conditional expression. Open
if container.is_a?(Page) && url.present?
- Read upRead up
- Exclude checks
Use a guard clause instead of wrapping the code inside a conditional expression
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
Favor modifier unless
usage when having a single-line body. Another good alternative is the usage of control flow &&
/||
. Open
unless @section.valid?
- Read upRead up
- Exclude checks
Checks for if and unless statements that would fit on one line
if written as a modifier if/unless. The maximum line length is
configured in the Metrics/LineLength
cop.
Example:
# bad
if condition
do_stuff(bar)
end
unless qux.empty?
Foo.do_something
end
# good
do_stuff(bar) if condition
Foo.do_something unless qux.empty?
unexpected token tGT
(Using Ruby 2.5 parser; configure using TargetRubyVersion
parameter, under AllCops
) Open
<%- content_sections("page").each do |section| -%>
- Exclude checks
Bypass vulnerability in Active Storage Open
activestorage (5.2.1)
- Read upRead up
- Exclude checks
Advisory: CVE-2018-16477
Criticality: Medium
URL: https://groups.google.com/forum/#!topic/rubyonrails-security/3KQRnXDIuLg
Solution: upgrade to >= 5.2.1.1
Place the . on the next line, together with the method name. Open
joins(:container).
- Read upRead up
- Exclude checks
This cop checks the . position in multi-line method calls.
Example: EnforcedStyle: leading (default)
# bad
something.
mehod
# good
something
.method
Example: EnforcedStyle: trailing
# bad
something
.method
# good
something.
mehod
unexpected token tOP_ASGN
(Using Ruby 2.5 parser; configure using TargetRubyVersion
parameter, under AllCops
) Open
Ninetails::Seeds::Generator.generate_layout :<%= name %> do |layout|
- Exclude checks
Place the . on the next line, together with the method name. Open
includes(:current_revision).
- Read upRead up
- Exclude checks
This cop checks the . position in multi-line method calls.
Example: EnforcedStyle: leading (default)
# bad
something.
mehod
# good
something
.method
Example: EnforcedStyle: trailing
# bad
something
.method
# good
something.
mehod
%
-literals should be delimited by (
and )
. Open
%{#{key}: { #{print_element(value)} }}
- Read upRead up
- Exclude checks
This cop enforces the consistent usage of %
-literal delimiters.
Specify the 'default' key to set all preferred delimiters at once. You can continue to specify individual preferred delimiters to override the default.
Example:
# Style/PercentLiteralDelimiters:
# PreferredDelimiters:
# default: '[]'
# '%i': '()'
# good
%w[alpha beta] + %i(gamma delta)
# bad
%W(alpha #{beta})
# bad
%I(alpha beta)
Favor modifier if
usage when having a single-line body. Another good alternative is the usage of control flow &&
/||
. Open
if container.errors.present?
- Read upRead up
- Exclude checks
Checks for if and unless statements that would fit on one line
if written as a modifier if/unless. The maximum line length is
configured in the Metrics/LineLength
cop.
Example:
# bad
if condition
do_stuff(bar)
end
unless qux.empty?
Foo.do_something
end
# good
do_stuff(bar) if condition
Foo.do_something unless qux.empty?
Do not suppress exceptions. Open
rescue LoadError
- Read upRead up
- Exclude checks
This cop checks for rescue blocks with no body.
Example:
# bad
def some_method
do_something
rescue
# do nothing
end
Example:
# bad
begin
do_something
rescue
# do nothing
end
Example:
# good
def some_method
do_something
rescue
handle_exception
end
Example:
# good
begin
do_something
rescue
handle_exception
end