Showing 2,171 of 2,171 total issues
%i
-literals should be delimited by [
and ]
. Open
before_action :set_places, only: %i(all)
- 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
:type_number, :about_string, :tezo_string, :order, :council ) ;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
Space missing after semicolon. Open
:type_number, :about_string, :tezo_string, :order, :council ) ;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
Space found before semicolon. Open
:type_number, :about_string, :tezo_string, :order, :council ) ;end;end
- Read upRead up
- Exclude checks
Checks for semicolon (;) preceded by space.
Example:
# bad
x = 1 ; y = 2
# good
x = 1; y = 2
%i
-literals should be delimited by [
and ]
. Open
has_scope :by_memory_id, only: %i(index all)
- 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
has_scope :by_calendary_id, only: %i(index all)
- 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
memo_orders_attributes: %i(id order_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)
Prefer single-quoted strings when you don't need string interpolation or special symbols. Open
"memories.short_name",
- 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"
Use the new Ruby 1.9 hash syntax. Open
scope.where(:id => record.id).exists? and !@user.nil?
- Read upRead up
- Exclude checks
This cop checks hash literal syntax.
It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).
A separate offense is registered for each problematic pair.
The supported styles are:
- ruby19 - forces use of the 1.9 syntax (e.g.
{a: 1}
) when hashes have all symbols for keys - hash_rockets - forces use of hash rockets for all hashes
- nomixedkeys - simply checks for hashes with mixed syntaxes
- ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes
Example: EnforcedStyle: ruby19 (default)
# bad
{:a => 2}
{b: 1, :c => 2}
# good
{a: 2, b: 1}
{:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
{d: 1, 'e' => 2} # technically not forbidden
Example: EnforcedStyle: hash_rockets
# bad
{a: 1, b: 2}
{c: 1, 'd' => 5}
# good
{:a => 1, :b => 2}
Example: EnforcedStyle: nomixedkeys
# bad
{:a => 1, b: 2}
{c: 1, 'd' => 2}
# good
{:a => 1, :b => 2}
{c: 1, d: 2}
Example: EnforcedStyle: ruby19nomixed_keys
# bad
{:a => 1, :b => 2}
{c: 2, 'd' => 3} # should just use hash rockets
# good
{a: 1, b: 2}
{:c => 3, 'd' => 4}
Interpolation in single quoted string detected. Use double quoted strings if you need interpolation. Open
ру_РУ: "Пятница \#{week}-я по Пасхе"
- Read upRead up
- Exclude checks
This cop checks for interpolation in a single quoted string.
Example:
# bad
foo = 'something with #{interpolation} inside'
Example:
# good
foo = "something with #{interpolation} inside"
Do not use space inside reference brackets. Open
record.errors[ attribute ] <<
- Read upRead up
- Exclude checks
Checks that reference brackets have or don't have surrounding space depending on configuration.
Example: EnforcedStyle: no_space (default)
# The `no_space` style enforces that reference brackets have
# no surrounding space.
# bad
hash[ :key ]
array[ index ]
# good
hash[:key]
array[index]
Example: EnforcedStyle: space
# The `space` style enforces that reference brackets have
# surrounding space.
# bad
hash[:key]
array[index]
# good
hash[ :key ]
array[ index ]
Place the end statement of a multi-line method on its own line. Open
I18n.t( 'activerecord.errors.invalid_last_name' ) ; end ; end ; end
- Read upRead up
- Exclude checks
This cop checks for trailing code after the method definition.
Example:
# bad
def some_method
do_stuff; end
def do_this(x)
baz.map { |b| b.this(x) } end
def foo
block do
bar
end end
# good
def some_method
do_stuff
end
def do_this(x)
baz.map { |b| b.this(x) }
end
def foo
block do
bar
end
end
Avoid multi-line chains of blocks. Open
end.flatten.map { |x| [ x.keys.first, x.values.first ] }.to_h
- Read upRead up
- Exclude checks
This cop checks for chaining of a block after another block that spans multiple lines.
Example:
Thread.list.find_all do |t|
t.alive?
end.map do |t|
t.object_id
end
Do not use space inside reference brackets. Open
record.errors[ attribute ] <<
- Read upRead up
- Exclude checks
Checks that reference brackets have or don't have surrounding space depending on configuration.
Example: EnforcedStyle: no_space (default)
# The `no_space` style enforces that reference brackets have
# no surrounding space.
# bad
hash[ :key ]
array[ index ]
# good
hash[:key]
array[index]
Example: EnforcedStyle: space
# The `space` style enforces that reference brackets have
# surrounding space.
# bad
hash[:key]
array[index]
# good
hash[ :key ]
array[ index ]
Missing top-level class documentation comment. Open
class PatronymicValidator < ActiveModel::EachValidator
- 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
Use &&
instead of and
. Open
scope.where(:id => record.id).exists? and !@user.nil?
- Read upRead up
- Exclude checks
This cop checks for uses of and
and or
, and suggests using &&
and
|| instead
. It can be configured to check only in conditions, or in
all contexts.
Example: EnforcedStyle: always (default)
# bad
foo.save and return
# bad
if foo and bar
end
# good
foo.save && return
# good
if foo && bar
end
Example: EnforcedStyle: conditionals
# bad
if foo and bar
end
# good
foo.save && return
# good
foo.save and return
# good
if foo && bar
end
Missing top-level class documentation comment. Open
class NamePolicy < ApplicationPolicy
- 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
Remove debugger entry point binding.pry
. Open
binding.pry
- Read upRead up
- Exclude checks
This cop checks for calls to debugger or pry.
Example:
# bad (ok during development)
# using pry
def some_method
binding.pry
do_something
end
Example:
# bad (ok during development)
# using byebug
def some_method
byebug
do_something
end
Example:
# good
def some_method
do_something
end
Missing top-level class documentation comment. Open
class OrderPolicy < ApplicationPolicy
- 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
Duplicated key in hash literal. Open
('01.08'..'14.08') => {
- Read upRead up
- Exclude checks
This cop checks for duplicated keys in hash literals.
This cop mirrors a warning in Ruby 2.2.
Example:
# bad
hash = { food: 'apple', food: 'orange' }
Example:
# good
hash = { food: 'apple', other_food: 'orange' }