Skip to content

Commit cc20eb8

Browse files
authored
[Ruby] Fix obsolete configuration of Rubocop and Rubocop's warns (#5417) (#5474)
* fix obsolute configuration in generated .rubocop.yml * fix style of `expect` with block in generated ruby client's test code * update sample of ruby client
1 parent 40cbbbf commit cc20eb8

File tree

9 files changed

+24
-54
lines changed

9 files changed

+24
-54
lines changed

modules/openapi-generator/src/main/resources/ruby-client/api_client_spec.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ describe {{moduleName}}::ApiClient do
150150
end
151151

152152
it 'fails for invalid collection format' do
153-
expect{api_client.build_collection_param(param, :INVALID)}.to raise_error(RuntimeError, 'unknown collection format: :INVALID')
153+
expect { api_client.build_collection_param(param, :INVALID) }.to raise_error(RuntimeError, 'unknown collection format: :INVALID')
154154
end
155155
end
156156

modules/openapi-generator/src/main/resources/ruby-client/rubocop.mustache

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@ AllCops:
1414
Style/AndOr:
1515
Enabled: true
1616

17-
# Do not use braces for hash literals when they are the last argument of a
18-
# method call.
19-
Style/BracesAroundHashParameters:
20-
Enabled: true
21-
EnforcedStyle: context_dependent
22-
2317
# Align `when` with `case`.
2418
Layout/CaseIndentation:
2519
Enabled: true
@@ -46,7 +40,7 @@ Layout/EmptyLinesAroundMethodBody:
4640
Layout/EmptyLinesAroundModuleBody:
4741
Enabled: true
4842

49-
Layout/IndentFirstArgument:
43+
Layout/FirstArgumentIndentation:
5044
Enabled: true
5145

5246
# Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }.
@@ -57,7 +51,7 @@ Style/HashSyntax:
5751
# extra level of indentation.
5852
Layout/IndentationConsistency:
5953
Enabled: true
60-
EnforcedStyle: rails
54+
EnforcedStyle: indented_internal_methods
6155

6256
# Two spaces, no tabs (for indentation).
6357
Layout/IndentationWidth:
@@ -123,15 +117,15 @@ Layout/Tab:
123117
Enabled: true
124118

125119
# Blank lines should not have any spaces.
126-
Layout/TrailingBlankLines:
120+
Layout/TrailingEmptyLines:
127121
Enabled: true
128122

129123
# No trailing whitespace.
130124
Layout/TrailingWhitespace:
131125
Enabled: false
132126

133127
# Use quotes for string literals when they are enough.
134-
Style/UnneededPercentQ:
128+
Style/RedundantPercentQ:
135129
Enabled: true
136130

137131
# Align `end` with the matching keyword or starting expression except for

samples/client/petstore/ruby-faraday/.rubocop.yml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@ AllCops:
1414
Style/AndOr:
1515
Enabled: true
1616

17-
# Do not use braces for hash literals when they are the last argument of a
18-
# method call.
19-
Style/BracesAroundHashParameters:
20-
Enabled: true
21-
EnforcedStyle: context_dependent
22-
2317
# Align `when` with `case`.
2418
Layout/CaseIndentation:
2519
Enabled: true
@@ -46,7 +40,7 @@ Layout/EmptyLinesAroundMethodBody:
4640
Layout/EmptyLinesAroundModuleBody:
4741
Enabled: true
4842

49-
Layout/IndentFirstArgument:
43+
Layout/FirstArgumentIndentation:
5044
Enabled: true
5145

5246
# Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }.
@@ -57,7 +51,7 @@ Style/HashSyntax:
5751
# extra level of indentation.
5852
Layout/IndentationConsistency:
5953
Enabled: true
60-
EnforcedStyle: rails
54+
EnforcedStyle: indented_internal_methods
6155

6256
# Two spaces, no tabs (for indentation).
6357
Layout/IndentationWidth:
@@ -123,15 +117,15 @@ Layout/Tab:
123117
Enabled: true
124118

125119
# Blank lines should not have any spaces.
126-
Layout/TrailingBlankLines:
120+
Layout/TrailingEmptyLines:
127121
Enabled: true
128122

129123
# No trailing whitespace.
130124
Layout/TrailingWhitespace:
131125
Enabled: false
132126

133127
# Use quotes for string literals when they are enough.
134-
Style/UnneededPercentQ:
128+
Style/RedundantPercentQ:
135129
Enabled: true
136130

137131
# Align `end` with the matching keyword or starting expression except for

samples/client/petstore/ruby/.rubocop.yml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@ AllCops:
1414
Style/AndOr:
1515
Enabled: true
1616

17-
# Do not use braces for hash literals when they are the last argument of a
18-
# method call.
19-
Style/BracesAroundHashParameters:
20-
Enabled: true
21-
EnforcedStyle: context_dependent
22-
2317
# Align `when` with `case`.
2418
Layout/CaseIndentation:
2519
Enabled: true
@@ -46,7 +40,7 @@ Layout/EmptyLinesAroundMethodBody:
4640
Layout/EmptyLinesAroundModuleBody:
4741
Enabled: true
4842

49-
Layout/IndentFirstArgument:
43+
Layout/FirstArgumentIndentation:
5044
Enabled: true
5145

5246
# Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }.
@@ -57,7 +51,7 @@ Style/HashSyntax:
5751
# extra level of indentation.
5852
Layout/IndentationConsistency:
5953
Enabled: true
60-
EnforcedStyle: rails
54+
EnforcedStyle: indented_internal_methods
6155

6256
# Two spaces, no tabs (for indentation).
6357
Layout/IndentationWidth:
@@ -123,15 +117,15 @@ Layout/Tab:
123117
Enabled: true
124118

125119
# Blank lines should not have any spaces.
126-
Layout/TrailingBlankLines:
120+
Layout/TrailingEmptyLines:
127121
Enabled: true
128122

129123
# No trailing whitespace.
130124
Layout/TrailingWhitespace:
131125
Enabled: false
132126

133127
# Use quotes for string literals when they are enough.
134-
Style/UnneededPercentQ:
128+
Style/RedundantPercentQ:
135129
Enabled: true
136130

137131
# Align `end` with the matching keyword or starting expression except for

samples/client/petstore/ruby/spec/api_client_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@
156156
end
157157

158158
it 'fails for invalid collection format' do
159-
expect{api_client.build_collection_param(param, :INVALID)}.to raise_error(RuntimeError, 'unknown collection format: :INVALID')
159+
expect { api_client.build_collection_param(param, :INVALID) }.to raise_error(RuntimeError, 'unknown collection format: :INVALID')
160160
end
161161
end
162162

samples/openapi3/client/petstore/ruby-faraday/.rubocop.yml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@ AllCops:
1414
Style/AndOr:
1515
Enabled: true
1616

17-
# Do not use braces for hash literals when they are the last argument of a
18-
# method call.
19-
Style/BracesAroundHashParameters:
20-
Enabled: true
21-
EnforcedStyle: context_dependent
22-
2317
# Align `when` with `case`.
2418
Layout/CaseIndentation:
2519
Enabled: true
@@ -46,7 +40,7 @@ Layout/EmptyLinesAroundMethodBody:
4640
Layout/EmptyLinesAroundModuleBody:
4741
Enabled: true
4842

49-
Layout/IndentFirstArgument:
43+
Layout/FirstArgumentIndentation:
5044
Enabled: true
5145

5246
# Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }.
@@ -57,7 +51,7 @@ Style/HashSyntax:
5751
# extra level of indentation.
5852
Layout/IndentationConsistency:
5953
Enabled: true
60-
EnforcedStyle: rails
54+
EnforcedStyle: indented_internal_methods
6155

6256
# Two spaces, no tabs (for indentation).
6357
Layout/IndentationWidth:
@@ -123,15 +117,15 @@ Layout/Tab:
123117
Enabled: true
124118

125119
# Blank lines should not have any spaces.
126-
Layout/TrailingBlankLines:
120+
Layout/TrailingEmptyLines:
127121
Enabled: true
128122

129123
# No trailing whitespace.
130124
Layout/TrailingWhitespace:
131125
Enabled: false
132126

133127
# Use quotes for string literals when they are enough.
134-
Style/UnneededPercentQ:
128+
Style/RedundantPercentQ:
135129
Enabled: true
136130

137131
# Align `end` with the matching keyword or starting expression except for

samples/openapi3/client/petstore/ruby-faraday/spec/api_client_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@
118118
end
119119

120120
it 'fails for invalid collection format' do
121-
expect{api_client.build_collection_param(param, :INVALID)}.to raise_error(RuntimeError, 'unknown collection format: :INVALID')
121+
expect { api_client.build_collection_param(param, :INVALID) }.to raise_error(RuntimeError, 'unknown collection format: :INVALID')
122122
end
123123
end
124124

samples/openapi3/client/petstore/ruby/.rubocop.yml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@ AllCops:
1414
Style/AndOr:
1515
Enabled: true
1616

17-
# Do not use braces for hash literals when they are the last argument of a
18-
# method call.
19-
Style/BracesAroundHashParameters:
20-
Enabled: true
21-
EnforcedStyle: context_dependent
22-
2317
# Align `when` with `case`.
2418
Layout/CaseIndentation:
2519
Enabled: true
@@ -46,7 +40,7 @@ Layout/EmptyLinesAroundMethodBody:
4640
Layout/EmptyLinesAroundModuleBody:
4741
Enabled: true
4842

49-
Layout/IndentFirstArgument:
43+
Layout/FirstArgumentIndentation:
5044
Enabled: true
5145

5246
# Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }.
@@ -57,7 +51,7 @@ Style/HashSyntax:
5751
# extra level of indentation.
5852
Layout/IndentationConsistency:
5953
Enabled: true
60-
EnforcedStyle: rails
54+
EnforcedStyle: indented_internal_methods
6155

6256
# Two spaces, no tabs (for indentation).
6357
Layout/IndentationWidth:
@@ -123,15 +117,15 @@ Layout/Tab:
123117
Enabled: true
124118

125119
# Blank lines should not have any spaces.
126-
Layout/TrailingBlankLines:
120+
Layout/TrailingEmptyLines:
127121
Enabled: true
128122

129123
# No trailing whitespace.
130124
Layout/TrailingWhitespace:
131125
Enabled: false
132126

133127
# Use quotes for string literals when they are enough.
134-
Style/UnneededPercentQ:
128+
Style/RedundantPercentQ:
135129
Enabled: true
136130

137131
# Align `end` with the matching keyword or starting expression except for

samples/openapi3/client/petstore/ruby/spec/api_client_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@
156156
end
157157

158158
it 'fails for invalid collection format' do
159-
expect{api_client.build_collection_param(param, :INVALID)}.to raise_error(RuntimeError, 'unknown collection format: :INVALID')
159+
expect { api_client.build_collection_param(param, :INVALID) }.to raise_error(RuntimeError, 'unknown collection format: :INVALID')
160160
end
161161
end
162162

0 commit comments

Comments
 (0)