clerk/internal/linter/rule_duplicated_account.go (view raw)
| 1 | package linter |
| 2 | |
| 3 | import ( |
| 4 | "fmt" |
| 5 | |
| 6 | "olexsmir.xyz/clerk/internal/analyzer" |
| 7 | ) |
| 8 | |
| 9 | // DuplicatedAccount flags account declarations that appear more than once. |
| 10 | type DuplicatedAccount struct{} |
| 11 | |
| 12 | func (DuplicatedAccount) ID() RuleID { return "duplicated-account" } |
| 13 | func (DuplicatedAccount) Severity() Severity { return SeverityWarning } |
| 14 | func (d *DuplicatedAccount) CheckJournal(an *analyzer.Analysis) []Find { |
| 15 | var finds []Find |
| 16 | for _, info := range an.Accounts { |
| 17 | if len(info.Directives) <= 1 { |
| 18 | continue |
| 19 | } |
| 20 | for _, ad := range info.Directives { |
| 21 | finds = append(finds, Find{ |
| 22 | Code: d.ID(), |
| 23 | Severity: d.Severity(), |
| 24 | Message: fmt.Sprintf("duplicated account declaration: %s", ad.Account.String()), |
| 25 | Span: ad.Account.Span, |
| 26 | }) |
| 27 | } |
| 28 | } |
| 29 | return finds |
| 30 | } |