Readability: case/when, guard clauses, small cleanups#2684
Open
ericproulx wants to merge 1 commit intomasterfrom
Open
Readability: case/when, guard clauses, small cleanups#2684ericproulx wants to merge 1 commit intomasterfrom
ericproulx wants to merge 1 commit intomasterfrom
Conversation
Danger ReportNo issues found. |
Mechanical readability refactors across validators, DSLs, and formatters: - inside_route.rb: sendfile dispatched via case/when on value type. - parameters.rb: map_params switched to case/when; EmptyOptionalValue simplified to a frozen Object.new; method order tidied. - error_formatter/json.rb: wrap_message dispatched via case/when. - middleware/formatter.rb: guard-clause returns in ensure_content_type and read_rack_input; bodies.collect -> bodies.map. - validations/types.rb: create_coercer_instance rewritten as a priority-list of guards with comments above each branch; shared array_or_set? predicate extracted; redundant Types. prefix dropped. - validations/types/primitive_coercer.rb: reject? rewritten as case/when with String/Array|Hash dispatch. - validators/except_values_validator.rb: lift except.is_a?(Proc) to a local to avoid recomputing it. No behavior change. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
84d2c2b to
95e47c1
Compare
dblock
approved these changes
Apr 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Mechanical readability refactors across validators, DSLs, and formatters. No behavior change.
dsl/inside_route.rb:sendfiledispatched viacase/whenon value type.dsl/parameters.rb:map_paramsswitched tocase/when;EmptyOptionalValuesimplified to a frozenObject.new; public/private method order tidied.error_formatter/json.rb:wrap_messagedispatched viacase/when.middleware/formatter.rb: guard-clause returns inensure_content_typeandread_rack_input;bodies.collect→bodies.map.validations/types.rb:create_coercer_instancerewritten as a priority-list of guards with comments above each branch; sharedarray_or_set?predicate extracted; redundantTypes.prefixes dropped insidemodule_function Types.validations/types/primitive_coercer.rb:reject?rewritten ascase/whendispatching on the value's class.validators/except_values_validator.rb: liftexcept.is_a?(Proc)to a local so it isn't recomputed.Test plan
🤖 Generated with Claude Code