Skip to content

Commit 783fa59

Browse files
authored
Adding rubocop-rspec (#2203)
* Update rubocop gems Add rubocop-rspec Regenerate autoconfig * Add CHANGELOG entry * Add back rack2_2.gemfile * Fix all RSpec/DescribedClass
1 parent 4c19f3f commit 783fa59

File tree

76 files changed

+1282
-787
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+1282
-787
lines changed

.rubocop.yml

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ AllCops:
88

99
require:
1010
- rubocop-performance
11+
- rubocop-rspec
1112

1213
inherit_from: .rubocop_todo.yml
1314

@@ -32,3 +33,6 @@ Style/HashTransformValues:
3233
Metrics/BlockLength:
3334
Exclude:
3435
- spec/**/*_spec.rb
36+
37+
RSpec/Capybara/FeatureMethods:
38+
Enabled: false

.rubocop_todo.yml

+209-6
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,26 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2021-09-26 08:03:47 UTC using RuboCop version 1.21.0.
3+
# on 2021-12-05 16:55:50 UTC using RuboCop version 1.23.0.
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: 1
10+
# Cop supports --auto-correct.
11+
# Configuration parameters: Include.
12+
# Include: **/*.gemspec
13+
Gemspec/RequireMFA:
14+
Exclude:
15+
- 'grape.gemspec'
16+
917
# Offense count: 1
1018
# Configuration parameters: IgnoredMethods.
1119
Lint/AmbiguousBlockAssociation:
1220
Exclude:
1321
- 'spec/grape/dsl/routing_spec.rb'
1422

15-
# Offense count: 56
23+
# Offense count: 41
1624
# Configuration parameters: AllowedMethods.
1725
# AllowedMethods: enums
1826
Lint/ConstantDefinitionInBlock:
@@ -61,17 +69,17 @@ Metrics/AbcSize:
6169
Metrics/BlockLength:
6270
Max: 182
6371

64-
# Offense count: 11
72+
# Offense count: 9
6573
# Configuration parameters: CountComments, CountAsOne.
6674
Metrics/ClassLength:
67-
Max: 310
75+
Max: 298
6876

6977
# Offense count: 30
7078
# Configuration parameters: IgnoredMethods.
7179
Metrics/CyclomaticComplexity:
7280
Max: 15
7381

74-
# Offense count: 71
82+
# Offense count: 68
7583
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
7684
Metrics/MethodLength:
7785
Max: 32
@@ -133,6 +141,201 @@ Performance/MethodObjectAsBlock:
133141
Exclude:
134142
- 'lib/grape/middleware/stack.rb'
135143

144+
# Offense count: 4
145+
RSpec/AnyInstance:
146+
Exclude:
147+
- 'spec/grape/api_spec.rb'
148+
- 'spec/grape/middleware/base_spec.rb'
149+
150+
# Offense count: 332
151+
# Configuration parameters: Prefixes.
152+
# Prefixes: when, with, without
153+
RSpec/ContextWording:
154+
Enabled: false
155+
156+
# Offense count: 3
157+
# Configuration parameters: IgnoredMetadata.
158+
RSpec/DescribeClass:
159+
Exclude:
160+
- '**/spec/features/**/*'
161+
- '**/spec/requests/**/*'
162+
- '**/spec/routing/**/*'
163+
- '**/spec/system/**/*'
164+
- '**/spec/views/**/*'
165+
- 'spec/grape/config_spec.rb'
166+
- 'spec/grape/named_api_spec.rb'
167+
- 'spec/grape/validations/instance_behaivour_spec.rb'
168+
169+
# Offense count: 3
170+
RSpec/EmptyExampleGroup:
171+
Exclude:
172+
- 'spec/grape/api_spec.rb'
173+
- 'spec/grape/dsl/configuration_spec.rb'
174+
- 'spec/grape/validations/attributes_iterator_spec.rb'
175+
176+
# Offense count: 1
177+
# Cop supports --auto-correct.
178+
RSpec/EmptyLineAfterSubject:
179+
Exclude:
180+
- 'spec/grape/dsl/logger_spec.rb'
181+
182+
# Offense count: 500
183+
# Configuration parameters: CountAsOne.
184+
RSpec/ExampleLength:
185+
Max: 57
186+
187+
# Offense count: 7
188+
# Cop supports --auto-correct.
189+
RSpec/ExpectActual:
190+
Exclude:
191+
- 'spec/routing/**/*'
192+
- 'spec/grape/endpoint/declared_spec.rb'
193+
- 'spec/grape/middleware/exception_spec.rb'
194+
195+
# Offense count: 3
196+
RSpec/ExpectInHook:
197+
Exclude:
198+
- 'spec/grape/api_spec.rb'
199+
- 'spec/grape/validations/validators/values_spec.rb'
200+
201+
# Offense count: 41
202+
# Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly.
203+
# Include: **/*_spec*rb*, **/spec/**/*
204+
RSpec/FilePath:
205+
Enabled: false
206+
207+
# Offense count: 2
208+
RSpec/IdenticalEqualityAssertion:
209+
Exclude:
210+
- 'spec/grape/middleware/base_spec.rb'
211+
212+
# Offense count: 38
213+
# Configuration parameters: AssignmentOnly.
214+
RSpec/InstanceVariable:
215+
Exclude:
216+
- 'spec/grape/api_spec.rb'
217+
- 'spec/grape/endpoint_spec.rb'
218+
- 'spec/grape/middleware/base_spec.rb'
219+
- 'spec/grape/middleware/versioner/accept_version_header_spec.rb'
220+
- 'spec/grape/middleware/versioner/header_spec.rb'
221+
- 'spec/grape/validations/validators/except_values_spec.rb'
222+
223+
# Offense count: 4
224+
RSpec/IteratedExpectation:
225+
Exclude:
226+
- 'spec/grape/middleware/formatter_spec.rb'
227+
228+
# Offense count: 90
229+
RSpec/LeakyConstantDeclaration:
230+
Enabled: false
231+
232+
# Offense count: 1
233+
RSpec/LetSetup:
234+
Exclude:
235+
- 'spec/grape/integration/rack_spec.rb'
236+
237+
# Offense count: 2
238+
RSpec/MessageChain:
239+
Exclude:
240+
- 'spec/grape/middleware/formatter_spec.rb'
241+
242+
# Offense count: 137
243+
# Configuration parameters: .
244+
# SupportedStyles: have_received, receive
245+
RSpec/MessageSpies:
246+
EnforcedStyle: receive
247+
248+
# Offense count: 12
249+
RSpec/MissingExampleGroupArgument:
250+
Exclude:
251+
- 'spec/grape/middleware/exception_spec.rb'
252+
253+
# Offense count: 755
254+
RSpec/MultipleExpectations:
255+
Max: 16
256+
257+
# Offense count: 11
258+
# Configuration parameters: AllowSubject.
259+
RSpec/MultipleMemoizedHelpers:
260+
Max: 10
261+
262+
# Offense count: 2118
263+
# Configuration parameters: IgnoreSharedExamples.
264+
RSpec/NamedSubject:
265+
Enabled: false
266+
267+
# Offense count: 157
268+
RSpec/NestedGroups:
269+
Max: 6
270+
271+
# Offense count: 12
272+
RSpec/RepeatedDescription:
273+
Exclude:
274+
- 'spec/grape/api_spec.rb'
275+
- 'spec/grape/endpoint_spec.rb'
276+
- 'spec/grape/validations/validators/allow_blank_spec.rb'
277+
- 'spec/grape/validations/validators/values_spec.rb'
278+
279+
# Offense count: 10
280+
RSpec/RepeatedExample:
281+
Exclude:
282+
- 'spec/grape/api_spec.rb'
283+
- 'spec/grape/dsl/request_response_spec.rb'
284+
- 'spec/grape/middleware/versioner/accept_version_header_spec.rb'
285+
- 'spec/grape/validations/validators/allow_blank_spec.rb'
286+
287+
# Offense count: 10
288+
RSpec/RepeatedExampleGroupDescription:
289+
Exclude:
290+
- 'spec/grape/api_spec.rb'
291+
- 'spec/grape/endpoint_spec.rb'
292+
- 'spec/grape/util/inheritable_setting_spec.rb'
293+
- 'spec/grape/validations/validators/values_spec.rb'
294+
295+
# Offense count: 6
296+
RSpec/ScatteredSetup:
297+
Exclude:
298+
- 'spec/grape/util/inheritable_setting_spec.rb'
299+
- 'spec/grape/validations_spec.rb'
300+
301+
# Offense count: 9
302+
RSpec/StubbedMock:
303+
Exclude:
304+
- 'spec/grape/api_spec.rb'
305+
- 'spec/grape/dsl/inside_route_spec.rb'
306+
- 'spec/grape/dsl/routing_spec.rb'
307+
- 'spec/grape/middleware/formatter_spec.rb'
308+
- 'spec/grape/parser_spec.rb'
309+
310+
# Offense count: 29
311+
RSpec/SubjectStub:
312+
Exclude:
313+
- 'spec/grape/api_spec.rb'
314+
- 'spec/grape/dsl/inside_route_spec.rb'
315+
- 'spec/grape/middleware/base_spec.rb'
316+
- 'spec/grape/middleware/formatter_spec.rb'
317+
- 'spec/grape/middleware/globals_spec.rb'
318+
- 'spec/grape/middleware/stack_spec.rb'
319+
- 'spec/grape/parser_spec.rb'
320+
321+
# Offense count: 25
322+
# Configuration parameters: IgnoreNameless, IgnoreSymbolicNames.
323+
RSpec/VerifiedDoubles:
324+
Exclude:
325+
- 'spec/grape/api_spec.rb'
326+
- 'spec/grape/dsl/inside_route_spec.rb'
327+
- 'spec/grape/dsl/logger_spec.rb'
328+
- 'spec/grape/integration/rack_sendfile_spec.rb'
329+
- 'spec/grape/middleware/formatter_spec.rb'
330+
- 'spec/grape/validations/multiple_attributes_iterator_spec.rb'
331+
- 'spec/grape/validations/single_attribute_iterator_spec.rb'
332+
333+
# Offense count: 2
334+
RSpec/VoidExpect:
335+
Exclude:
336+
- 'spec/grape/api_spec.rb'
337+
- 'spec/grape/dsl/headers_spec.rb'
338+
136339
# Offense count: 1
137340
Style/CombinableLoops:
138341
Exclude:
@@ -161,7 +364,7 @@ Style/OptionalBooleanParameter:
161364
- 'lib/grape/validations/types/primitive_coercer.rb'
162365
- 'lib/grape/validations/types/set_coercer.rb'
163366

164-
# Offense count: 132
367+
# Offense count: 146
165368
# Cop supports --auto-correct.
166369
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
167370
# URISchemes: http, https

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
* [#2192](https://github.com/ruby-grape/grape/pull/2192): Memoize the result of Grape::Middleware::Base#response - [@Jack12816](https://github.com/Jack12816).
1212
* [#2200](https://github.com/ruby-grape/grape/pull/2200): Add validators module to all validators - [@ericproulx](https://github.com/ericproulx).
1313
* [#2202](https://github.com/ruby-grape/grape/pull/2202): Fix random mock spec error - [@ericproulx](https://github.com/ericproulx).
14+
* [#2203](https://github.com/ruby-grape/grape/pull/2203): Add rubocop-rspec - [@ericproulx](https://github.com/ericproulx).
1415
* Your contribution here.
1516

1617
### 1.6.0 (2021/10/04)

Gemfile

+4-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ group :development, :test do
1010
gem 'bundler'
1111
gem 'hashie'
1212
gem 'rake'
13-
gem 'rubocop', '~> 1.21.0'
14-
gem 'rubocop-ast', '~> 1.11.0'
15-
gem 'rubocop-performance', '~> 1.11.5', require: false
13+
gem 'rubocop', '~> 1.23.0'
14+
gem 'rubocop-ast', '~> 1.14.0'
15+
gem 'rubocop-performance', require: false
16+
gem 'rubocop-rspec', require: false
1617
end
1718

1819
group :development do

gemfiles/multi_json.gemfile

+8-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ group :development, :test do
1010
gem 'bundler'
1111
gem 'hashie'
1212
gem 'rake'
13-
gem 'rubocop', '1.7.0'
14-
gem 'rubocop-ast', '1.3.0'
15-
gem 'rubocop-performance', '1.9.1', require: false
13+
gem 'rubocop', '~> 1.23.0'
14+
gem 'rubocop-ast', '~> 1.14.0'
15+
gem 'rubocop-performance', require: false
16+
gem 'rubocop-rspec', require: false
1617
end
1718

1819
group :development do
@@ -37,4 +38,8 @@ group :test do
3738
gem 'test-prof', require: false
3839
end
3940

41+
platforms :jruby do
42+
gem 'racc'
43+
end
44+
4045
gemspec path: '../'

gemfiles/multi_xml.gemfile

+8-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ group :development, :test do
1010
gem 'bundler'
1111
gem 'hashie'
1212
gem 'rake'
13-
gem 'rubocop', '1.7.0'
14-
gem 'rubocop-ast', '1.3.0'
15-
gem 'rubocop-performance', '1.9.1', require: false
13+
gem 'rubocop', '~> 1.23.0'
14+
gem 'rubocop-ast', '~> 1.14.0'
15+
gem 'rubocop-performance', require: false
16+
gem 'rubocop-rspec', require: false
1617
end
1718

1819
group :development do
@@ -37,4 +38,8 @@ group :test do
3738
gem 'test-prof', require: false
3839
end
3940

41+
platforms :jruby do
42+
gem 'racc'
43+
end
44+
4045
gemspec path: '../'

gemfiles/rack1.gemfile

+8-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ group :development, :test do
1010
gem 'bundler'
1111
gem 'hashie'
1212
gem 'rake'
13-
gem 'rubocop', '1.7.0'
14-
gem 'rubocop-ast', '1.3.0'
15-
gem 'rubocop-performance', '1.9.1', require: false
13+
gem 'rubocop', '~> 1.23.0'
14+
gem 'rubocop-ast', '~> 1.14.0'
15+
gem 'rubocop-performance', require: false
16+
gem 'rubocop-rspec', require: false
1617
end
1718

1819
group :development do
@@ -37,4 +38,8 @@ group :test do
3738
gem 'test-prof', require: false
3839
end
3940

41+
platforms :jruby do
42+
gem 'racc'
43+
end
44+
4045
gemspec path: '../'

gemfiles/rack2.gemfile

+8-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ group :development, :test do
1010
gem 'bundler'
1111
gem 'hashie'
1212
gem 'rake'
13-
gem 'rubocop', '1.7.0'
14-
gem 'rubocop-ast', '1.3.0'
15-
gem 'rubocop-performance', '1.9.1', require: false
13+
gem 'rubocop', '~> 1.23.0'
14+
gem 'rubocop-ast', '~> 1.14.0'
15+
gem 'rubocop-performance', require: false
16+
gem 'rubocop-rspec', require: false
1617
end
1718

1819
group :development do
@@ -37,4 +38,8 @@ group :test do
3738
gem 'test-prof', require: false
3839
end
3940

41+
platforms :jruby do
42+
gem 'racc'
43+
end
44+
4045
gemspec path: '../'

0 commit comments

Comments
 (0)