Skip to content

Commit 91604fc

Browse files
authored
Add unconfigured rubocops and fix errors (#4169)
1 parent b536c96 commit 91604fc

Some content is hidden

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

49 files changed

+529
-495
lines changed

.rubocop_cc.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ Lint/AmbiguousRange:
162162
Enabled: true
163163
Lint/ConstantOverwrittenInRescue:
164164
Enabled: true
165+
Lint/ConstantReassignment:
166+
Enabled: true
165167
Lint/DeprecatedConstants:
166168
Enabled: true
167169
Lint/DuplicateBranch:
@@ -172,12 +174,16 @@ Lint/DuplicateMatchPattern:
172174
Enabled: true
173175
Lint/DuplicateRegexpCharacterClassElement:
174176
Enabled: true
177+
Lint/DuplicateSetElement:
178+
Enabled: true
175179
Lint/EmptyBlock:
176180
Enabled: true
177181
Lint/EmptyClass:
178182
Enabled: true
179183
Lint/EmptyInPattern:
180184
Enabled: true
185+
Lint/HashNewWithKeywordArgumentsAsDefault:
186+
Enabled: true
181187
Lint/IncompatibleIoSelectWithFiberScheduler:
182188
Enabled: true
183189
Lint/ItWithoutArgumentsInBlock:
@@ -194,6 +200,8 @@ Lint/NonAtomicFileOperation:
194200
Enabled: true
195201
Lint/NumberedParameterAssignment:
196202
Enabled: true
203+
Lint/NumericOperationWithConstantResult:
204+
Enabled: true
197205
Lint/OrAssignmentToConstant:
198206
Enabled: true
199207
Lint/RedundantDirGlobSort:
@@ -206,16 +214,22 @@ Lint/RequireRangeParentheses:
206214
Enabled: true
207215
Lint/RequireRelativeSelfPath:
208216
Enabled: true
217+
Lint/SharedMutableDefault:
218+
Enabled: true
209219
Lint/SymbolConversion:
210220
Enabled: true
211221
Lint/ToEnumArguments:
212222
Enabled: true
213223
Lint/TripleQuotes:
214224
Enabled: true
225+
Lint/UnescapedBracketInRegexp:
226+
Enabled: true
215227
Lint/UnexpectedBlockArity:
216228
Enabled: true
217229
Lint/UnmodifiedReduceAccumulator:
218230
Enabled: true
231+
Lint/UselessDefined:
232+
Enabled: true
219233
Lint/UselessRescue:
220234
Enabled: true
221235
Lint/UselessRuby2Keywords:
@@ -228,18 +242,26 @@ Security/CompoundHash:
228242
Enabled: true
229243
Security/IoMethods:
230244
Enabled: true
245+
Style/AmbiguousEndlessMethodDefinition:
246+
Enabled: true
231247
Style/ArgumentsForwarding:
232248
Enabled: true
233249
Style/ArrayIntersect:
234250
Enabled: true
251+
Style/BitwisePredicate:
252+
Enabled: true
235253
Style/CollectionCompact:
236254
Enabled: true
255+
Style/CombinableDefined:
256+
Enabled: true
237257
Style/ComparableClamp:
238258
Enabled: true
239259
Style/ConcatArrayLiterals:
240260
Enabled: true
241261
Style/DataInheritance:
242262
Enabled: true
263+
Style/DigChain:
264+
Enabled: true
243265
Style/DirEmpty:
244266
Enabled: true
245267
Style/DocumentDynamicEvalDefinition:
@@ -256,8 +278,12 @@ Style/FetchEnvVar:
256278
Enabled: true
257279
Style/FileEmpty:
258280
Enabled: true
281+
Style/FileNull:
282+
Enabled: true
259283
Style/FileRead:
260284
Enabled: true
285+
Style/FileTouch:
286+
Enabled: true
261287
Style/FileWrite:
262288
Enabled: true
263289
Style/HashConversion:
@@ -268,6 +294,10 @@ Style/IfWithBooleanLiteralBranches:
268294
Enabled: true
269295
Style/InPatternThen:
270296
Enabled: true
297+
Style/ItAssignment:
298+
Enabled: true
299+
Style/KeywordArgumentsMerging:
300+
Enabled: true
271301
Style/MagicCommentFormat:
272302
Enabled: true
273303
Style/MapCompactWithConditionalBlock:
@@ -328,6 +358,8 @@ Style/RedundantStringEscape:
328358
Enabled: true
329359
Style/ReturnNilInPredicateMethodDefinition:
330360
Enabled: true
361+
Style/SafeNavigationChainLength:
362+
Enabled: true
331363
Style/SelectByRegexp:
332364
Enabled: true
333365
Style/StringChars:
@@ -528,6 +560,8 @@ RSpec/SpecFilePathFormat:
528560
Enabled: true
529561
RSpec/SpecFilePathSuffix:
530562
Enabled: true
563+
RSpec/StringAsInstanceDoubleConstant:
564+
Enabled: true
531565
RSpec/SubjectDeclaration:
532566
Enabled: true
533567
RSpec/VerifiedDoubleReference:

config/environment.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
require File.expand_path('application', __dir__)
22

3-
Rails.logger = Logger.new('/dev/null')
3+
Rails.logger = Logger.new(File::NULL)
44
Rails.application.initialize!

lib/cloud_controller/blobstore/fingerprints_collection.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def each(&block)
3131

3232
def parse_mode(raw_mode, filename)
3333
mode = raw_mode ? raw_mode.to_i(8) : DEFAULT_FILE_MODE
34-
unless (mode & 0o600) == 0o600
34+
unless mode.allbits?(0o600)
3535
raise CloudController::Errors::ApiError.new_from_details('AppResourcesFileModeInvalid',
3636
"File mode '#{raw_mode}' with path '#{filename}' is invalid. Minimum file mode is '0600'")
3737
end

spec/request/admin_actions_spec.rb

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

1313
let(:expected_codes_and_responses) do
1414
h = Hash.new(
15-
code: 403
15+
{ code: 403 }.freeze
1616
)
1717
h['admin'] = {
1818
code: 202

spec/request/app_features_spec.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
end
4545

4646
let(:expected_codes_and_responses) do
47-
h = Hash.new(code: 404)
47+
h = Hash.new({ code: 404 }.freeze)
4848
%w[admin admin_read_only global_auditor space_developer space_manager space_auditor org_manager
4949
space_supporter].each do |r|
5050
h[r] = { code: 200, response_object: features_response_object }
@@ -62,7 +62,7 @@
6262

6363
describe 'GET /v3/apps/:guid/features/:name' do
6464
let(:expected_codes_and_responses) do
65-
h = Hash.new(code: 404)
65+
h = Hash.new({ code: 404 }.freeze)
6666
%w[admin admin_read_only global_auditor space_developer space_manager space_auditor org_manager
6767
space_supporter].each do |r|
6868
h[r] = { code: 200, response_object: feature_response_object }
@@ -132,7 +132,7 @@
132132
end
133133

134134
let(:expected_codes_and_responses) do
135-
h = Hash.new(code: 403, errors: CF_NOT_AUTHORIZED)
135+
h = Hash.new({ code: 403, errors: CF_NOT_AUTHORIZED }.freeze)
136136
%w[no_role org_auditor org_billing_manager].each { |r| h[r] = { code: 404 } }
137137
%w[admin space_developer].each { |r| h[r] = { code: 200, response_object: feature_response_object } }
138138
h
@@ -166,7 +166,7 @@
166166
end
167167

168168
let(:expected_codes_and_responses) do
169-
h = Hash.new(code: 403, errors: CF_NOT_AUTHORIZED)
169+
h = Hash.new({ code: 403, errors: CF_NOT_AUTHORIZED }.freeze)
170170
%w[no_role org_auditor org_billing_manager].each { |r| h[r] = { code: 404 } }
171171
%w[admin space_developer space_supporter].each do |r|
172172
h[r] = { code: 200, response_object: feature_response_object }
@@ -202,7 +202,7 @@
202202
end
203203

204204
let(:expected_codes_and_responses) do
205-
h = Hash.new(code: 403, errors: CF_NOT_AUTHORIZED)
205+
h = Hash.new({ code: 403, errors: CF_NOT_AUTHORIZED }.freeze)
206206
%w[no_role org_auditor org_billing_manager].each { |r| h[r] = { code: 404 } }
207207
%w[admin space_developer].each { |r| h[r] = { code: 200, response_object: feature_response_object } }
208208
h

spec/request/app_manifests_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
context 'permissions' do
5959
let(:api_call) { ->(user_headers) { get "/v3/apps/#{app_model.guid}/manifest", nil, user_headers } }
6060
let(:expected_codes_and_responses) do
61-
h = Hash.new(code: 403)
61+
h = Hash.new({ code: 403 }.freeze)
6262
h['no_role'] = { code: 404 }
6363
h['org_auditor'] = { code: 404 }
6464
h['org_billing_manager'] = { code: 404 }

spec/request/app_usage_events_spec.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
let(:expected_codes_and_responses) do
1818
h = Hash.new(
19-
code: 404,
20-
response_object: []
19+
{ code: 404,
20+
response_object: [] }.freeze
2121
)
2222
h['admin'] = {
2323
code: 200,
@@ -63,8 +63,8 @@
6363

6464
let(:expected_codes_and_responses) do
6565
h = Hash.new(
66-
code: 200,
67-
response_objects: []
66+
{ code: 200,
67+
response_objects: [] }.freeze
6868
)
6969
h['admin'] = {
7070
code: 200,
@@ -151,7 +151,7 @@
151151
end
152152

153153
let(:expected_codes_and_responses) do
154-
h = Hash.new(code: 403)
154+
h = Hash.new({ code: 403 }.freeze)
155155
h['admin'] = { code: 200 }
156156
h
157157
end

0 commit comments

Comments
 (0)