feat: improve builder#165
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughAdds ChangesFeature Flag Builder
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 3❌ Failed checks (1 warning, 2 inconclusive)
✅ Passed checks (2 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.12.2)level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies" 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 @@
## main #165 +/- ##
==========================================
- Coverage 68.52% 68.48% -0.05%
==========================================
Files 56 56
Lines 5417 5438 +21
==========================================
+ Hits 3712 3724 +12
- Misses 1494 1498 +4
- Partials 211 216 +5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
NumaryBot
left a comment
There was a problem hiding this comment.
✅ Approve — automated review
The new builder API emits syntactically valid feature declarations and preserves existing BuildProgram behavior. I did not find any discrete regressions introduced by the patch.
No findings.
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
builder/builder_test.go (1)
53-68: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd a dedicated test for invalid-flag panic behavior.
This PR introduces a strict panic contract for invalid flags, but current coverage only asserts the happy path. Add a focused test to lock panic behavior and prevent silent contract drift.
Example test addition
+func TestBuildProgramWithFeatureFlagsInvalidFlagPanics(t *testing.T) { + stmt := builder.StmtSend( + builder.ExprMonetary( + builder.ExprAsset("USD/2"), + builder.ExprNumberBigInt(big.NewInt(1)), + ), + builder.SrcAccount(builder.ExprAccount("src")), + builder.DestAccount(builder.ExprAccount("dest")), + ) + + defer func() { + if recover() == nil { + t.Fatalf("expected panic for invalid feature flag") + } + }() + + builder.BuildProgramWithFeatureFlags([]string{"Invalid-Flag"}, stmt) +}🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@builder/builder_test.go` around lines 53 - 68, The current test coverage only validates the happy path where valid feature flags are passed to the BuildProgramWithFeatureFlags function. Add a new test function that specifically tests the panic behavior when an invalid or unsupported flag is provided to BuildProgramWithFeatureFlags. The test should verify that the function panics with an appropriate error message when given an invalid flag, ensuring the strict panic contract is properly covered and preventing regression of the panic behavior contract.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@builder/builder.go`:
- Around line 175-189: The BuildProgramWithFeatureFlags function validates
featureFlags after calling BuildProgram on the statements, which allows side
effects from BuildProgram to execute even when invalid flags would cause a
panic. Move the flag validation loop that calls checkIsFlagValid before the call
to BuildProgram to ensure invalid flags are caught immediately and prevent any
statement execution or side effects from occurring before the panic.
---
Nitpick comments:
In `@builder/builder_test.go`:
- Around line 53-68: The current test coverage only validates the happy path
where valid feature flags are passed to the BuildProgramWithFeatureFlags
function. Add a new test function that specifically tests the panic behavior
when an invalid or unsupported flag is provided to BuildProgramWithFeatureFlags.
The test should verify that the function panics with an appropriate error
message when given an invalid flag, ensuring the strict panic contract is
properly covered and preventing regression of the panic behavior contract.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 0137bf64-5872-438a-8436-36decab91be4
📒 Files selected for processing (2)
builder/builder.gobuilder/builder_test.go
NumaryBot
left a comment
There was a problem hiding this comment.
✅ Approve — automated review
The new builder helper appears to generate syntactically valid feature declarations for the supported flag format, and existing builder behavior is unchanged.
No findings.
No description provided.