Showing 365 of 368 total issues
Prefer single-quoted strings when you don't need string interpolation or special symbols. Open
if action_name == "about"
- 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"
Shadowing outer local variable - context
. Open
context = params[:result][:contexts].any? {|context| context[:name].downcase == 'nextmeetup'}
- Read upRead up
- Exclude checks
This cop looks for use of the same name as outer local variables
for block arguments or block local variables.
This is a mimic of the warning
"shadowing outer local variable - foo" from ruby -cw
.
Example:
# bad
def some_method
foo = 1
2.times do |foo| # shadowing outer `foo`
do_something(foo)
end
end
Example:
# good
def some_method
foo = 1
2.times do |bar|
do_something(bar)
end
end
Useless assignment to variable - msg
. Open
msg = ["El meetup #{@meetup.title} tendrá lugar el #{@meetup.date.strftime('%d/%m/%y')}", url_for(@meetup)]
- Read upRead up
- Exclude checks
This cop checks for every useless assignment to local variable in every
scope.
The basic idea for this cop was from the warning of ruby -cw
:
assigned but unused variable - foo
Currently this cop has advanced logic that detects unreferenced reassignments and properly handles varied cases such as branch, loop, rescue, ensure, etc.
Example:
# bad
def some_method
some_var = 1
do_something
end
Example:
# good
def some_method
some_var = 1
do_something(some_var)
end
Line is too long. [159/80] Open
msg = ["No hay ningún meetup planeado todavía. Pero puedes ver las charlas de los anteriores ponentes en nuestra web.", "http://infusionvlc.com/archive"]
- Exclude checks
Use casecmp
instead of downcase ==
. Open
context = params[:result][:contexts].any? {|context| context[:name].downcase == 'nextmeetup'}
- Read upRead up
- Exclude checks
This cop identifies places where a case-insensitive string comparison
can better be implemented using casecmp
.
Example:
# bad
str.downcase == 'abc'
str.upcase.eql? 'ABC'
'abc' == str.downcase
'ABC'.eql? str.upcase
str.downcase == str.downcase
# good
str.casecmp('ABC').zero?
'abc'.casecmp(str).zero?
Use @meetups.count.zero?
instead of @meetups.count == 0
. Open
if @meetups.count == 0
- Read upRead up
- Exclude checks
This cop checks for usage of comparison operators (==
,
>
, <
) to test numbers as zero, positive, or negative.
These can be replaced by their respective predicate methods.
The cop can also be configured to do the reverse.
The cop disregards #nonzero?
as it its value is truthy or falsey,
but not true
and false
, and thus not always interchangeable with
!= 0
.
The cop ignores comparisons to global variables, since they are often
populated with objects which can be compared with integers, but are
not themselves Interger
polymorphic.
Example: EnforcedStyle: predicate (default)
# bad
foo == 0
0 > foo
bar.baz > 0
# good
foo.zero?
foo.negative?
bar.baz.positive?
Example: EnforcedStyle: comparison
# bad
foo.zero?
foo.negative?
bar.baz.positive?
# good
foo == 0
0 > foo
bar.baz > 0
Space missing inside }. Open
format.js { render 'notifications/read'}
- Read upRead up
- Exclude checks
Checks that block braces have or don't have surrounding space inside them on configuration. For blocks taking parameters, it checks that the left brace has or doesn't have trailing space depending on configuration.
Example: EnforcedStyle: space (default)
# The `space` style enforces that block braces have
# surrounding space.
# bad
some_array.each {puts e}
# good
some_array.each { puts e }
Example: EnforcedStyle: no_space
# The `no_space` style enforces that block braces don't
# have surrounding space.
# bad
some_array.each { puts e }
# good
some_array.each {puts e}
Example: EnforcedStyleForEmptyBraces: no_space (default)
# The `no_space` EnforcedStyleForEmptyBraces style enforces that
# block braces don't have a space in between when empty.
# bad
some_array.each { }
some_array.each { }
some_array.each { }
# good
some_array.each {}
Example: EnforcedStyleForEmptyBraces: space
# The `space` EnforcedStyleForEmptyBraces style enforces that
# block braces have at least a spece in between when empty.
# bad
some_array.each {}
# good
some_array.each { }
some_array.each { }
some_array.each { }
Example: SpaceBeforeBlockParameters: true (default)
# The SpaceBeforeBlockParameters style set to `true` enforces that
# there is a space between `{` and `|`. Overrides `EnforcedStyle`
# if there is a conflict.
# bad
[1, 2, 3].each {|n| n * 2 }
# good
[1, 2, 3].each { |n| n * 2 }
Example: SpaceBeforeBlockParameters: true
# The SpaceBeforeBlockParameters style set to `false` enforces that
# there is no space between `{` and `|`. Overrides `EnforcedStyle`
# if there is a conflict.
# bad
[1, 2, 3].each { |n| n * 2 }
# good
[1, 2, 3].each {|n| n * 2 }
Use \
instead of +
or <<
to concatenate those strings. Open
"meetup_sessions.meetup_id = meetups.id LEFT OUTER JOIN " +
- Read upRead up
- Exclude checks
This cop checks for string literal concatenation at the end of a line.
Example:
# bad
some_str = 'ala' +
'bala'
some_str = 'ala' <<
'bala'
# good
some_str = 'ala' \
'bala'
Keep a blank line before and after private
. Open
private
- Read upRead up
- Exclude checks
Access modifiers should be surrounded by blank lines.
Example:
# bad
class Foo
def bar; end
private
def baz; end
end
# good
class Foo
def bar; end
private
def baz; end
end
Shadowing outer local variable - context
. Open
context = params[:result][:contexts].any? {|context| context[:name].downcase == 'nextmeetup'}
- Read upRead up
- Exclude checks
This cop looks for use of the same name as outer local variables
for block arguments or block local variables.
This is a mimic of the warning
"shadowing outer local variable - foo" from ruby -cw
.
Example:
# bad
def some_method
foo = 1
2.times do |foo| # shadowing outer `foo`
do_something(foo)
end
end
Example:
# good
def some_method
foo = 1
2.times do |bar|
do_something(bar)
end
end
Shadowing outer local variable - context
. Open
context = params[:result][:contexts].any? {|context| context[:name].downcase == 'nextmeetup'}
- Read upRead up
- Exclude checks
This cop looks for use of the same name as outer local variables
for block arguments or block local variables.
This is a mimic of the warning
"shadowing outer local variable - foo" from ruby -cw
.
Example:
# bad
def some_method
foo = 1
2.times do |foo| # shadowing outer `foo`
do_something(foo)
end
end
Example:
# good
def some_method
foo = 1
2.times do |bar|
do_something(bar)
end
end
Unused method argument - resource
. If it's necessary, use _
or _resource
as an argument name to indicate that it won't be used. You can also write as after_sign_in_path_for(*)
if you want the method to accept any arguments but don't care about them. Open
def after_sign_in_path_for(resource)
- 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
Space missing inside }. Open
format.js { render 'assistances/updated'}
- Read upRead up
- Exclude checks
Checks that block braces have or don't have surrounding space inside them on configuration. For blocks taking parameters, it checks that the left brace has or doesn't have trailing space depending on configuration.
Example: EnforcedStyle: space (default)
# The `space` style enforces that block braces have
# surrounding space.
# bad
some_array.each {puts e}
# good
some_array.each { puts e }
Example: EnforcedStyle: no_space
# The `no_space` style enforces that block braces don't
# have surrounding space.
# bad
some_array.each { puts e }
# good
some_array.each {puts e}
Example: EnforcedStyleForEmptyBraces: no_space (default)
# The `no_space` EnforcedStyleForEmptyBraces style enforces that
# block braces don't have a space in between when empty.
# bad
some_array.each { }
some_array.each { }
some_array.each { }
# good
some_array.each {}
Example: EnforcedStyleForEmptyBraces: space
# The `space` EnforcedStyleForEmptyBraces style enforces that
# block braces have at least a spece in between when empty.
# bad
some_array.each {}
# good
some_array.each { }
some_array.each { }
some_array.each { }
Example: SpaceBeforeBlockParameters: true (default)
# The SpaceBeforeBlockParameters style set to `true` enforces that
# there is a space between `{` and `|`. Overrides `EnforcedStyle`
# if there is a conflict.
# bad
[1, 2, 3].each {|n| n * 2 }
# good
[1, 2, 3].each { |n| n * 2 }
Example: SpaceBeforeBlockParameters: true
# The SpaceBeforeBlockParameters style set to `false` enforces that
# there is no space between `{` and `|`. Overrides `EnforcedStyle`
# if there is a conflict.
# bad
[1, 2, 3].each { |n| n * 2 }
# good
[1, 2, 3].each {|n| n * 2 }
Do not chain ordinary method call after safe navigation operator. Open
!@session.nil? && @session&.event&.date <= Date.today && \
- Read upRead up
- Exclude checks
The safe navigation operator returns nil if the receiver is nil. If you chain an ordinary method call after a safe navigation operator, it raises NoMethodError. We should use a safe navigation operator after a safe navigation operator. This cop checks for the problem outlined above.
Example:
# bad
x&.foo.bar
x&.foo + bar
x&.foo[bar]
Example:
# good
x&.foo&.bar
x&.foo || bar
Line is too long. [90/80] Open
!@user.nil? && @meetup.holdings.where('user_id = ? AND role < ?', @user.id, 2).exists?
- Exclude checks
Line is too long. [88/80] Open
subject: I18n.t('notification_mailer.notify_activity.subject_assistance', \
- Exclude checks
Prefer single-quoted strings inside interpolations. Open
exec "yarnpkg #{ARGV.join(" ")}"
- Read upRead up
- Exclude checks
This cop checks that quotes inside the string interpolation match the configured preference.
Example: EnforcedStyle: single_quotes (default)
# bad
result = "Tests #{success ? "PASS" : "FAIL"}"
# good
result = "Tests #{success ? 'PASS' : 'FAIL'}"
Example: EnforcedStyle: double_quotes
# bad
result = "Tests #{success ? 'PASS' : 'FAIL'}"
# good
result = "Tests #{success ? "PASS" : "FAIL"}"
Script file setup doesn't have execute permission. Open
#!/usr/bin/env ruby.exe
- Exclude checks
Extra empty line detected at class body end. Open
end
- Read upRead up
- Exclude checks
This cops checks if empty lines around the bodies of classes match the configuration.
Example: EnforcedStyle: empty_lines
# good
class Foo
def bar
# ...
end
end
Example: EnforcedStyle: emptylinesexcept_namespace
# good
class Foo
class Bar
# ...
end
end
Example: EnforcedStyle: emptylinesspecial
# good
class Foo
def bar; end
end
Example: EnforcedStyle: noemptylines (default)
# good
class Foo
def bar
# ...
end
end
Use nested module/class definitions instead of compact style. Open
class ActiveSupport::TestCase
- Read upRead up
- Exclude checks
This cop checks the style of children definitions at classes and modules. Basically there are two different styles:
Example: EnforcedStyle: nested (default)
# good
# have each child on its own line
class Foo
class Bar
end
end
Example: EnforcedStyle: compact
# good
# combine definitions as much as possible
class Foo::Bar
end
The compact style is only forced for classes/modules with one child.