Reduce cyclomatic complexity in FieldValue+Codable, drop lint disable (#154)#414
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## v1.0.0-beta.3 #414 +/- ##
=================================================
+ Coverage 73.85% 74.26% +0.40%
=================================================
Files 156 156
Lines 3698 3718 +20
=================================================
+ Hits 2731 2761 +30
+ Misses 967 957 -10
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Code ReviewSummary: Splits Strengths
Minor observations
The Comment on /// Encode the scalar cases (string, bytes, int64, double, date).
///
/// - Returns: `true` when `self` was a scalar case…Per the project's CLAUDE.md, comments should explain the non-obvious WHY. The doc comment's
This is correct, but since Overall: Minimal, correct, and closes the lint issue without any behavior change. The defensive |
…disable (#154) Re-scoped from the now-removed CustomFieldValue(Payload).swift to the remaining hand-written disable in FieldValue+Codable.swift. Extracted helpers so the cyclomatic_complexity swiftlint disable can be removed; behavior and serialization output unchanged. Generated Operations.*.Output disables are out of scope. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
da921b1 to
f28213b
Compare
The #154 refactor split encodeValue into encodeScalar/encodeComplex but added no tests; the only encode-path test covered .string. Add a parameterized encode→decode round-trip over the scalar and complex cases (driving the encodeScalar→encodeComplex delegation), plus explicit encode-shape assertions for .date (milliseconds) and .bytes (string payload), which do not round-trip by design. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Re-scope note
Issue #154 cited
CustomFieldValue.swift/CustomFieldValuePayload.swift— those files no longer exist onv1.0.0-beta.3. The remaining actionable hand-written// swiftlint:disable:next cyclomatic_complexitywas inFieldValue+Codable.swift(encodeValue(to:)). The other disables live in generatedOperations.*.Output.swiftand are out of scope.What
Split
encodeValue(to:)into a thin dispatcher +encodeScalar/encodeComplexhelpers so each stays under the complexity threshold and the disable is removed. Behavior, public API, and serialization output unchanged (date→ms math preserved).Closes #154.
Verification
swift build, fullswift test(538 pass), swiftlint--strictclean with the disable removed.