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
5 changes: 2 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@ gem "activesupport", require: false
gem "mry", require: false
gem "parser"
gem "pry", require: false
gem "rubocop", "0.92.0", require: false
gem "rubocop", "1.7.0", require: false
gem "rubocop-i18n", require: false
gem "rubocop-migrations", require: false
gem "rubocop-minitest", require: false
gem "rubocop-performance", require: false
gem "rubocop-rails", require: false
gem "rubocop-rake", require: false
gem "rubocop-rspec", require: false
gem "rubocop-sequel", require: false
gem 'rubocop-sorbet', require: false
gem "rubocop-sorbet", require: false
gem "rubocop-thread_safety", require: false
gem "safe_yaml"
gem "test-prof", require: false
Expand Down
29 changes: 13 additions & 16 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ GEM
minitest (5.14.1)
mry (0.78.0.0)
rubocop (>= 0.41.0)
parallel (1.19.2)
parser (2.7.1.5)
parallel (1.20.1)
parser (3.0.0.0)
ast (~> 2.4.1)
pry (0.13.1)
coderay (~> 1.1)
method_source (~> 1.0)
rack (2.2.3)
rainbow (3.0.0)
rake (13.0.1)
regexp_parser (1.8.1)
regexp_parser (2.0.3)
rexml (3.2.4)
rspec (3.9.0)
rspec-core (~> 3.9.0)
Expand All @@ -41,21 +41,19 @@ GEM
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.9.0)
rspec-support (3.9.3)
rubocop (0.92.0)
rubocop (1.7.0)
parallel (~> 1.10)
parser (>= 2.7.1.5)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.7)
regexp_parser (>= 1.8, < 3.0)
rexml
rubocop-ast (>= 0.5.0)
rubocop-ast (>= 1.2.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 2.0)
rubocop-ast (0.7.1)
rubocop-ast (1.4.0)
parser (>= 2.7.1.5)
rubocop-i18n (2.0.2)
rubocop (~> 0.51)
rubocop-migrations (0.1.2)
rubocop (~> 0.41)
rubocop-i18n (3.0.0)
rubocop (~> 1.0)
rubocop-minitest (0.9.0)
rubocop (>= 0.74)
rubocop-performance (1.7.0)
Expand All @@ -68,13 +66,13 @@ GEM
rubocop
rubocop-rspec (1.41.0)
rubocop (>= 0.68.1)
rubocop-sequel (0.0.6)
rubocop (~> 0.55, >= 0.55)
rubocop-sequel (0.1.0)
rubocop (~> 1.0)
rubocop-sorbet (0.5.1)
rubocop
rubocop-thread_safety (0.4.1)
rubocop (>= 0.51.0)
ruby-progressbar (1.10.1)
ruby-progressbar (1.11.0)
safe_yaml (1.0.5)
test-prof (0.11.3)
thread_safe (0.3.6)
Expand All @@ -93,9 +91,8 @@ DEPENDENCIES
pry
rake
rspec
rubocop (= 0.92.0)
rubocop (= 1.7.0)
rubocop-i18n
rubocop-migrations
rubocop-minitest
rubocop-performance
rubocop-rails
Expand Down
11 changes: 10 additions & 1 deletion config/contents/bundler/duplicated_gem.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,13 @@ A Gem's requirements should be listed only once in a Gemfile.
end

# good
gem 'rubocop', groups: [:development, :test]
gem 'rubocop', groups: [:development, :test]

# good - conditional declaration
if Dir.exist?(local)
gem 'rubocop', path: local
elsif ENV['RUBOCOP_VERSION'] == 'master'
gem 'rubocop', git: 'https://github.com/rubocop-hq/rubocop.git'
else
gem 'rubocop', '~> 0.90.0'
end
5 changes: 3 additions & 2 deletions config/contents/gemspec/required_ruby_version.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@ required by gemspec.
spec.required_ruby_version = '>= 2.5'
end

# good
# accepted but not recommended
Gem::Specification.new do |spec|
spec.required_ruby_version = ['>= 2.5.0', '< 2.7.0']
end

# good
# accepted but not recommended, since
# Ruby does not really follow semantic versionning
Gem::Specification.new do |spec|
spec.required_ruby_version = '~> 2.5'
end
2 changes: 1 addition & 1 deletion config/contents/layout/else_alignment.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
This cop checks the alignment of else keywords. Normally they should
be aligned with an if/unless/while/until/begin/def keyword, but there
be aligned with an if/unless/while/until/begin/def/rescue keyword, but there
are special cases when they should follow the same rules as the
alignment of end.

Expand Down
64 changes: 59 additions & 5 deletions config/contents/layout/empty_line_between_defs.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
This cop checks whether method definitions are
separated by one empty line.
This cop checks whether class/module/method definitions are
separated by one or more empty lines.

`NumberOfEmptyLines` can be an integer (default is 1) or
an array (e.g. [1, 2]) to specify a minimum and maximum
number of empty lines permitted.

`AllowAdjacentOneLineDefs` configures whether adjacent
one-line method definitions are considered an offense.
one-line definitions are considered an offense.

### Example:
### Example: EmptyLineBetweenMethodDefs: true (default)
# checks for empty lines between method definitions.

# bad
def a
Expand All @@ -23,4 +24,57 @@ one-line method definitions are considered an offense.
end

def b
end
end

### Example: EmptyLineBetweenClassDefs: true (default)
# checks for empty lines between class definitions.

# bad
class A
end
class B
end
def b
end

### Example:

# good
class A
end

class B
end

def b
end

### Example: EmptyLineBetweenModuleDefs: true (default)
# checks for empty lines between module definitions.

# bad
module A
end
module B
end
def b
end

### Example:

# good
module A
end

module B
end

def b
end

### Example: AllowAdjacentOneLineDefs: true

# good
class ErrorA < BaseError; end
class ErrorB < BaseError; end
class ErrorC < BaseError; end
2 changes: 2 additions & 0 deletions config/contents/layout/space_around_operators.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
Checks that operators have space around them, except for ** which
should or shouldn't have surrounding space depending on configuration.
It allows vertical alignment consisting of one or more whitespace
around operators.

This cop has `AllowForAlignment` option. When `true`, allows most
uses of extra spacing if the intent is to align with an operator on
Expand Down
14 changes: 14 additions & 0 deletions config/contents/layout/space_before_brackets.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Checks for space between the name of a receiver and a left
brackets.

This cop is marked as unsafe because it can occur false positives
for `do_something [this_is_an_array_literal_argument]` that take
an array without parentheses as an argument.

### Example:

# bad
collection [index_or_key]

# good
collection[index_or_key]
2 changes: 2 additions & 0 deletions config/contents/layout/space_inside_parens.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ Checks for spaces inside ordinary round parentheses.
# bad
f( 3)
g = (a + 3 )
f( )

# good
f(3)
g = (a + 3)
f()

### Example: EnforcedStyle: space
# The `space` style enforces that parentheses have a space at the
Expand Down
15 changes: 13 additions & 2 deletions config/contents/layout/trailing_whitespace.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,25 @@ This cop looks for trailing whitespace in the source code.
# good
x = 0

### Example: AllowInHeredoc: false
### Example: AllowInHeredoc: false (default)
# The line in this example contains spaces after the 0.
# bad
code = <<~RUBY
x = 0
RUBY

### Example: AllowInHeredoc: true (default)
# ok
code = <<~RUBY
x = 0 #{}
RUBY

# good
trailing_whitespace = ' '
code = <<~RUBY
x = 0#{trailing_whitespace}
RUBY

### Example: AllowInHeredoc: true
# The line in this example contains spaces after the 0.
# good
code = <<~RUBY
Expand Down
14 changes: 14 additions & 0 deletions config/contents/lint/ambiguous_assignment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
This cop checks for mistyped shorthand assignments.

### Example:
# bad
x =- y
x =+ y
x =* y
x =! y

# good
x -= y # or x = -y
x += y # or x = +y
x *= y # or x = *y
x != y # or x = !y
2 changes: 2 additions & 0 deletions config/contents/lint/ambiguous_block_association.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ when param passed without parentheses.

# good
# With parentheses, there's no ambiguity.
some_method(a { |val| puts val })
# or (different meaning)
some_method(a) { |val| puts val }

# good
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and thus can generate false positives:

### Example:
# bad
x / x
x.top >= x.top

if a.x != 0 && a.x != 0
Expand All @@ -21,3 +22,7 @@ and thus can generate false positives:
def childs?
left_child || left_child
end

# good
x + x
1 << 1
13 changes: 12 additions & 1 deletion config/contents/lint/constant_definition_in_block.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,15 @@ For meta-programming, use `const_set`.
included do
const_set(:LIST, [])
end
end
end

### Example: AllowedMethods: ['enums'] (default)
# good

# `enums` for Typed Enums via `T::Enum` in Sorbet.
# https://sorbet.org/docs/tenum
class TestEnum < T::Enum
enums do
Foo = new("foo")
end
end
1 change: 1 addition & 0 deletions config/contents/lint/debugger.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
This cop checks for calls to debugger or pry.
The cop can be configured to define which methods and receivers must be fixed.

### Example:

Expand Down
Loading