You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Omit unused numeric enum parse maps with noparse - #328
--noparse currently leaves a numeric enum's reverse lookup map in the output even when no parse function uses it. Emit that map alongside the parse function so it is omitted when parsing is disabled.
Maps needed by private parsers for marshal, SQL, flags, or MustParse remain generated. String enums also retain their lookup map because IsValid still uses it. Extend the existing regression cases and regenerate the noparse example.
Numeric regression fails against the original template; string and marshal controls pass.
go test -race -shuffle=on ./...: passed.
go test -race -shuffle=on --tags=example ./example: passed.
go vet ./..., formatting and git diff --check: passed.
After make deps, complete make generate passes and leaves the committed checkout clean. The earlier attempt without mockgen failed; no generated failure was treated as a passing check.
Other platforms and the Go 1.26 CI lane were not run locally. No binary-size or runtime-performance claim is made. This contribution was prepared with AI assistance.
Summary by CodeRabbit
Bug Fixes
Corrected generated enum lookup maps when parsing is disabled, omitting unnecessary maps while retaining those needed for validation or marshaling.
Tests
Added coverage for lookup-map behavior across integer and string enums, including enums with marshaling support.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: 5c0c8677-bd7f-488a-a962-9763300d9116
📥 Commits
Reviewing files that changed from the base of the PR and between ad6b63d and e38adfa.
📒 Files selected for processing: 3
example/noparse_enum.go
generator/enum.tmpl
generator/generator_test.go
💤 Files with no reviewable changes: 1
example/noparse_enum.go
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.
📝 Walkthrough
The enum template now omits lookup maps when parsing is disabled. Tests cover map generation for integer and string enums, including marshal support. The example removes an unused lookup map.
The template emits lookup maps only when parsing is enabled. Tests check map output for integer enums, string enums, and marshal support. The example removes an unused map.
No concrete merge-blocking risk remains in the reviewed changes; the map is retained for generated features that need it.
Pre-merge checks: 5
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title clearly and concisely describes the main change: omitting unused numeric enum parse maps when noparse is enabled.
Linked Issues check
The change satisfies issue [#313]. generator/enum.tmpl now emits _{{.enum.Name}}Value inside the .generateParse block. The generated example/noparse_enum.go omits _UnparsedValuesValue, while…
Out of Scope Changes check
The changed files stay within issue [#313]. The template change implements conditional map generation. The generator test updates verify the required numeric, string, and marshal cases. The regenerate…
Docstring Coverage
Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 1 files. (1 skipped: 1 …
Full details: Linked Issues check
Explanation
The change satisfies issue [#313]. generator/enum.tmpl now emits _{{.enum.Name}}Value inside the .generateParse block. The generated example/noparse_enum.go omits _UnparsedValuesValue, while UnparsedString retains its lookup map for IsValid. The reported regression checks also cover numeric no-parse output and numeric marshal output.
Full details: Out of Scope Changes check
Explanation
The changed files stay within issue [#313]. The template change implements conditional map generation. The generator test updates verify the required numeric, string, and marshal cases. The regenerated noparse example records the expected output. No unrelated change is shown.
Full details: Docstring Coverage
Explanation
Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 1 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches
🧪 Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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 @coderabbitai help to get the list of available commands.
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
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.
--noparsecurrently leaves a numeric enum's reverse lookup map in the output even when no parse function uses it. Emit that map alongside the parse function so it is omitted when parsing is disabled.Maps needed by private parsers for marshal, SQL, flags, or MustParse remain generated. String enums also retain their lookup map because
IsValidstill uses it. Extend the existing regression cases and regenerate thenoparseexample.Fixes #313.
Validation on macOS arm64, Go 1.25.5:
go test -race -shuffle=on ./...: passed.go test -race -shuffle=on --tags=example ./example: passed.go vet ./..., formatting andgit diff --check: passed.make deps, completemake generatepasses and leaves the committed checkout clean. The earlier attempt without mockgen failed; no generated failure was treated as a passing check.Other platforms and the Go 1.26 CI lane were not run locally. No binary-size or runtime-performance claim is made. This contribution was prepared with AI assistance.
Summary by CodeRabbit