Skip to content

Commit b7173a4

Browse files
authored
Merge pull request #790 from deivid-rodriguez/bump-rubocop
Upgrade RuboCop, fix config and offenses, and run it in CI
2 parents d092549 + 39d16cb commit b7173a4

File tree

18 files changed

+76
-61
lines changed

18 files changed

+76
-61
lines changed

.github/workflows/lint.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: Run linters
2+
on: [push, pull_request]
3+
jobs:
4+
test:
5+
runs-on: ubuntu-latest
6+
env:
7+
BUNDLE_GEMFILE: lint_gems.rb
8+
steps:
9+
- uses: actions/checkout@v2
10+
- uses: ruby/setup-ruby@v1
11+
with:
12+
ruby-version: 3.1
13+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
14+
- run: bundle exec rubocop

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
.yardoc
2222
Desktop.ini
2323
Gemfile.lock
24+
lint_gems.rb.lock
2425
Icon?
2526
InstalledFiles
2627
Session.vim

.rubocop.yml

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,49 +6,50 @@ AllCops:
66
Exclude:
77
- spec/sandbox/**/*
88
- spec/fixtures/**/*
9+
- vendor/bundle/**/**
910

1011
# Enforce Ruby 1.8-compatible hash syntax
11-
HashSyntax:
12+
Style/HashSyntax:
1213
EnforcedStyle: hash_rockets
1314

1415
# No spaces inside hash literals
15-
SpaceInsideHashLiteralBraces:
16+
Layout/SpaceInsideHashLiteralBraces:
1617
EnforcedStyle: no_space
1718

1819
# Enforce outdenting of access modifiers (i.e. public, private, protected)
19-
AccessModifierIndentation:
20+
Layout/AccessModifierIndentation:
2021
EnforcedStyle: outdent
2122

22-
EmptyLinesAroundAccessModifier:
23+
Layout/EmptyLinesAroundAccessModifier:
2324
Enabled: true
2425

2526
# Align ends correctly
26-
EndAlignment:
27+
Layout/EndAlignment:
2728
EnforcedStyleAlignWith: variable
29+
Exclude:
30+
- 'lib/thor/actions.rb'
31+
- 'lib/thor/error.rb'
32+
- 'lib/thor/shell/basic.rb'
33+
- 'lib/thor/parser/option.rb'
2834

2935
# Indentation of when/else
30-
CaseIndentation:
36+
Layout/CaseIndentation:
3137
EnforcedStyle: end
3238
IndentOneStep: false
3339

34-
StringLiterals:
40+
Style/StringLiterals:
3541
EnforcedStyle: double_quotes
3642

3743
Lint/AssignmentInCondition:
3844
Exclude:
3945
- 'lib/thor/line_editor/readline.rb'
4046
- 'lib/thor/parser/arguments.rb'
4147

42-
Lint/EndAlignment:
43-
Exclude:
44-
- 'lib/thor/actions.rb'
45-
- 'lib/thor/parser/option.rb'
46-
4748
Security/Eval:
4849
Exclude:
4950
- 'spec/helper.rb'
5051

51-
Lint/HandleExceptions:
52+
Lint/SuppressedException:
5253
Exclude:
5354
- 'lib/thor/line_editor/readline.rb'
5455

@@ -99,10 +100,15 @@ Style/GlobalVars:
99100
- 'spec/register_spec.rb'
100101
- 'spec/thor_spec.rb'
101102

102-
Layout/IndentArray:
103+
Layout/FirstArrayElementIndentation:
103104
EnforcedStyle: consistent
104105

105-
Style/MethodMissing:
106+
Lint/MissingSuper:
107+
Exclude:
108+
- 'lib/thor/error.rb'
109+
- 'spec/rake_compat_spec.rb'
110+
111+
Style/MissingRespondToMissing:
106112
Exclude:
107113
- 'lib/thor/core_ext/hash_with_indifferent_access.rb'
108114
- 'lib/thor/runner.rb'

.rubocop_todo.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,6 @@ Layout/SpaceInsideHashLiteralBraces:
2525
- 'spec/actions_spec.rb'
2626
- 'spec/command_spec.rb'
2727

28-
# Offense count: 1
29-
# Cop supports --auto-correct.
30-
# Configuration parameters: EnforcedStyleAlignWith, SupportedStylesAlignWith, AutoCorrect.
31-
# SupportedStylesAlignWith: keyword, variable, start_of_line
32-
Lint/EndAlignment:
33-
Exclude:
34-
- 'lib/thor/error.rb'
35-
3628
# Offense count: 65
3729
# Cop supports --auto-correct.
3830
# Configuration parameters: EnforcedStyle, SupportedStyles, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.

Gemfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@ end
99

1010
group :test do
1111
gem "childlabor"
12-
gem 'coveralls_reborn', '~> 0.23.1', require: false if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.6.0")
12+
gem 'coveralls_reborn', '~> 0.23.1', :require => false if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.6.0")
1313
gem "rspec", ">= 3.2"
1414
gem "rspec-mocks", ">= 3"
15-
gem "rubocop", "~> 0.50.0"
1615
gem "simplecov", ">= 0.13"
1716
gem "webmock"
1817
end

lib/thor.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ def disable_required_check #:nodoc:
356356
end
357357

358358
# The method responsible for dispatching given the args.
359-
def dispatch(meth, given_args, given_opts, config) #:nodoc: # rubocop:disable MethodLength
359+
def dispatch(meth, given_args, given_opts, config) #:nodoc:
360360
meth ||= retrieve_command_name(given_args)
361361
command = all_commands[normalize_command_name(meth)]
362362

lib/thor/base.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ def build_options(options, scope) #:nodoc:
610610
def find_and_refresh_command(name) #:nodoc:
611611
if commands[name.to_s]
612612
commands[name.to_s]
613-
elsif command = all_commands[name.to_s] # rubocop:disable AssignmentInCondition
613+
elsif command = all_commands[name.to_s] # rubocop:disable Lint/AssignmentInCondition
614614
commands[name.to_s] = command.clone
615615
else
616616
raise ArgumentError, "You supplied :for => #{name.inspect}, but the command #{name.inspect} could not be found."

lib/thor/group.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ def class_options_help(shell, groups = {}) #:nodoc:
169169
# options are added to group_options hash. Options that already exists
170170
# in base_options are not added twice.
171171
#
172-
def get_options_from_invocations(group_options, base_options) #:nodoc: # rubocop:disable MethodLength
172+
def get_options_from_invocations(group_options, base_options) #:nodoc:
173173
invocations.each do |name, from_option|
174174
value = if from_option
175175
option = class_options[name]

lib/thor/parser/arguments.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
class Thor
2-
class Arguments #:nodoc: # rubocop:disable ClassLength
2+
class Arguments #:nodoc:
33
NUMERIC = /[-+]?(\d*\.\d+|\d+)/
44

55
# Receives an array of args and returns two arrays, one with arguments

lib/thor/parser/option.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def self.parse(key, value)
5858
default = nil
5959
if VALID_TYPES.include?(value)
6060
value
61-
elsif required = (value == :required) # rubocop:disable AssignmentInCondition
61+
elsif required = (value == :required) # rubocop:disable Lint/AssignmentInCondition
6262
:string
6363
end
6464
when TrueClass, FalseClass

0 commit comments

Comments
 (0)