Showing 2,171 of 2,171 total issues
Prefer single-quoted strings when you don't need string interpolation or special symbols. Open
joins(join).select(selector).group(:id, "#{model.table_name}.text", "languages.key", "alphabeths.key")
- Read upRead up
- Exclude checks
Checks if uses of quotes match the configured preference.
Example: EnforcedStyle: single_quotes (default)
# bad
"No special symbols"
"No string interpolation"
"Just text"
# good
'No special symbols'
'No string interpolation'
'Just text'
"Wait! What's #{this}!"
Example: EnforcedStyle: double_quotes
# bad
'Just some text'
'No special chars or interpolation'
# good
"Just some text"
"No special chars or interpolation"
"Every string in #{project} uses double_quotes"
unexpected token error
(Using Ruby 2.1 parser; configure using TargetRubyVersion
parameter, under AllCops
) Open
event_id: @event&.id
- Exclude checks
end
at 6, 70 is not aligned with class
at 1, 0. Open
validates :tone, inclusion: { in: 1..8 }, if: ->{ tone.present? } ;end
- Read upRead up
- Exclude checks
This cop checks whether the end keywords are aligned properly.
Three modes are supported through the EnforcedStyleAlignWith
configuration parameter:
If it's set to keyword
(which is the default), the end
shall be aligned with the start of the keyword (if, class, etc.).
If it's set to variable
the end
shall be aligned with the
left-hand-side of the variable assignment, if there is one.
If it's set to start_of_line
, the end
shall be aligned with the
start of the line where the matching keyword appears.
Example: EnforcedStyleAlignWith: keyword (default)
# bad
variable = if true
end
# good
variable = if true
end
Example: EnforcedStyleAlignWith: variable
# bad
variable = if true
end
# good
variable = if true
end
Example: EnforcedStyleAlignWith: startofline
# bad
variable = if true
end
# good
puts(if true
end)
%i
-literals should be delimited by [
and ]
. Open
links_attributes: %i(id url language_code alphabeth_code type _destroy),
- 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)
Space missing after semicolon. Open
v ;end;end
- Read upRead up
- Exclude checks
Checks for semicolon (;) not followed by some kind of space.
Example:
# bad
x = 1;y = 2
# good
x = 1; y = 2
Closing method call brace must be on the line after the last argument when opening brace is on a separate line from the first argument. Open
descriptions_attributes: %i(id text language_code alphabeth_code _destroy))
- Read upRead up
- Exclude checks
This cop checks that the closing brace in a method call is either on the same line as the last method argument, or a new line.
When using the symmetrical
(default) style:
If a method call's opening brace is on the same line as the first argument of the call, then the closing brace should be on the same line as the last argument of the call.
If an method call's opening brace is on the line above the first argument of the call, then the closing brace should be on the line below the last argument of the call.
When using the new_line
style:
The closing brace of a multi-line method call must be on the line after the last argument of the call.
When using the same_line
style:
The closing brace of a multi-line method call must be on the same line as the last argument of the call.
Example:
# symmetrical: bad
# new_line: good
# same_line: bad
foo(a,
b
)
# symmetrical: bad
# new_line: bad
# same_line: good
foo(
a,
b)
# symmetrical: good
# new_line: bad
# same_line: good
foo(a,
b)
# symmetrical: good
# new_line: good
# same_line: bad
foo(
a,
b
)
Missing top-level class documentation comment. Open
class Admin::OrdersController < Admin::CommonController
- 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
unexpected token error
(Using Ruby 2.1 parser; configure using TargetRubyVersion
parameter, under AllCops
) Open
request.formats.first&.symbol == :html
- Exclude checks
%i
-literals should be delimited by [
and ]
. Open
nomina_attributes: %i(id root_id bind_kind_name modifier bond_to_id _destroy),
- 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)
Closing method call brace must be on the line after the last argument when opening brace is on a separate line from the first argument. Open
descriptions_attributes: %i(id text language_code alphabeth_code _destroy))
- Read upRead up
- Exclude checks
This cop checks that the closing brace in a method call is either on the same line as the last method argument, or a new line.
When using the symmetrical
(default) style:
If a method call's opening brace is on the same line as the first argument of the call, then the closing brace should be on the same line as the last argument of the call.
If an method call's opening brace is on the line above the first argument of the call, then the closing brace should be on the line below the last argument of the call.
When using the new_line
style:
The closing brace of a multi-line method call must be on the line after the last argument of the call.
When using the same_line
style:
The closing brace of a multi-line method call must be on the same line as the last argument of the call.
Example:
# symmetrical: bad
# new_line: good
# same_line: bad
foo(a,
b
)
# symmetrical: bad
# new_line: bad
# same_line: good
foo(
a,
b)
# symmetrical: good
# new_line: bad
# same_line: good
foo(a,
b)
# symmetrical: good
# new_line: good
# same_line: bad
foo(
a,
b
)
%i
-literals should be delimited by [
and ]
. Open
titles_attributes: %i(id text language_code alphabeth_code _destroy),
- 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)
%i
-literals should be delimited by [
and ]
. Open
titles_attributes: %i(id text language_code alphabeth_code _destroy),
- 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)
%i
-literals should be delimited by [
and ]
. Open
tweets_attributes: %i(id text language_code alphabeth_code _destroy),
- 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)
Use the lambda
method for multiline lambdas. Open
scope :by_token, -> text do
- Read upRead up
- Exclude checks
This cop (by default) checks for uses of the lambda literal syntax for single line lambdas, and the method call syntax for multiline lambdas. It is configurable to enforce one of the styles for both single line and multiline lambdas as well.
Example: EnforcedStyle: linecountdependent (default)
# bad
f = lambda { |x| x }
f = ->(x) do
x
end
# good
f = ->(x) { x }
f = lambda do |x|
x
end
Example: EnforcedStyle: lambda
# bad
f = ->(x) { x }
f = ->(x) do
x
end
# good
f = lambda { |x| x }
f = lambda do |x|
x
end
Example: EnforcedStyle: literal
# bad
f = lambda { |x| x }
f = lambda do |x|
x
end
# good
f = ->(x) { x }
f = ->(x) do
x
end
Use the lambda
method for multiline lambdas. Open
scope :by_root, -> do
- Read upRead up
- Exclude checks
This cop (by default) checks for uses of the lambda literal syntax for single line lambdas, and the method call syntax for multiline lambdas. It is configurable to enforce one of the styles for both single line and multiline lambdas as well.
Example: EnforcedStyle: linecountdependent (default)
# bad
f = lambda { |x| x }
f = ->(x) do
x
end
# good
f = ->(x) { x }
f = lambda do |x|
x
end
Example: EnforcedStyle: lambda
# bad
f = ->(x) { x }
f = ->(x) do
x
end
# good
f = lambda { |x| x }
f = lambda do |x|
x
end
Example: EnforcedStyle: literal
# bad
f = lambda { |x| x }
f = lambda do |x|
x
end
# good
f = ->(x) { x }
f = ->(x) do
x
end
Wrap stabby lambda arguments with parentheses. Open
scope :by_token, -> text do
- Read upRead up
- Exclude checks
Check for parentheses around stabby lambda arguments.
There are two different styles. Defaults to require_parentheses
.
Example: EnforcedStyle: require_parentheses (default)
# bad
->a,b,c { a + b + c }
# good
->(a,b,c) { a + b + c}
Example: EnforcedStyle: requirenoparentheses
# bad
->(a,b,c) { a + b + c }
# good
->a,b,c { a + b + c}
Space missing after semicolon. Open
validates :tone, inclusion: { in: 1..8 }, if: ->{ tone.present? } ;end
- Read upRead up
- Exclude checks
Checks for semicolon (;) not followed by some kind of space.
Example:
# bad
x = 1;y = 2
# good
x = 1; y = 2
unexpected token tRCURLY
(Using Ruby 2.1 parser; configure using TargetRubyVersion
parameter, under AllCops
) Open
}
- Exclude checks
unexpected token tCOLON
(Using Ruby 2.1 parser; configure using TargetRubyVersion
parameter, under AllCops
) Open
'avatar_url': user_info['avatar_url'],
- Exclude checks
unexpected token tCOLON
(Using Ruby 2.1 parser; configure using TargetRubyVersion
parameter, under AllCops
) Open
'info': user_info['bio'],
- Exclude checks