Skip to content

Commit 04fda95

Browse files
committed
Fixed violations that had to do with using {...} for multi-line operations
1 parent 8d6503d commit 04fda95

File tree

5 files changed

+73
-87
lines changed

5 files changed

+73
-87
lines changed

.rubocop_todo.yml

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,6 @@ Metrics/ModuleLength:
4343
Metrics/PerceivedComplexity:
4444
Max: 16
4545

46-
# Offense count: 44
47-
# Cop supports --auto-correct.
48-
# Configuration parameters: EnforcedStyle, SupportedStyles, ProceduralMethods, FunctionalMethods, IgnoredMethods.
49-
# SupportedStyles: line_count_based, semantic, braces_for_chaining
50-
# ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object
51-
# FunctionalMethods: let, let!, subject, watch
52-
# IgnoredMethods: lambda, proc, it
53-
Style/BlockDelimiters:
54-
Exclude:
55-
- 'spec/grape/api_spec.rb'
56-
- 'spec/grape/exceptions/validation_errors_spec.rb'
57-
- 'spec/grape/middleware/versioner/header_spec.rb'
58-
- 'spec/grape/request_spec.rb'
59-
6046
# Offense count: 111
6147
Style/Documentation:
6248
Enabled: false

spec/grape/api_spec.rb

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -2170,9 +2170,9 @@ def static
21702170
expect(last_response.body).to eq('["a","b,c"]')
21712171
end
21722172
it 'sets params' do
2173-
expect(subject.routes.map { |route|
2173+
expect(subject.routes.map do |route|
21742174
{ params: route.params }
2175-
}).to eq [
2175+
end).to eq [
21762176
{
21772177
params: {
21782178
'string' => '',
@@ -2200,9 +2200,9 @@ def static
22002200
end
22012201
end
22022202
it 'sets params' do
2203-
expect(subject.routes.map { |route|
2203+
expect(subject.routes.map do |route|
22042204
{ params: route.params }
2205-
}).to eq [
2205+
end).to eq [
22062206
{
22072207
params: {
22082208
'one' => { required: true, desc: 'a token' },
@@ -2231,9 +2231,9 @@ def static
22312231
end
22322232
end
22332233
it 'sets params' do
2234-
expect(subject.routes.map { |route|
2234+
expect(subject.routes.map do |route|
22352235
{ params: route.params }
2236-
}).to eq [
2236+
end).to eq [
22372237
{
22382238
params: {
22392239
'one' => { required: true, desc: 'a token' },
@@ -2285,7 +2285,7 @@ def static
22852285
end
22862286
it 'describes a method' do
22872287
subject.desc 'first method'
2288-
subject.get :first do; end
2288+
subject.get :first
22892289
expect(subject.routes.length).to eq(1)
22902290
route = subject.routes.first
22912291
expect(route.description).to eq('first method')
@@ -2295,52 +2295,52 @@ def static
22952295
end
22962296
it 'has params which does not include format and version as named captures' do
22972297
subject.version :v1, using: :path
2298-
subject.get :first do; end
2298+
subject.get :first
22992299
param_keys = subject.routes.first.params.keys
23002300
expect(param_keys).not_to include('format')
23012301
expect(param_keys).not_to include('version')
23022302
end
23032303
it 'describes methods separately' do
23042304
subject.desc 'first method'
2305-
subject.get :first do; end
2305+
subject.get :first
23062306
subject.desc 'second method'
2307-
subject.get :second do; end
2307+
subject.get :second
23082308
expect(subject.routes.count).to eq(2)
2309-
expect(subject.routes.map { |route|
2309+
expect(subject.routes.map do |route|
23102310
{ description: route.description, params: route.params }
2311-
}).to eq [
2311+
end).to eq [
23122312
{ description: 'first method', params: {} },
23132313
{ description: 'second method', params: {} }
23142314
]
23152315
end
23162316
it 'resets desc' do
23172317
subject.desc 'first method'
2318-
subject.get :first do; end
2319-
subject.get :second do; end
2320-
expect(subject.routes.map { |route|
2318+
subject.get :first
2319+
subject.get :second
2320+
expect(subject.routes.map do |route|
23212321
{ description: route.description, params: route.params }
2322-
}).to eq [
2322+
end).to eq [
23232323
{ description: 'first method', params: {} },
23242324
{ description: nil, params: {} }
23252325
]
23262326
end
23272327
it 'namespaces and describe arbitrary parameters' do
23282328
subject.namespace 'ns' do
23292329
desc 'ns second', foo: 'bar'
2330-
get 'second' do; end
2330+
get 'second'
23312331
end
2332-
expect(subject.routes.map { |route|
2332+
expect(subject.routes.map do |route|
23332333
{ description: route.description, foo: route.route_foo, params: route.params }
2334-
}).to eq [
2334+
end).to eq [
23352335
{ description: 'ns second', foo: 'bar', params: {} }
23362336
]
23372337
end
23382338
it 'includes details' do
23392339
subject.desc 'method', details: 'method details'
2340-
subject.get 'method' do; end
2341-
expect(subject.routes.map { |route|
2340+
subject.get 'method'
2341+
expect(subject.routes.map do |route|
23422342
{ description: route.description, details: route.details, params: route.params }
2343-
}).to eq [
2343+
end).to eq [
23442344
{ description: 'method', details: 'method details', params: {} }
23452345
]
23462346
end
@@ -2349,9 +2349,9 @@ def static
23492349
subject.get 'reverse' do
23502350
params[:s].reverse
23512351
end
2352-
expect(subject.routes.map { |route|
2352+
expect(subject.routes.map do |route|
23532353
{ description: route.description, params: route.params }
2354-
}).to eq [
2354+
end).to eq [
23552355
{ description: 'Reverses a string.', params: { 's' => { desc: 'string to reverse', type: 'string' } } }
23562356
]
23572357
end
@@ -2362,17 +2362,17 @@ def static
23622362
optional :param2
23632363
end
23642364
subject.namespace 'ns1' do
2365-
get do; end
2365+
get { ; }
23662366
end
23672367
subject.params do
23682368
optional :param2
23692369
end
23702370
subject.namespace 'ns2' do
2371-
get do; end
2371+
get { ; }
23722372
end
2373-
routes_doc = subject.routes.map { |route|
2373+
routes_doc = subject.routes.map do |route|
23742374
{ description: route.description, params: route.params }
2375-
}
2375+
end
23762376
expect(routes_doc).to eq [
23772377
{ description: 'global description',
23782378
params: {
@@ -2397,12 +2397,12 @@ def static
23972397
params do
23982398
optional :method_param, desc: 'method parameter'
23992399
end
2400-
get 'method' do; end
2400+
get 'method'
24012401
end
24022402

2403-
routes_doc = subject.routes.map { |route|
2403+
routes_doc = subject.routes.map do |route|
24042404
{ description: route.description, params: route.params }
2405-
}
2405+
end
24062406
expect(routes_doc).to eq [
24072407
{ description: 'method',
24082408
params: {
@@ -2429,12 +2429,12 @@ def static
24292429
params do
24302430
optional :method_param, desc: 'method param'
24312431
end
2432-
get 'method' do; end
2432+
get 'method'
24332433
end
24342434
end
2435-
expect(subject.routes.map { |route|
2435+
expect(subject.routes.map do |route|
24362436
{ description: route.description, params: route.params }
2437-
}).to eq [
2437+
end).to eq [
24382438
{ description: 'method',
24392439
params: {
24402440
'ns_param' => { required: true, desc: 'ns param 2' },
@@ -2457,7 +2457,7 @@ def static
24572457
requires :param2, desc: 'group2 param2 desc'
24582458
end
24592459
end
2460-
subject.get 'method' do; end
2460+
subject.get 'method'
24612461

24622462
expect(subject.routes.map(&:params)).to eq [{
24632463
'group1' => { required: true, type: 'Array' },
@@ -2476,10 +2476,10 @@ def static
24762476
requires :nested_param, desc: 'nested param'
24772477
end
24782478
end
2479-
subject.get 'method' do; end
2480-
expect(subject.routes.map { |route|
2479+
subject.get 'method'
2480+
expect(subject.routes.map do |route|
24812481
{ description: route.description, params: route.params }
2482-
}).to eq [
2482+
end).to eq [
24832483
{ description: 'nesting',
24842484
params: {
24852485
'root_param' => { required: true, desc: 'root param' },
@@ -2500,10 +2500,10 @@ def static
25002500
subject.params do
25012501
requires :one_param, desc: 'one param'
25022502
end
2503-
subject.get 'method' do; end
2504-
expect(subject.routes.map { |route|
2503+
subject.get 'method'
2504+
expect(subject.routes.map do |route|
25052505
{ description: route.description, params: route.params }
2506-
}).to eq [
2506+
end).to eq [
25072507
{ description: nil, params: { 'one_param' => { required: true, desc: 'one param' } } }
25082508
]
25092509
end
@@ -2512,9 +2512,9 @@ def static
25122512
subject.get 'reverse/:s' do
25132513
params[:s].reverse
25142514
end
2515-
expect(subject.routes.map { |route|
2515+
expect(subject.routes.map do |route|
25162516
{ description: route.description, params: route.params }
2517-
}).to eq [
2517+
end).to eq [
25182518
{ description: 'Reverses a string.', params: { 's' => { desc: 'string to reverse', type: 'string' } } }
25192519
]
25202520
end

spec/grape/exceptions/validation_errors_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
let(:validation_error) { OpenStruct.new(params: [validation_message]) }
77

88
context 'initialize' do
9-
let(:headers) {
9+
let(:headers) do
1010
{
1111
'A-Header-Key' => 'A-Header-Value'
1212
}
13-
}
13+
end
1414

1515
subject do
1616
described_class.new(errors: [validation_error], headers: headers)

spec/grape/middleware/versioner/header_spec.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -263,13 +263,13 @@
263263
end
264264

265265
context 'when there are multiple versions with complex vendor specified with rescue_from :all' do
266-
subject {
266+
subject do
267267
Class.new(Grape::API) do
268268
rescue_from :all
269269
end
270-
}
270+
end
271271

272-
let(:v1_app) {
272+
let(:v1_app) do
273273
Class.new(Grape::API) do
274274
version 'v1', using: :header, vendor: 'test.a-cool_resource', cascade: false, strict: true
275275
content_type :v1_test, 'application/vnd.test.a-cool_resource-v1+json'
@@ -282,9 +282,9 @@
282282
end
283283
end
284284
end
285-
}
285+
end
286286

287-
let(:v2_app) {
287+
let(:v2_app) do
288288
Class.new(Grape::API) do
289289
version 'v2', using: :header, vendor: 'test.a-cool_resource', strict: true
290290
content_type :v2_test, 'application/vnd.test.a-cool_resource-v2+json'
@@ -297,7 +297,7 @@
297297
end
298298
end
299299
end
300-
}
300+
end
301301

302302
def app
303303
subject.mount v2_app

0 commit comments

Comments
 (0)