clerk/internal/linter/rule_empty_postings.go (view raw)
| 1 | package linter |
| 2 | |
| 3 | import "olexsmir.xyz/clerk/internal/analyzer" |
| 4 | |
| 5 | // EmptyPostings flags transactions that have no postings. |
| 6 | type EmptyPostings struct{} |
| 7 | |
| 8 | func (EmptyPostings) ID() RuleID { return "empty-postings" } |
| 9 | func (EmptyPostings) Severity() Severity { return SeverityError } |
| 10 | func (e *EmptyPostings) CheckJournal(an *analyzer.Analysis) []Find { |
| 11 | var finds []Find |
| 12 | for _, txn := range an.Transactions { |
| 13 | if len(txn.Postings) == 0 { |
| 14 | finds = append(finds, Find{ |
| 15 | Code: e.ID(), |
| 16 | Severity: e.Severity(), |
| 17 | Message: "transaction has no postings", |
| 18 | Span: txn.Span, |
| 19 | }) |
| 20 | } |
| 21 | } |
| 22 | return finds |
| 23 | } |