Showing 2,171 of 2,171 total issues
Redundant self
detected. Open
self.merge(or_rel).distinct
- Read upRead up
- Exclude checks
This cop checks for redundant uses of self
.
The usage of self
is only needed when:
Sending a message to same object with zero arguments in presence of a method name clash with an argument or a local variable.
Calling an attribute writer to prevent an local variable assignment.
Note, with using explicit self you can only send messages with public or protected scope, you cannot send private messages this way.
Note we allow uses of self
with operators because it would be awkward
otherwise.
Example:
# bad
def foo(bar)
self.baz
end
# good
def foo(bar)
self.bar # Resolves name clash with the argument.
end
def foo
bar = 1
self.bar # Resolves name clash with the local variable.
end
def foo
%w[x y z].select do |bar|
self.bar == bar # Resolves name clash with argument of the block.
end
end
Do not use spaces between ->
and opening brace in lambda literals Open
scope :with_description, -> context do
as = table.table_alias || table.name
language_codes = [context[:locales]].flatten
selector = self.select_values.dup
- Read upRead up
- Exclude checks
This cop checks for spaces between -> and opening parameter brace in lambda literals.
Example: EnforcedStyle: requirenospace (default)
# bad
a = -> (x, y) { x + y }
# good
a = ->(x, y) { x + y }
Example: EnforcedStyle: require_space
# bad
a = ->(x, y) { x + y }
# good
a = -> (x, y) { x + y }
Wrap stabby lambda arguments with parentheses. Open
scope :with_description, -> context 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}
Use 3 (not -1) spaces for indenting an expression spanning multiple lines. Open
.order( :describable_type )
- Read upRead up
- Exclude checks
This cop checks the indentation of the method name part in method calls that span more than one line.
Example: EnforcedStyle: aligned
# bad
while myvariable
.b
# do something
end
# good
while myvariable
.b
# do something
end
# good
Thing.a
.b
.c
Example: EnforcedStyle: indented
# good
while myvariable
.b
# do something
end
Example: EnforcedStyle: indentedrelativeto_receiver
# good
while myvariable
.a
.b
# do something
end
# good
myvariable = Thing
.a
.b
.c
Missing top-level module documentation comment. Open
module WithTitles
- 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
new_root_id = self.bond_to&.nomina&.first&.root_id || name_id
- Exclude checks
Redundant self
detected. Open
self._validate_callbacks.select do |callback|
- Read upRead up
- Exclude checks
This cop checks for redundant uses of self
.
The usage of self
is only needed when:
Sending a message to same object with zero arguments in presence of a method name clash with an argument or a local variable.
Calling an attribute writer to prevent an local variable assignment.
Note, with using explicit self you can only send messages with public or protected scope, you cannot send private messages this way.
Note we allow uses of self
with operators because it would be awkward
otherwise.
Example:
# bad
def foo(bar)
self.baz
end
# good
def foo(bar)
self.bar # Resolves name clash with the argument.
end
def foo
bar = 1
self.bar # Resolves name clash with the local variable.
end
def foo
%w[x y z].select do |bar|
self.bar == bar # Resolves name clash with argument of the block.
end
end
Do not use spaces between ->
and opening brace in lambda literals Open
scope :by_tokens, -> string_in do
return self if string_in.blank?
# TODO fix the correctness of the query
klass = self.model_name.name.constantize
or_rel_tokens = string_in.split(/\//).map do |or_token|
- Read upRead up
- Exclude checks
This cop checks for spaces between -> and opening parameter brace in lambda literals.
Example: EnforcedStyle: requirenospace (default)
# bad
a = -> (x, y) { x + y }
# good
a = ->(x, y) { x + y }
Example: EnforcedStyle: require_space
# bad
a = ->(x, y) { x + y }
# good
a = -> (x, y) { x + y }
Wrap stabby lambda arguments with parentheses. Open
scope :by_tokens, -> string_in 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}
Missing top-level module documentation comment. Open
module WithDescriptions
- 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 spaces between ->
and opening brace in lambda literals Open
scope :with_title, -> context do
as = table.table_alias || table.name
language_codes = [context[:locales]].flatten
selector = self.select_values.dup
- Read upRead up
- Exclude checks
This cop checks for spaces between -> and opening parameter brace in lambda literals.
Example: EnforcedStyle: requirenospace (default)
# bad
a = -> (x, y) { x + y }
# good
a = ->(x, y) { x + y }
Example: EnforcedStyle: require_space
# bad
a = ->(x, y) { x + y }
# good
a = -> (x, y) { x + y }
Do not use space inside array brackets. Open
language_codes = [ context[:locales] ].flatten
- Read upRead up
- Exclude checks
Checks that brackets used for array literals have or don't have surrounding space depending on configuration.
Example: EnforcedStyle: space
# The `space` style enforces that array literals have
# surrounding space.
# bad
array = [a, b, c, d]
# good
array = [ a, b, c, d ]
Example: EnforcedStyle: no_space
# The `no_space` style enforces that array literals have
# no surrounding space.
# bad
array = [ a, b, c, d ]
# good
array = [a, b, c, d]
Example: EnforcedStyle: compact
# The `compact` style normally requires a space inside
# array brackets, with the exception that successive left
# or right brackets are collapsed together in nested arrays.
# bad
array = [ a, [ b, c ] ]
# good
array = [ a, [ b, c ]]
Space inside parentheses detected. Open
if self.class.respond_to?( :default_key )
- Read upRead up
- Exclude checks
Checks for spaces inside ordinary round parentheses.
Example:
# bad
f( 3)
g = (a + 3 )
# good
f(3)
g = (a + 3)
end
at 11, 30 is not aligned with def
at 10, 3. Open
self.default_key = key ;end
- Read upRead up
- Exclude checks
This cop checks whether the end keywords of method definitions are aligned properly.
Two modes are supported through the EnforcedStyleAlignWith configuration
parameter. If it's set to start_of_line
(which is the default), the
end
shall be aligned with the start of the line where the def
keyword is. If it's set to def
, the end
shall be aligned with the
def
keyword.
Example: EnforcedStyleAlignWith: startofline (default)
# bad
private def foo
end
# good
private def foo
end
Example: EnforcedStyleAlignWith: def
# bad
private def foo
end
# good
private def foo
end
Do not use spaces between ->
and opening brace in lambda literals Open
scope :with_links, -> context do
join_name = table.table_alias || table.name
language_codes = [context[:locales]].flatten
alphabeth_codes = Languageble.alphabeth_list_for(language_codes).flatten
selector = self.select_values.dup
- Read upRead up
- Exclude checks
This cop checks for spaces between -> and opening parameter brace in lambda literals.
Example: EnforcedStyle: requirenospace (default)
# bad
a = -> (x, y) { x + y }
# good
a = ->(x, y) { x + y }
Example: EnforcedStyle: require_space
# bad
a = ->(x, y) { x + y }
# good
a = -> (x, y) { x + y }
Missing space after #
. Open
base.has_many :service_links, as: :info, inverse_of: :info, dependent: :destroy #ЧИНЬ превод во services
- Read upRead up
- Exclude checks
This cop checks whether comments have a leading space after the
#
denoting the start of the comment. The leading space is not
required for some RDoc special syntax, like #++
, #--
,
#:nodoc
, =begin
- and =end
comments, "shebang" directives,
or rackup options.
Example:
# bad
#Some comment
# good
# Some comment
Do not use spaces between ->
and opening brace in lambda literals Open
scope :with_descriptions, -> context do
join_name = table.table_alias || table.name
language_codes = [context[:locales]].flatten
alphabeth_codes = Languageble.alphabeth_list_for(language_codes).flatten
selector = self.select_values.dup
- Read upRead up
- Exclude checks
This cop checks for spaces between -> and opening parameter brace in lambda literals.
Example: EnforcedStyle: requirenospace (default)
# bad
a = -> (x, y) { x + y }
# good
a = ->(x, y) { x + y }
Example: EnforcedStyle: require_space
# bad
a = ->(x, y) { x + y }
# good
a = -> (x, y) { x + y }
Space inside parentheses detected. Open
alphabeth_codes = Languageble.alphabeth_list_for( language_codes ).flatten
- Read upRead up
- Exclude checks
Checks for spaces inside ordinary round parentheses.
Example:
# bad
f( 3)
g = (a + 3 )
# good
f(3)
g = (a + 3)
Space missing after semicolon. Open
x.mb_chars.downcase ;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
Do not use space inside reference brackets. Open
digits + firsts[ 0...4 - digits.size ].join
- 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 ]