Repository navigation
This release makes the naming rule's rename fix opt-in. It also fixes five wrong reports or fixes, which a review of the formal specs against the code found.
Caution
Behavior changes
-fixno longer renames for the naming rule unlessrules.naming.fix: trueis set. The report is still made (#391).- The naming rule's message changed. A tool that matches the message text needs updating. Baseline keys do not include the message, so no recorded finding reports again.
survey -format=jsonaddschecks.configs[].rules.fix(#392).
The naming rule's rename is opt-in
A rename can choose a name, but not a place. The tool sees the file a declaration is in, not the file it belongs to. A prefix that reads badly usually means the declaration is in the wrong file. So the message now offers a move first, and names the rename as one candidate.
| Before | Now | |
|---|---|---|
-fix on a qualify report |
Renames it | Renames it only with rules.naming.fix: true |
| The message | ...; rename it to userHelper, or to another name that carries "user" |
...; move it to the file it belongs to, or give it a name that carries "user" (userHelper is one candidate, not necessarily the best) |
inspect's names[].fixable |
Whether the rename is safe | Same. It still answers with the key off |
rules.naming.fix is a config key, not a flag. An analyzer flag does not reach go vet or golangci-lint.
Fixes
| What was wrong | Now | PR |
|---|---|---|
The filter report blamed an only above for files that the same config's omit removed |
It counts only the files an only above removes |
#372 |
A field's //declscope:ignore boundary was reported unused when a build-excluded file filled it through a named pointer type. A defined type or a type parameter did the same |
The ignore is kept, as in a run that reads that file | #373 |
The strict fix deleted a directive that such a file still needed |
The fix is withheld | #373 |
| The rename of an embedded type could uncover a deeper method of the old name, and a type assertion would change its answer | The rename is withheld when an interface of the package asks for the old name | #380 |
The boundary fix on a type could leave a member's own //declscope:shared binding nothing |
The type's fix is withheld | #381 |
In each case of a withheld fix, the report is still made.
Skills
declscope-authoringhas a new section, "When-fixrenames". With the key on,-fixrenames every reported name at once. Read-fix -diff, judge each rename bynaming.md, and take only the edits you accept (#391).naming.mdgains five patterns from a review of this repository. They are:- the suggested rename is one option, not the answer
- a helper copied under each file's prefix
- a wrapper written only to carry a namespace
- a helper in a verb-named file that does not perform the verb
- a recorder named as a predicate
declscope-adoptionno longer renames in bulk through-fix.
Upgrading
| Who | Do |
|---|---|
Runs -fix with rules.naming.qualify on, and wants the renames |
Set rules.naming.fix: true, and read the renames in -fix -diff |
| Matches the naming rule's message text | Update the pattern |
| Everyone else | Nothing |
Specs
The formal specs were checked against the code. 23 of them are now proved by induction, up from 20. The new ones are rename_reserved, rename_selections and type_fix_members. The other refactors rename internal helpers and the package internal/pointer to internal/implicitfield. No public API changes.
Install
mise use "github:mpyw/declscope@0.25.0"Full changelog: v0.24.5...v0.25.0
Changelog
- c901bd8 docs(readme): say why the rename is opt-in in prose, not a table (#393)
- d1e4037 docs(spec): keep each spec's claim rows together, so As above names its own scope (#384)
- 2dc6d2a feat(qualify): make the rename fix opt-in with rules.naming.fix, and teach the skills when to take it (#391)
- c852286 feat(survey): report rules.naming.fix in checks.configs[].rules (#392)
- 79c1052 fix(filter): do not blame an only above for what an omit removed (#372)
- f76e6cf fix: keep a field's boundary ignore an excluded file reaches through any literal type (#373)
- 592f5b2 fix: withhold a type's boundary fix that would leave a member's own shared directive unused, and prove the type fix's member edits (#381)
- b50b70b refactor(cmd): name load.go's helpers for what they return, and move inspect's and the parallel runner out (#385)
- f388675 refactor(shrink): name helpers for what they do, and move the build-excluded stage and pattern resolution where they belong (#388)
- 4a7f8ae refactor: name internal helpers for what they do, and share four from the core (#387)
- 5ec72b7 refactor: name measure and config helpers for what they hold (#386)
- 7219bad refactor: rename package pointer to implicitfield (#389)
- 6e826bc spec(naming_rules): model where a method is read from, and the toolchain's names (#383)
- 9c45d76 spec(rename): model non-Go files, directive text, selections and reserved names, and withhold an embedded type an interface asks for (#380)
- fa625ce spec(shrink): model the guessed write, non-Go packages and the remaining withholding reasons (#378)
- 50c678f spec(shrink): model the nested build doubt that withholds fixes and keeps reports (#374)
- b4de016 spec(unused_bind): pin both directions of binding (#375)
- 170938d spec(unused_ignore): leave duplicate ignores out, scope away module-wide rules, and model a file-level answer to a declaration's ignore (#377)
- 3a378c1 spec(unused_modes): withhold the strict fix only where the code does (#376)
- 9ca920b spec: give surplus.fsl and surplus_strict.fsl the one reach set the code tests (#379)
- 4691c59 spec: witness every scope knob per kind, model the baselined type in fix_members, and compare the two filter orders (#382)