Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ source 'https://rubygems.org'
gem "activesupport", require: false
gem "parser"
gem "pry", require: false
gem "rubocop", "1.35.0", require: false
gem "rubocop", "1.36.0", require: false
gem "rubocop-i18n", require: false
gem "rubocop-graphql", require: false
gem "rubocop-minitest", require: false
Expand Down
24 changes: 12 additions & 12 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
GEM
remote: https://rubygems.org/
specs:
activesupport (7.0.3.1)
activesupport (7.0.4)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
Expand All @@ -21,7 +21,7 @@ GEM
pry (0.14.1)
coderay (~> 1.1)
method_source (~> 1.0)
rack (2.2.4)
rack (3.0.0)
rainbow (3.1.1)
rake (13.0.6)
regexp_parser (2.5.0)
Expand All @@ -32,14 +32,14 @@ GEM
rspec-mocks (~> 3.11.0)
rspec-core (3.11.0)
rspec-support (~> 3.11.0)
rspec-expectations (3.11.0)
rspec-expectations (3.11.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.11.0)
rspec-mocks (3.11.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.11.0)
rspec-support (3.11.0)
rubocop (1.35.0)
rubocop (1.36.0)
json (~> 2.3)
parallel (~> 1.10)
parser (>= 3.1.2.1)
Expand All @@ -51,23 +51,23 @@ GEM
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.21.0)
parser (>= 3.1.1.0)
rubocop-graphql (0.14.5)
rubocop-graphql (0.14.6)
rubocop (>= 0.87, < 2)
rubocop-i18n (3.0.0)
rubocop (~> 1.0)
rubocop-minitest (0.21.0)
rubocop-minitest (0.22.0)
rubocop (>= 0.90, < 2.0)
rubocop-performance (1.14.3)
rubocop-performance (1.15.0)
rubocop (>= 1.7.0, < 2.0)
rubocop-ast (>= 0.4.0)
rubocop-rails (2.15.2)
rubocop-rails (2.16.0)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.7.0, < 2.0)
rubocop (>= 1.33.0, < 2.0)
rubocop-rake (0.6.0)
rubocop (~> 1.0)
rubocop-rspec (2.12.1)
rubocop (~> 1.31)
rubocop-rspec (2.13.0)
rubocop (~> 1.33)
rubocop-sequel (0.3.4)
rubocop (~> 1.0)
rubocop-shopify (2.9.0)
Expand All @@ -91,7 +91,7 @@ DEPENDENCIES
pry
rake
rspec
rubocop (= 1.35.0)
rubocop (= 1.36.0)
rubocop-graphql
rubocop-i18n
rubocop-minitest
Expand Down
27 changes: 14 additions & 13 deletions config/contents/layout/block_alignment.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,24 @@ location. The autofixer will default to `start_of_line`.
# bad

foo.bar
.each do
baz
end
.each do
baz
end

# good

variable = lambda do |i|
i
foo.bar
.each do
baz
end

### Example: EnforcedStyleAlignWith: start_of_block
# bad

foo.bar
.each do
baz
end
.each do
baz
end

# good

Expand All @@ -46,13 +47,13 @@ location. The autofixer will default to `start_of_line`.
# bad

foo.bar
.each do
baz
end
.each do
baz
end

# good

foo.bar
.each do
baz
end
baz
end
8 changes: 4 additions & 4 deletions config/contents/layout/end_of_line.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ Checks for Windows-style line endings in the source code.
# all platforms.

# bad
puts 'Hello' # Return character is CR+LF on all platfoms.
puts 'Hello' # Return character is CR+LF on all platforms.

# good
puts 'Hello' # Return character is LF on all platfoms.
puts 'Hello' # Return character is LF on all platforms.

### Example: EnforcedStyle: crlf
# The `crlf` style means that CR+LF (Carriage Return + Line Feed) is
# enforced on all platforms.

# bad
puts 'Hello' # Return character is LF on all platfoms.
puts 'Hello' # Return character is LF on all platforms.

# good
puts 'Hello' # Return character is CR+LF on all platfoms.
puts 'Hello' # Return character is CR+LF on all platforms.
2 changes: 1 addition & 1 deletion config/contents/lint/duplicate_require.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Checks for duplicate `require`s and `require_relative`s.
Checks for duplicate ``require``s and ``require_relative``s.

### Safety:

Expand Down
12 changes: 9 additions & 3 deletions config/contents/lint/redundant_safe_navigation.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ Checks for redundant safe navigation calls.
`instance_of?`, `kind_of?`, `is_a?`, `eql?`, `respond_to?`, and `equal?` methods
are checked by default. These are customizable with `AllowedMethods` option.

The `AllowedMethods` option specifies nil-safe methods,
in other words, it is a method that is allowed to skip safe navigation.
Note that the `AllowedMethod` option is not an option that specifies methods
for which to suppress (allow) this cop's check.

In the example below, the safe navigation operator (`&.`) is unnecessary
because `NilClass` has methods like `respond_to?` and `is_a?`.

Expand Down Expand Up @@ -31,9 +36,10 @@ will be autocorrected to never return `nil`.
# good - without `&.` this will always return `true`
foo&.respond_to?(:to_a)

### Example: AllowedMethods: [foo?]
### Example: AllowedMethods: [nil_safe_method]
# bad
do_something if attrs&.foo?(:[])
do_something if attrs&.nil_safe_method(:[])

# good
do_something if attrs&.bar?(:[])
do_something if attrs.nil_safe_method(:[])
do_something if attrs&.not_nil_safe_method(:[])
2 changes: 1 addition & 1 deletion config/contents/lint/shadowed_exception.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ancestor is, or if it and its ancestor are both rescued in the
same `rescue` statement. In both cases, the more specific rescue is
unnecessary because it is covered by rescuing the less specific
exception. (ie. `rescue Exception, StandardError` has the same behavior
whether `StandardError` is included or not, because all `StandardError`s
whether `StandardError` is included or not, because all ``StandardError``s
are rescued by `rescue Exception`).

### Example:
Expand Down
2 changes: 1 addition & 1 deletion config/contents/lint/unreachable_loop.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ A loop that can never reach the second iteration is a possible error in the code
In rare cases where only one iteration (or at most one iteration) is intended behavior,
the code should be refactored to use `if` conditionals.

NOTE: Block methods that are used with `Enumerable`s are considered to be loops.
NOTE: Block methods that are used with ``Enumerable``s are considered to be loops.

`AllowedPatterns` can be used to match against the block receiver in order to allow
code that would otherwise be registered as an offense (eg. `times` used not in an
Expand Down
4 changes: 2 additions & 2 deletions config/contents/lint/useless_access_modifier.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ create other methods in the module's current access context.
# bad
class Foo
# The following is redundant (methods defined on the class'
# singleton class are not affected by the public modifier)
public
# singleton class are not affected by the private modifier)
private

def self.method3
end
Expand Down
2 changes: 1 addition & 1 deletion config/contents/lint/useless_ruby2_keywords.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Looks for `ruby2_keywords` calls for methods that do not need it.

`ruby2_keywords` should only be called on methods that accept an argument splat
(`*args`) but do not explicit keyword arguments (`k:` or `k: true`) or
(`\*args`) but do not explicit keyword arguments (`k:` or `k: true`) or
a keyword splat (`**kwargs`).

### Example:
Expand Down
6 changes: 6 additions & 0 deletions config/contents/style/access_modifier_declarations.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ EnforcedStyle config covers only method definitions.
Applications of visibility methods to symbols can be controlled
using AllowModifiersOnSymbols config.

### Safety:

Autocorrection is not safe, because the visibility of dynamically
defined methods can vary depending on the state determined by
the group access modifier.

### Example: EnforcedStyle: group (default)
# bad
class Foo
Expand Down
10 changes: 10 additions & 0 deletions config/contents/style/case_equality.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ Checks for uses of the case equality operator(===).

If `AllowOnConstant` option is enabled, the cop will ignore violations when the receiver of
the case equality operator is a constant.
If `AllowOnSelfClass` option is enabled, the cop will ignore violations when the receiver of
the case equality operator is `self.class`. Note intermediate variables are not accepted.

### Example:
# bad
Expand All @@ -20,3 +22,11 @@ the case equality operator is a constant.
### Example: AllowOnConstant: true
# good
Array === something

### Example: AllowOnSelfClass: false (default)
# bad
self.class === something

### Example: AllowOnSelfClass: true
# good
self.class === something
44 changes: 27 additions & 17 deletions config/contents/style/guard_clause.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Use a guard clause instead of wrapping the code inside a conditional
expression

A condition with an `elsif` or `else` branch is allowed unless
one of `return`, `break`, `next`, `raise`, or `fail` is used
in the body of the conditional expression.

### Example:
# bad
def test
Expand Down Expand Up @@ -45,31 +49,37 @@ expression

### Example: AllowConsecutiveConditionals: false (default)
# bad
if foo?
work
end
def test
if foo?
work
end

if bar? # <- reports an offense
work
if bar? # <- reports an offense
work
end
end

### Example: AllowConsecutiveConditionals: true
# good
if foo?
work
end
def test
if foo?
work
end

if bar?
work
if bar?
work
end
end

# bad
if foo?
work
end
def test
if foo?
work
end

do_something
do_something

if bar? # <- reports an offense
work
end
if bar? # <- reports an offense
work
end
end
9 changes: 5 additions & 4 deletions config/contents/style/symbol_proc.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ These are customizable with `AllowedMethods` option.

### Safety:

This cop is unsafe because `proc`s and blocks work differently
when additional arguments are passed in. A block will silently
allow additional arguments, but a `proc` will raise
an `ArgumentError`.
This cop is unsafe because there is a difference that a `Proc`
generated from `Symbol#to_proc` behaves as a lambda, while
a `Proc` generated from a block does not.
For example, a lambda will raise an `ArgumentError` if the
number of arguments is wrong, but a non-lambda `Proc` will not.

For example:

Expand Down