Skip to content

Commit 9ea0069

Browse files
committed
Fix rubocop
1 parent 96e7fb0 commit 9ea0069

2 files changed

Lines changed: 28 additions & 5 deletions

File tree

.rubocop_todo.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,31 @@
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: 2
10+
# Configuration parameters: CountComments, Max, CountAsOne, AllowedMethods, AllowedPatterns.
11+
Metrics/ClassLength:
12+
Exclude:
13+
- 'lib/grape/validations/params_scope.rb'
14+
915
# Offense count: 1
1016
# Configuration parameters: CountComments, Max, CountAsOne, AllowedMethods, AllowedPatterns.
17+
Metrics/CyclomaticComplexity:
18+
Exclude:
19+
- 'lib/grape/validations/types/hash_schema.rb'
20+
21+
# Offense count: 2
22+
# Configuration parameters: CountComments, Max, CountAsOne, AllowedMethods, AllowedPatterns.
1123
Metrics/MethodLength:
1224
Exclude:
1325
- 'lib/grape/endpoint.rb'
26+
- 'lib/grape/validations/types/hash_schema.rb'
27+
28+
# Offense count: 2
29+
# Configuration parameters: CountComments, Max, CountAsOne, AllowedMethods, AllowedPatterns.
30+
Metrics/PerceivedComplexity:
31+
Exclude:
32+
- 'lib/grape/validations/params_scope.rb'
33+
- 'lib/grape/validations/types/hash_schema.rb'
1434

1535
# Offense count: 18
1636
# Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers, AllowedPatterns.

lib/grape/validations/validators/multiple_hash_schema_validator.rb

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,19 @@ def validate_param!(attr_name, params)
2424

2525
# Try to validate against each schema and collect results
2626
results = []
27-
@schemas.each do |schema|
27+
valid_schema = @schemas.any? do |schema|
2828
result = schema.validate_hash(value, attr_name, @api, @scope)
2929
if result.valid?
30-
# Validation succeeded for this schema
31-
return
30+
true
31+
else
32+
results << result
33+
false
3234
end
33-
34-
results << result
3535
end
3636

37+
# Validation succeeded for one of the schemas
38+
return if valid_schema
39+
3740
# None of the schemas matched - determine best error message
3841
raise_best_error(attr_name, results)
3942
end

0 commit comments

Comments
 (0)