From c4972f44237b4dc6a37220bd390cbf6c4f560e9b Mon Sep 17 00:00:00 2001 From: "@mpyw" Date: Thu, 8 Oct 2026 11:16:43 +0900 Subject: [PATCH] refactor: order declarations by reach as declscope 0.20.4 refines it boolSetting and its UnmarshalYAML method are one type unit now, so the exported File type goes before it. Co-Authored-By: Claude Opus 5.5 --- internal/config/config.go | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/internal/config/config.go b/internal/config/config.go index 0b1dbf9..0097048 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -68,21 +68,6 @@ var surplusModes = rule.SurplusModeSet{rule.SurplusModeOff, rule.SurplusModeLoos // The values rules.unused accepts, from reporting least to most. var unusedModes = rule.UnusedModeSet{rule.UnusedModeOff, rule.UnusedModeLoose, rule.UnusedModeStrict} -// boolSetting is a true/false key, with its own error naming the two values it -// takes rather than the parser's "cannot unmarshal". -type boolSetting struct { - set bool - value bool -} - -func (b *boolSetting) UnmarshalYAML(node *yaml.Node) error { - if err := node.Decode(&b.value); err != nil { - return fmt.Errorf("want true or false") - } - b.set = true - return nil -} - // File is the on-disk configuration. Every field is optional, and no setting // has a zero value that means anything, so a field left empty is skipped by // Apply: omitting a key keeps the built-in default rather than silently @@ -102,6 +87,21 @@ type File struct { path string } +// boolSetting is a true/false key, with its own error naming the two values it +// takes rather than the parser's "cannot unmarshal". +type boolSetting struct { + set bool + value bool +} + +func (b *boolSetting) UnmarshalYAML(node *yaml.Node) error { + if err := node.Decode(&b.value); err != nil { + return fmt.Errorf("want true or false") + } + b.set = true + return nil +} + // Each section is a named type so that go-yaml's strict-decoding error can name // the section a misspelled key sits in, rather than printing the anonymous // struct's whole type literal.