Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughThis PR introduces parameter validation for the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 5 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Fix all issues with AI agents
In `@internal/cmd/params_validation.go`:
- Around line 82-92: The negated compound condition in isJSONParams (currently
written as if !((strings.HasPrefix(input, "{") && strings.HasSuffix(input, "}"))
|| (strings.HasPrefix(input, "[") && strings.HasSuffix(input, "]")) ) { return
false }) should be rewritten to satisfy the linter by removing the outer
negation using De Morgan's law: replace the negated OR with the equivalent AND
of negations (i.e., !(A&&B) && !(C&&D)) or, more readably, invert the branch to
check the positive case ((A&&B) || (C&&D)) and return false in the else branch;
update the condition in isJSONParams accordingly referencing the same
HasPrefix/HasSuffix checks.
- Around line 20-22: paramTokenRegex uses an incorrect subpattern for
backtick-quoted values (`(?:\\"|[^"]*)`) that matches non-quote characters
instead of non-backtick characters; update the regex used by paramTokenRegex to
use a backtick-safe pattern (e.g., `[^`]*` for the backtick-quoted branch) so
backtick-quoted tokens like `echo "message"` are tokenized correctly, and make
the identical fix to the same pattern occurrence in the params validation logic
in the spec package (note: leave the separate backtickRegex used for evaluation
unchanged).
- Around line 37-55: In validateStartPositionalParamCount, avoid failing when
the user supplied only named params: after extracting provided tokens (from
extractProvidedParamTokens) and before comparing got :=
countPositionalParams(provided) to expected :=
countDeclaredPositionalParams(...), detect that there are zero positional tokens
(got == 0) or that all provided tokens are named and in that case return nil
(i.e., skip the positional-count check); update the check around
countPositionalParams/provide handling so only cases with actual positional
tokens trigger the got != expected error.
🧹 Nitpick comments (4)
internal/cmd/params_validation.go (2)
102-118: Consider usingstringutil.RemoveQuotesfor consistency with the rest of the codebase.The manual quote-stripping logic (
strings.Trim+strings.ReplaceAll) diverges from the existingstringutil.RemoveQuotesutility (which usesstrconv.Unquoteand handles more edge cases). Since this is only used for counting tokens the impact is low, but aligning with the shared utility reduces maintenance surface.
130-142:countDeclaredPositionalParamsnever returns an error but haserrorin its signature.The function always returns
nilfor the error. If no error path is anticipated, simplify the return type to justint. This avoids unnecessary error-checking boilerplate at the call site (line 47-49).internal/cmd/start_test.go (2)
153-157: Userequire.NoErrorinstead ofassert.NoErrorfor consistency.The coding guidelines and retrieved learnings specify using
stretchr/testify/requirefor assertions. Whileassertvsrequiredoesn't matter functionally here (last statement), mixing both packages in the same file creates inconsistency.Suggested fix
- assert.NoError(t, err) + require.NoError(t, err)And drop the
assertimport on line 12 if no other usages remain.Based on learnings: "Use
stretchr/testify/requirefor assertions and shared fixtures frominternal/testinstead of duplicating mocks."
108-141: Consider adding a test case for JSON params bypassing positional count validation.The code in
extractProvidedParamTokensexplicitly skips validation for JSON input (isJSONParams→skipValidation=true), but no test exercises this path. A subtest like"AcceptsJSONParamsWithoutPositionalCount"passing--params '{"key":"value"}'to a DAG with positional defaults would close the gap.Based on learnings: "Co-locate Go tests as
*_test.gofiles; favour table-driven cases and cover failure paths."
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1663 +/- ##
==========================================
- Coverage 70.18% 69.70% -0.48%
==========================================
Files 345 347 +2
Lines 38664 38957 +293
==========================================
+ Hits 27135 27154 +19
- Misses 9361 9479 +118
- Partials 2168 2324 +156
... and 19 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
fixes #1660
Summary by CodeRabbit
Release Notes
New Features
Bug Fixes