cl: conf.TypeAbbrSuffix - #883
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #883 +/- ##
==========================================
+ Coverage 88.49% 88.51% +0.01%
==========================================
Files 22 22
Lines 1860 1863 +3
==========================================
+ Hits 1646 1649 +3
Misses 214 214
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:
|
There was a problem hiding this comment.
Review: add TypeAbbrSuffix config field
Clean, well-scoped change. The new TypeAbbrSuffix field is wired consistently through all layers (tool/config.go → tool/gen.go → cl/compile.go → cl/ctx.go), reuses the existing rmSuffix helper, and the logic at cl/ctx.go:344-351 correctly strips the suffix only when the type is not present in TypeAbbr. The golden test config exercises the new path (Remapping TypeAbbr entry replaced with TypeAbbrSuffix: ["ping"]).
Performance & security: No issues. rmSuffix is a pure, allocation-free string slice guarded by HasSuffix, runs only during code generation, and introduces no new trust-boundary surface (it mirrors the existing TypePrefix/TypeSuffix pattern).
Minor / non-blocking
- Field ordering is inconsistent across definitions.
tool/config.goplacesTypeAbbrSuffixbeforeTypeAbbr;cl/compile.goplaces it after; incl/ctx.gotypeAbbrSuffixsits in its own block far fromtypeAbbr. Since the two are semantically coupled, keeping them adjacent and in the same order everywhere would aid readability. rmSuffixis first-match-wins / order-dependent (cl/ctx.go:459). For overlapping suffixes (e.g.["ing", "ping"]),"Remapping"would match"ing"first. This matches the pre-existing helper contract (not a regression), but sinceTypeAbbrSuffixis a new user-facing knob, a note that ordering matters — list longer/more-specific suffixes first — would help. An empty-string entry also short-circuits the loop as a silent no-op.- Naming:
TypeAbbrSuffixreads like "suffix of an abbreviation" rather than "suffix to strip from the Go type name." The doc comment clarifies intent; an inline example (e.g."Remapping" -> "Remap") in the comment would make it clearer at a glance.
No description provided.