Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated channel and documentation to Rubocop v1.4.1 #263

Closed
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
10 changes: 6 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@ gem "activesupport", require: false
gem "mry", require: false
gem "parser"
gem "pry", require: false
gem "rubocop", "0.92.0", require: false
gem "rubocop-i18n", require: false
gem "rubocop-migrations", require: false
gem "rubocop", "1.4.1", require: false
gem "rubocop-i18n", require: false,
github: "mvz/rubocop-i18n", ref: "5e824a47a88732830a8b60e46697bbb0a2795c19"
Comment on lines +10 to +11
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
gem "rubocop-i18n", require: false,
github: "mvz/rubocop-i18n", ref: "5e824a47a88732830a8b60e46697bbb0a2795c19"
gem "rubocop-i18n", require: false

This change should be applied when puppetlabs/rubocop-i18n#46 is merged and released.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DanielWright wouldn't this PR be merged faster, if you stick to @mvz s branch for now?
I suggest to move this change into another pull request.

gem "rubocop-migrations", require: false,
github: "DanielWright/rubocop-migrations", branch: "dw/nov24/rubocop-1.x-support"
Comment on lines +12 to +13
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
gem "rubocop-migrations", require: false,
github: "DanielWright/rubocop-migrations", branch: "dw/nov24/rubocop-1.x-support"
gem "rubocop-migrations", require: false

This change should be applied when redbooth/rubocop-migrations#3 is merged and released.

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-sequel", "0.1.0", require: false
gem 'rubocop-sorbet', require: false
gem "rubocop-thread_safety", require: false
gem "safe_yaml"
Expand Down
46 changes: 29 additions & 17 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
GIT
remote: https://github.com/DanielWright/rubocop-migrations.git
revision: a4cb61a86a272b57e7fb3dcda238519c39f2ac70
branch: dw/nov24/rubocop-1.x-support
specs:
rubocop-migrations (0.1.2)
rubocop (~> 1.0)

GIT
remote: https://github.com/mvz/rubocop-i18n.git
revision: 5e824a47a88732830a8b60e46697bbb0a2795c19
ref: 5e824a47a88732830a8b60e46697bbb0a2795c19
specs:
rubocop-i18n (2.0.2)
rubocop (~> 1.0)

GEM
remote: https://rubygems.org/
specs:
Expand All @@ -17,16 +33,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 (2.7.2.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 (1.8.2)
rexml (3.2.4)
rspec (3.9.0)
rspec-core (~> 3.9.0)
Expand All @@ -41,21 +57,17 @@ GEM
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.9.0)
rspec-support (3.9.3)
rubocop (0.92.0)
rubocop (1.4.1)
parallel (~> 1.10)
parser (>= 2.7.1.5)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.7)
regexp_parser (>= 1.8)
rexml
rubocop-ast (>= 0.5.0)
rubocop-ast (>= 1.1.1)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 2.0)
rubocop-ast (0.7.1)
rubocop-ast (1.1.1)
parser (>= 2.7.1.5)
rubocop-i18n (2.0.2)
rubocop (~> 0.51)
rubocop-migrations (0.1.2)
rubocop (~> 0.41)
rubocop-minitest (0.9.0)
rubocop (>= 0.74)
rubocop-performance (1.7.0)
Expand All @@ -68,8 +80,8 @@ 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)
Expand All @@ -93,15 +105,15 @@ DEPENDENCIES
pry
rake
rspec
rubocop (= 0.92.0)
rubocop-i18n
rubocop-migrations
rubocop (= 1.4.1)
rubocop-i18n!
rubocop-migrations!
rubocop-minitest
rubocop-performance
rubocop-rails
rubocop-rake
rubocop-rspec
rubocop-sequel
rubocop-sequel (= 0.1.0)
rubocop-sorbet
rubocop-thread_safety
safe_yaml
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
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
49 changes: 48 additions & 1 deletion config/contents/layout/empty_line_between_defs.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ number of empty lines permitted.
`AllowAdjacentOneLineDefs` configures whether adjacent
one-line method definitions are considered an offense.

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

# bad
def a
Expand All @@ -22,5 +23,51 @@ one-line method definitions are considered an offense.
def a
end

def b
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
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
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
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
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
52 changes: 52 additions & 0 deletions config/contents/lint/duplicate_branch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
This cop checks that there are no repeated bodies
within `if/unless`, `case-when` and `rescue` constructs.

### Example:
# bad
if foo
do_foo
do_something_else
elsif bar
do_foo
do_something_else
end

# good
if foo || bar
do_foo
do_something_else
end

# bad
case x
when foo
do_foo
when bar
do_foo
else
do_something_else
end

# good
case x
when foo, bar
do_foo
else
do_something_else
end

# bad
begin
do_something
rescue FooError
handle_error
rescue BarError
handle_error
end

# good
begin
do_something
rescue FooError, BarError
handle_error
end
15 changes: 15 additions & 0 deletions config/contents/lint/duplicate_regexp_character_class_element.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
This cop checks for duplicate elements in Regexp character classes.

### Example:

# bad
r = /[xyx]/

# bad
r = /[0-9x0-9]/

# good
r = /[xy]/

# good
r = /[0-9x]/
17 changes: 15 additions & 2 deletions config/contents/lint/else_layout.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
This cop checks for odd else block layout - like
having an expression on the same line as the else keyword,
This cop checks for odd `else` block layout - like
having an expression on the same line as the `else` keyword,
which is usually a mistake.

Its auto-correction tweaks layout to keep the syntax. So, this auto-correction
is compatible correction for bad case syntax, but if your code makes a mistake
with `elsif` and `else`, you will have to correct it manually.

### Example:

# bad
Expand All @@ -16,9 +20,18 @@ which is usually a mistake.

# good

# This code is compatible with the bad case. It will be auto-corrected like this.
if something
# ...
else
do_this
do_that
end

# This code is incompatible with the bad case.
# If `do_this` is a condition, `elsif` should be used instead of `else`.
if something
# ...
elsif do_this
do_that
end
Loading