From 3087558fef913791e7c90dcff2ed4df43aa09cae Mon Sep 17 00:00:00 2001 From: closer-claudio Date: Sun, 15 Nov 2026 11:30:07 -0800 Subject: [PATCH] lint: mnd leaves the backlog, the subject's two lengths are named mnd was off for rules/shortsubject/shortsubject.go as part of the onboarding backlog. It finds the two numbers the rule compares a subject with: 90, which a subject must stay under, and 72, which it is better kept within. They are constants now, named for what they are. The rule decides nothing differently: validate/contract_test.go holds both boundaries (72, 73, 89, 90) and passes unchanged. For https://github.com/forkcloser/git-validation/issues/37. Co-Authored-By: Claude Fable 5.2 Signed-off-by: closer-claudio --- .lint-go.yaml | 3 +-- rules/shortsubject/shortsubject.go | 12 ++++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/.lint-go.yaml b/.lint-go.yaml index e772868..db22bf6 100644 --- a/.lint-go.yaml +++ b/.lint-go.yaml @@ -120,8 +120,7 @@ golangci: - gochecknoinits # 1 - revive # 1 - path: ^rules/shortsubject/shortsubject\.go$ - linters: # 7 findings - - mnd # 2 + linters: # 5 findings - revive # 2 - gochecknoglobals # 1 - gochecknoinits # 1 diff --git a/rules/shortsubject/shortsubject.go b/rules/shortsubject/shortsubject.go index 726b341..e2b2dea 100644 --- a/rules/shortsubject/shortsubject.go +++ b/rules/shortsubject/shortsubject.go @@ -8,6 +8,14 @@ import ( "github.com/forkcloser/git-validation/validate" ) +// The two lengths of a subject, in characters: it must be strictly shorter +// than limit, and is better kept within preferred. The description and the +// messages name them too. +const ( + limit = 90 + preferred = 72 +) + // ShortSubjectRule is the rule being registered. var ShortSubjectRule = validate.Rule{ Name: "short-subject", @@ -34,7 +42,7 @@ func ValidateShortSubject(r validate.Rule, c git.CommitEntry) (vr validate.Resul // them; in bytes, 85 accented characters failed the rule. length := utf8.RuneCountInString(c["subject"]) - if length >= 90 { + if length >= limit { vr.Pass = false vr.Msg = "commit subject exceeds 90 characters" @@ -42,7 +50,7 @@ func ValidateShortSubject(r validate.Rule, c git.CommitEntry) (vr validate.Resul } vr.Pass = true - if length > 72 { + if length > preferred { vr.Msg = "commit subject is under 90 characters, but is still more than 72 chars" } else { vr.Msg = "commit subject is 72 characters or less! *yay*"