Skip to content

Commit 83f9ca7

Browse files
authored
Update rubocop (#2003)
1 parent 0022804 commit 83f9ca7

14 files changed

+294
-56
lines changed

.rubocop.yml

+11-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1+
require:
2+
- rubocop-performance
3+
14
AllCops:
25
TargetRubyVersion: 2.4
3-
Include:
4-
- Dangerfile
5-
- gemfiles/*.gemfile
6-
76
Exclude:
87
- vendor/**/*
98
- bin/**/*
@@ -19,8 +18,14 @@ Style/MultilineIfModifier:
1918
Style/RaiseArgs:
2019
Enabled: false
2120

22-
Lint/UnneededDisable:
23-
Enabled: false
21+
Style/HashEachMethods:
22+
Enabled: true
23+
24+
Style/HashTransformKeys:
25+
Enabled: true
26+
27+
Style/HashTransformValues:
28+
Enabled: true
2429

2530
Metrics/BlockLength:
2631
Exclude:

.rubocop_todo.yml

+189-37
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,42 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2019-12-09 18:07:42 +0100 using RuboCop version 0.51.0.
3+
# on 2020-03-02 11:38:28 +0100 using RuboCop version 0.80.1.
44
# The point is for the user to remove these configuration records
55
# one by one as the offenses are removed from the code base.
66
# Note that changes in the inspected code, or installation of new
77
# versions of RuboCop, may require this file to be generated again.
88

9+
# Offense count: 6
10+
# Cop supports --auto-correct.
11+
Layout/ClosingHeredocIndentation:
12+
Exclude:
13+
- 'spec/grape/api_spec.rb'
14+
- 'spec/grape/entity_spec.rb'
15+
16+
# Offense count: 72
17+
# Cop supports --auto-correct.
18+
Layout/EmptyLineAfterGuardClause:
19+
Enabled: false
20+
21+
# Offense count: 27
22+
# Cop supports --auto-correct.
23+
# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
24+
# SupportedHashRocketStyles: key, separator, table
25+
# SupportedColonStyles: key, separator, table
26+
# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
27+
Layout/HashAlignment:
28+
Exclude:
29+
- 'grape.gemspec'
30+
- 'lib/grape/validations/params_scope.rb'
31+
- 'lib/grape/validations/types/primitive_coercer.rb'
32+
- 'spec/grape/api_spec.rb'
33+
- 'spec/grape/entity_spec.rb'
34+
935
# Offense count: 7
1036
# Cop supports --auto-correct.
11-
# Configuration parameters: EnforcedStyle, SupportedStyles.
12-
# SupportedStyles: auto_detection, squiggly, active_support, powerpack, unindent
13-
Layout/IndentHeredoc:
37+
# Configuration parameters: EnforcedStyle.
38+
# SupportedStyles: squiggly, active_support, powerpack, unindent
39+
Layout/HeredocIndentation:
1440
Exclude:
1541
- 'lib/grape/router/route.rb'
1642
- 'spec/grape/api_spec.rb'
@@ -21,23 +47,45 @@ Lint/AmbiguousBlockAssociation:
2147
Exclude:
2248
- 'spec/grape/dsl/routing_spec.rb'
2349

50+
# Offense count: 4
51+
Lint/DisjunctiveAssignmentInConstructor:
52+
Exclude:
53+
- 'lib/grape/namespace.rb'
54+
- 'lib/grape/path.rb'
55+
- 'lib/grape/router.rb'
56+
- 'lib/grape/router/pattern.rb'
57+
2458
# Offense count: 1
25-
Lint/RescueWithoutErrorClass:
59+
# Cop supports --auto-correct.
60+
Lint/NonDeterministicRequireOrder:
2661
Exclude:
27-
- 'lib/grape/validations/validators/coerce.rb'
62+
- 'spec/spec_helper.rb'
63+
64+
# Offense count: 1
65+
# Cop supports --auto-correct.
66+
Lint/RedundantCopDisableDirective:
67+
Exclude:
68+
- 'lib/grape/router/attribute_translator.rb'
2869

2970
# Offense count: 1
3071
# Cop supports --auto-correct.
31-
Lint/UnneededRequireStatement:
72+
Lint/RedundantRequireStatement:
3273
Exclude:
3374
- 'lib/grape.rb'
3475

35-
# Offense count: 46
76+
# Offense count: 2
77+
# Cop supports --auto-correct.
78+
Lint/ToJSON:
79+
Exclude:
80+
- 'spec/grape/middleware/formatter_spec.rb'
81+
82+
# Offense count: 48
3683
Metrics/AbcSize:
37-
Max: 44
84+
Max: 43
3885

39-
# Offense count: 7
86+
# Offense count: 6
4087
# Configuration parameters: CountComments, ExcludedMethods.
88+
# ExcludedMethods: refine
4189
Metrics/BlockLength:
4290
Max: 182
4391

@@ -46,18 +94,12 @@ Metrics/BlockLength:
4694
Metrics/ClassLength:
4795
Max: 305
4896

49-
# Offense count: 30
97+
# Offense count: 32
5098
Metrics/CyclomaticComplexity:
5199
Max: 14
52100

53-
# Offense count: 1300
54-
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
55-
# URISchemes: http, https
56-
Metrics/LineLength:
57-
Max: 215
58-
59-
# Offense count: 60
60-
# Configuration parameters: CountComments.
101+
# Offense count: 61
102+
# Configuration parameters: CountComments, ExcludedMethods.
61103
Metrics/MethodLength:
62104
Max: 33
63105

@@ -66,54 +108,164 @@ Metrics/MethodLength:
66108
Metrics/ModuleLength:
67109
Max: 220
68110

69-
# Offense count: 22
111+
# Offense count: 25
70112
Metrics/PerceivedComplexity:
71113
Max: 14
72114

73-
# Offense count: 4
74-
# Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts, AllowedAcronyms.
75-
# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
76-
Naming/FileName:
115+
# Offense count: 3
116+
# Configuration parameters: EnforcedStyleForLeadingUnderscores.
117+
# SupportedStylesForLeadingUnderscores: disallowed, required, optional
118+
Naming/MemoizedInstanceVariableName:
119+
Exclude:
120+
- 'lib/grape/api/instance.rb'
121+
- 'lib/grape/middleware/base.rb'
122+
- 'spec/grape/integration/rack_spec.rb'
123+
124+
# Offense count: 5
125+
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
126+
# AllowedNames: io, id, to, by, on, in, at, ip, db, os, pp
127+
Naming/MethodParameterName:
128+
Exclude:
129+
- 'lib/grape/endpoint.rb'
130+
- 'lib/grape/middleware/error.rb'
131+
- 'lib/grape/middleware/stack.rb'
132+
- 'spec/grape/api_spec.rb'
133+
134+
# Offense count: 1
135+
# Cop supports --auto-correct.
136+
# Configuration parameters: PreferredName.
137+
Naming/RescuedExceptionsVariableName:
138+
Exclude:
139+
- 'lib/grape/middleware/error.rb'
140+
141+
# Offense count: 3
142+
# Cop supports --auto-correct.
143+
Performance/InefficientHashSearch:
77144
Exclude:
78-
- 'Appraisals'
79-
- 'Gemfile'
80-
- 'Guardfile'
81-
- 'Rakefile'
145+
- 'spec/grape/validations/validators/values_spec.rb'
82146

83147
# Offense count: 1
84148
# Cop supports --auto-correct.
85149
Performance/RegexpMatch:
86150
Exclude:
87151
- 'lib/grape/middleware/versioner/path.rb'
88152

153+
# Offense count: 5
154+
# Cop supports --auto-correct.
155+
Style/EmptyLambdaParameter:
156+
Exclude:
157+
- 'spec/grape/dsl/callbacks_spec.rb'
158+
- 'spec/grape/dsl/middleware_spec.rb'
159+
- 'spec/grape/dsl/routing_spec.rb'
160+
- 'spec/grape/middleware/auth/dsl_spec.rb'
161+
- 'spec/grape/middleware/stack_spec.rb'
162+
163+
# Offense count: 3
164+
# Cop supports --auto-correct.
165+
Style/ExpandPathArguments:
166+
Exclude:
167+
- 'grape.gemspec'
168+
- 'lib/grape.rb'
169+
- 'spec/grape/validations/validators/coerce_spec.rb'
170+
89171
# Offense count: 2
90-
# Configuration parameters: SupportedStyles.
91-
# SupportedStyles: annotated, template
172+
# Configuration parameters: .
173+
# SupportedStyles: annotated, template, unannotated
92174
Style/FormatStringToken:
93175
EnforcedStyle: template
94176

95177
# Offense count: 1
96178
# Cop supports --auto-correct.
97-
# Configuration parameters: AutoCorrect, EnforcedStyle, SupportedStyles.
179+
Style/HashTransformValues:
180+
Exclude:
181+
- 'lib/grape/api.rb'
182+
183+
# Offense count: 23
184+
# Cop supports --auto-correct.
185+
Style/IfUnlessModifier:
186+
Exclude:
187+
- 'lib/grape/api/instance.rb'
188+
- 'lib/grape/dsl/desc.rb'
189+
- 'lib/grape/dsl/request_response.rb'
190+
- 'lib/grape/dsl/routing.rb'
191+
- 'lib/grape/dsl/settings.rb'
192+
- 'lib/grape/endpoint.rb'
193+
- 'lib/grape/error_formatter/json.rb'
194+
- 'lib/grape/error_formatter/xml.rb'
195+
- 'lib/grape/middleware/error.rb'
196+
- 'lib/grape/middleware/formatter.rb'
197+
- 'lib/grape/middleware/versioner/accept_version_header.rb'
198+
- 'lib/grape/validations/params_scope.rb'
199+
- 'lib/grape/validations/validators/base.rb'
200+
- 'lib/grape/validations/validators/default.rb'
201+
- 'spec/support/versioned_helpers.rb'
202+
203+
# Offense count: 1
204+
Style/MethodMissingSuper:
205+
Exclude:
206+
- 'lib/grape/router/attribute_translator.rb'
207+
208+
# Offense count: 5
209+
# Cop supports --auto-correct.
210+
# Configuration parameters: EnforcedStyle.
211+
# SupportedStyles: literals, strict
212+
Style/MutableConstant:
213+
Exclude:
214+
- 'lib/grape/middleware/versioner/header.rb'
215+
- 'lib/grape/router/route.rb'
216+
217+
# Offense count: 1
218+
# Cop supports --auto-correct.
219+
# Configuration parameters: AutoCorrect, EnforcedStyle, IgnoredMethods.
98220
# SupportedStyles: predicate, comparison
99221
Style/NumericPredicate:
100222
Exclude:
101223
- 'spec/**/*'
102224
- 'lib/grape/middleware/formatter.rb'
103225

104-
# Offense count: 12
226+
# Offense count: 1
227+
# Cop supports --auto-correct.
228+
# Configuration parameters: EnforcedStyle.
229+
# SupportedStyles: implicit, explicit
230+
Style/RescueStandardError:
231+
Exclude:
232+
- 'lib/grape/validations/validators/coerce.rb'
233+
234+
# Offense count: 11
105235
# Cop supports --auto-correct.
106-
# Configuration parameters: ConvertCodeThatCanStartToReturnNil.
236+
# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods.
237+
# AllowedMethods: present?, blank?, presence, try, try!
107238
Style/SafeNavigation:
108239
Exclude:
109240
- 'lib/grape/api/instance.rb'
110241
- 'lib/grape/dsl/desc.rb'
111-
- 'lib/grape/dsl/helpers.rb'
112242
- 'lib/grape/dsl/inside_route.rb'
113-
- 'lib/grape/dsl/routing.rb'
243+
- 'lib/grape/dsl/request_response.rb'
114244
- 'lib/grape/endpoint.rb'
115245
- 'lib/grape/middleware/error.rb'
116246
- 'lib/grape/middleware/versioner/accept_version_header.rb'
117247
- 'lib/grape/middleware/versioner/header.rb'
118-
- 'lib/grape/middleware/versioner/param.rb'
119-
- 'lib/grape/middleware/versioner/path.rb'
248+
249+
# Offense count: 2
250+
# Cop supports --auto-correct.
251+
# Configuration parameters: EnforcedStyleForMultiline.
252+
# SupportedStylesForMultiline: comma, consistent_comma, no_comma
253+
Style/TrailingCommaInHashLiteral:
254+
Exclude:
255+
- 'lib/grape/middleware/error.rb'
256+
257+
# Offense count: 10
258+
# Cop supports --auto-correct.
259+
# Configuration parameters: EnforcedStyle, MinSize, WordRegex.
260+
# SupportedStyles: percent, brackets
261+
Style/WordArray:
262+
Exclude:
263+
- 'spec/grape/validations/validators/except_values_spec.rb'
264+
- 'spec/grape/validations/validators/values_spec.rb'
265+
266+
# Offense count: 1314
267+
# Cop supports --auto-correct.
268+
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
269+
# URISchemes: http, https
270+
Layout/LineLength:
271+
Max: 215

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ matrix:
1616
- rvm: 2.7.0
1717
gemfile: gemfiles/rack1.gemfile
1818
- rvm: 2.7.0
19-
gemfile: gemfiles/rack2-0.gemfile
19+
gemfile: gemfiles/rack2.gemfile
2020
- rvm: 2.7.0
2121
gemfile: gemfiles/rack_edge.gemfile
2222
- rvm: 2.7.0

Appraisals

+8
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,11 @@ end
1919
appraise 'multi_xml' do
2020
gem 'multi_xml', require: 'multi_xml'
2121
end
22+
23+
appraise 'rack1' do
24+
gem 'rack', '~> 1.0'
25+
end
26+
27+
appraise 'rack2' do
28+
gem 'rack', '~> 2.0'
29+
end

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#### Features
44

55
* Your contribution here.
6+
* [#2003](https://github.com/ruby-grape/grape/pull/2003): Upgraded Rubocop to 0.80.1 - [@ericproulx](https://github.com/ericproulx).
67
* [#2002](https://github.com/ruby-grape/grape/pull/2002): Objects allocation optimization (lazy_lookup) - [@ericproulx](https://github.com/ericproulx).
78

89
#### Fixes

Gemfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ group :development, :test do
1010
gem 'bundler'
1111
gem 'hashie'
1212
gem 'rake'
13-
gem 'rubocop', '0.51.0'
13+
gem 'rubocop', '0.80.1'
14+
gem 'rubocop-performance', require: false
1415
end
1516

1617
group :development do

gemfiles/multi_json.gemfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ group :development, :test do
1010
gem 'bundler'
1111
gem 'hashie'
1212
gem 'rake'
13-
gem 'rubocop', '0.51.0'
13+
gem 'rubocop', '0.80.1'
14+
gem 'rubocop-performance', require: false
1415
end
1516

1617
group :development do

gemfiles/multi_xml.gemfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ group :development, :test do
1010
gem 'bundler'
1111
gem 'hashie'
1212
gem 'rake'
13-
gem 'rubocop', '0.51.0'
13+
gem 'rubocop', '0.80.1'
14+
gem 'rubocop-performance', require: false
1415
end
1516

1617
group :development do

0 commit comments

Comments
 (0)