Skip to content

Commit d877ea5

Browse files
committed
Fix CI, upgrade RuboCop.
1 parent 7dfc7f3 commit d877ea5

File tree

8 files changed

+124
-67
lines changed

8 files changed

+124
-67
lines changed

.rubocop.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ AllCops:
77

88
inherit_from: .rubocop_todo.yml
99

10+
require:
11+
- rubocop-rake
12+
- rubocop-rspec
13+
1014
Naming/FileName:
1115
Enabled: false
1216

.rubocop_todo.yml

Lines changed: 88 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This configuration was generated by
2-
# `rubocop --auto-gen-config --auto-gen-only-exclude --exclude-limit 5000`
3-
# on 2023-07-06 20:16:40 UTC using RuboCop version 1.42.0.
2+
# `rubocop --auto-gen-config`
3+
# on 2024-09-09 22:35:29 UTC using RuboCop version 1.66.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
@@ -28,7 +28,7 @@ Lint/EmptyBlock:
2828
Exclude:
2929
- 'spec/grape-swagger/entity/attribute_parser_spec.rb'
3030

31-
# Offense count: 1
31+
# Offense count: 2
3232
# This cop supports unsafe autocorrection (--autocorrect-all).
3333
# Configuration parameters: AllowedMethods.
3434
# AllowedMethods: instance_of?, kind_of?, is_a?, eql?, respond_to?, equal?
@@ -37,59 +37,109 @@ Lint/RedundantSafeNavigation:
3737
- 'lib/grape-swagger/entity/attribute_parser.rb'
3838

3939
# Offense count: 4
40-
# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods, CountRepeatedAttributes, Max.
40+
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
4141
Metrics/AbcSize:
42-
Exclude:
43-
- 'lib/grape-swagger/entity/attribute_parser.rb'
44-
- 'lib/grape-swagger/entity/parser.rb'
45-
46-
# Offense count: 13
47-
# Configuration parameters: CountComments, Max, CountAsOne, ExcludedMethods, AllowedMethods, AllowedPatterns, IgnoredMethods.
48-
# AllowedMethods: refine
49-
Metrics/BlockLength:
50-
Exclude:
51-
- '**/*.gemspec'
52-
- 'spec/grape-swagger/entities/response_model_spec.rb'
53-
- 'spec/grape-swagger/entity/attribute_parser_spec.rb'
54-
- 'spec/grape-swagger/entity/parser_spec.rb'
55-
- 'spec/support/shared_contexts/this_api.rb'
42+
Max: 34
5643

57-
# Offense count: 1
58-
# Configuration parameters: CountComments, Max, CountAsOne.
44+
# Offense count: 2
45+
# Configuration parameters: CountComments, CountAsOne.
5946
Metrics/ClassLength:
60-
Exclude:
61-
- 'lib/grape-swagger/entity/attribute_parser.rb'
62-
- 'lib/grape-swagger/entity/parser.rb'
47+
Max: 112
6348

6449
# Offense count: 2
65-
# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods, Max.
50+
# Configuration parameters: AllowedMethods, AllowedPatterns.
6651
Metrics/CyclomaticComplexity:
67-
Exclude:
68-
- 'lib/grape-swagger/entity/attribute_parser.rb'
69-
- 'lib/grape-swagger/entity/parser.rb'
52+
Max: 11
7053

71-
# Offense count: 5
72-
# Configuration parameters: CountComments, Max, CountAsOne, ExcludedMethods, AllowedMethods, AllowedPatterns, IgnoredMethods.
54+
# Offense count: 7
55+
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
7356
Metrics/MethodLength:
74-
Exclude:
75-
- 'lib/grape-swagger/entity/attribute_parser.rb'
76-
- 'lib/grape-swagger/entity/parser.rb'
57+
Max: 28
7758

7859
# Offense count: 2
79-
# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods, Max.
60+
# Configuration parameters: AllowedMethods, AllowedPatterns.
8061
Metrics/PerceivedComplexity:
81-
Exclude:
82-
- 'lib/grape-swagger/entity/attribute_parser.rb'
83-
- 'lib/grape-swagger/entity/parser.rb'
62+
Max: 13
8463

85-
# Offense count: 2
64+
# Offense count: 5
8665
# Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers, AllowedPatterns.
8766
# SupportedStyles: snake_case, normalcase, non_integer
88-
# AllowedIdentifiers: capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339
67+
# AllowedIdentifiers: capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339, x86_64
8968
Naming/VariableNumber:
9069
Exclude:
9170
- 'spec/grape-swagger/entities/response_model_spec.rb'
9271

72+
# Offense count: 1
73+
RSpec/BeforeAfterAll:
74+
Exclude:
75+
- '**/spec/spec_helper.rb'
76+
- '**/spec/rails_helper.rb'
77+
- '**/spec/support/**/*.rb'
78+
- 'spec/grape-swagger/entities/response_model_spec.rb'
79+
80+
# Offense count: 4
81+
# Configuration parameters: Prefixes, AllowedPatterns.
82+
# Prefixes: when, with, without
83+
RSpec/ContextWording:
84+
Exclude:
85+
- 'spec/grape-swagger/entity/parser_spec.rb'
86+
- 'spec/support/shared_contexts/inheritance_api.rb'
87+
- 'spec/support/shared_contexts/this_api.rb'
88+
89+
# Offense count: 2
90+
# Configuration parameters: IgnoredMetadata.
91+
RSpec/DescribeClass:
92+
Exclude:
93+
- '**/spec/features/**/*'
94+
- '**/spec/requests/**/*'
95+
- '**/spec/routing/**/*'
96+
- '**/spec/system/**/*'
97+
- '**/spec/views/**/*'
98+
- 'spec/grape-swagger/entities/response_model_spec.rb'
99+
100+
# Offense count: 4
101+
# Configuration parameters: CountAsOne.
102+
RSpec/ExampleLength:
103+
Max: 172
104+
105+
# Offense count: 24
106+
RSpec/LeakyConstantDeclaration:
107+
Exclude:
108+
- 'spec/grape-swagger/entities/response_model_spec.rb'
109+
- 'spec/support/shared_contexts/inheritance_api.rb'
110+
- 'spec/support/shared_contexts/this_api.rb'
111+
112+
# Offense count: 1
113+
RSpec/MultipleDescribes:
114+
Exclude:
115+
- 'spec/grape-swagger/entities/response_model_spec.rb'
116+
117+
# Offense count: 5
118+
RSpec/MultipleExpectations:
119+
Max: 11
120+
121+
# Offense count: 20
122+
# Configuration parameters: EnforcedStyle, IgnoreSharedExamples.
123+
# SupportedStyles: always, named_only
124+
RSpec/NamedSubject:
125+
Exclude:
126+
- 'spec/grape-swagger/entities/response_model_spec.rb'
127+
128+
# Offense count: 39
129+
# Configuration parameters: AllowedGroups.
130+
RSpec/NestedGroups:
131+
Max: 5
132+
133+
# Offense count: 3
134+
# Configuration parameters: Include, CustomTransform, IgnoreMethods, IgnoreMetadata.
135+
# Include: **/*_spec.rb
136+
RSpec/SpecFilePathFormat:
137+
Exclude:
138+
- '**/spec/routing/**/*'
139+
- 'spec/grape-swagger/entity/attribute_parser_spec.rb'
140+
- 'spec/grape-swagger/entity/parser_spec.rb'
141+
- 'spec/grape-swagger/entity_spec.rb'
142+
93143
# Offense count: 4
94144
# Configuration parameters: AllowedConstants.
95145
Style/Documentation:

Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ group :development, :test do
1616
gem 'rdoc'
1717
gem 'rspec'
1818
gem 'rubocop'
19+
gem 'rubocop-rake'
20+
gem 'rubocop-rspec'
1921
end
2022

2123
gem 'grape-swagger', git: 'https://github.com/ruby-grape/grape-swagger.git'

grape-swagger-entity.gemspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
2020
s.require_paths = ['lib']
2121

2222
s.required_ruby_version = '>= 3.0'
23-
s.add_runtime_dependency 'grape-entity', '~> 1'
24-
s.add_runtime_dependency 'grape-swagger', '~> 2'
23+
s.add_dependency 'grape-entity', '~> 1'
24+
s.add_dependency 'grape-swagger', '~> 2'
2525
s.metadata['rubygems_mfa_required'] = 'true'
2626
end

spec/grape-swagger/entities/response_model_spec.rb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@
33
require 'spec_helper'
44

55
describe 'responseModel' do
6+
subject do
7+
get '/swagger_doc/something'
8+
JSON.parse(last_response.body)
9+
end
10+
611
include_context 'this api'
712

813
def app
914
ThisApi::ResponseModelApi
1015
end
1116

12-
subject do
13-
get '/swagger_doc/something'
14-
JSON.parse(last_response.body)
15-
end
16-
1717
it 'documents index action' do
1818
expect(subject['paths']['/something']['get']['responses']).to eq(
1919
'200' => {
@@ -26,7 +26,7 @@ def app
2626
)
2727
end
2828

29-
it 'should document specified models as show action' do
29+
it 'documents specified models as show action' do
3030
expect(subject['paths']['/something/{id}']['get']['responses']).to eq(
3131
'200' => {
3232
'description' => 'OK',
@@ -88,6 +88,11 @@ def app
8888
end
8989

9090
describe 'building definitions from given entities' do
91+
subject do
92+
get '/swagger_doc'
93+
JSON.parse(last_response.body)['definitions']
94+
end
95+
9196
before :all do
9297
module TheseApi
9398
module Entities
@@ -209,11 +214,6 @@ def app
209214
TheseApi::ResponseEntityApi
210215
end
211216

212-
subject do
213-
get '/swagger_doc'
214-
JSON.parse(last_response.body)['definitions']
215-
end
216-
217217
it 'prefers entity over other `using` values' do
218218
expect(subject['TheseApi_Entities_Values']).to eql(
219219
'type' => 'object',

spec/grape-swagger/entity/attribute_parser_spec.rb

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
include_context 'this api'
88

99
describe '#call' do
10-
let(:endpoint) {}
11-
1210
subject { described_class.new(endpoint).call(entity_options) }
1311

12+
let(:endpoint) {}
13+
1414
context 'when the entity is a model' do
1515
context 'when it is exposed as an array' do
1616
let(:entity_options) { { using: ThisApi::Entities::Tag, documentation: { is_array: true } } }
@@ -62,7 +62,7 @@
6262
documentation: { type: 'ThisApi::Kind', desc: 'The kind of this something.' } }
6363
end
6464

65-
it { is_expected.to_not include('type') }
65+
it { is_expected.not_to include('type') }
6666
it { is_expected.to include('$ref' => '#/definitions/Kind') }
6767
end
6868
end
@@ -88,15 +88,15 @@
8888
context 'when it contains values array' do
8989
let(:entity_options) { { documentation: { type: 'string', desc: 'Colors', values: %w[red blue] } } }
9090

91-
it { is_expected.to_not include('minimum') }
92-
it { is_expected.to_not include('maximum') }
91+
it { is_expected.not_to include('minimum') }
92+
it { is_expected.not_to include('maximum') }
9393
end
9494

9595
context 'when it contains values range' do
9696
let(:entity_options) { { documentation: { type: 'string', desc: 'Colors', values: 'a'...'c' } } }
9797

98-
it { is_expected.to_not include('minimum') }
99-
it { is_expected.to_not include('maximum') }
98+
it { is_expected.not_to include('minimum') }
99+
it { is_expected.not_to include('maximum') }
100100
end
101101

102102
context 'when it contains extensions' do
@@ -126,8 +126,8 @@
126126
context 'when it contains values array' do
127127
let(:entity_options) { { documentation: { type: 'number', desc: 'Solution pH', values: [6.0, 7.0, 8.0] } } }
128128

129-
it { is_expected.to_not include('minimum') }
130-
it { is_expected.to_not include('maximum') }
129+
it { is_expected.not_to include('minimum') }
130+
it { is_expected.not_to include('maximum') }
131131
end
132132

133133
context 'when it contains values range' do
@@ -139,14 +139,14 @@
139139
context 'when it contains values range with no minimum' do
140140
let(:entity_options) { { documentation: { type: 'number', desc: 'Solution pH', values: ..14.0 } } }
141141

142-
it { is_expected.to_not include('minimum') }
142+
it { is_expected.not_to include('minimum') }
143143
it { is_expected.to include(maximum: 14.0) }
144144
end
145145

146146
context 'when it contains values range with no maximum' do
147147
let(:entity_options) { { documentation: { type: 'number', desc: 'Solution pH', values: 0.0.. } } }
148148

149-
it { is_expected.to_not include('maximum') }
149+
it { is_expected.not_to include('maximum') }
150150
it { is_expected.to include(minimum: 0.0) }
151151
end
152152

@@ -177,8 +177,8 @@
177177
context 'when it contains values array' do
178178
let(:entity_options) { { documentation: { type: 'integer', desc: 'Count', values: 1..10 } } }
179179

180-
it { is_expected.to_not include('minimum') }
181-
it { is_expected.to_not include('maximum') }
180+
it { is_expected.not_to include('minimum') }
181+
it { is_expected.not_to include('maximum') }
182182
end
183183

184184
context 'when it contains values range' do
@@ -241,7 +241,7 @@
241241
let(:entity_options) { { documentation: { type: 'string', desc: 'Content of something.' } } }
242242

243243
it { is_expected.to include(type: 'string') }
244-
it { is_expected.to_not include('$ref') }
244+
it { is_expected.not_to include('$ref') }
245245
end
246246

247247
context 'when it is exposed as a boolean' do

spec/grape-swagger/entity/parser_spec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,12 @@
2929
end
3030

3131
it 'hides hidden attributes' do
32-
expect(properties).to_not include(:hidden_attr)
32+
expect(properties).not_to include(:hidden_attr)
3333
end
3434
end
3535
end
3636
end
37+
3738
context 'inheritance api' do
3839
include_context 'inheritance api'
3940

spec/grape-swagger/entity_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
describe GrapeSwagger::Entity do
66
it 'has a version number' do
7-
expect(GrapeSwagger::Entity::VERSION).not_to be nil
7+
expect(GrapeSwagger::Entity::VERSION).not_to be_nil
88
end
99

1010
it 'parser should be registred' do

0 commit comments

Comments
 (0)