clerk/internal/linter/rule_empty_postings.go (view raw)
| 1 | package linter |
| 2 | |
| 3 | import "olexsmir.xyz/clerk/journal/ast" |
| 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 (EmptyPostings) Description() string { return "transaction has no postings" } |
| 11 | func (e *EmptyPostings) CheckEntry(entry ast.Entry) []Find { |
| 12 | txn, ok := entry.(*ast.Transaction) |
| 13 | if !ok { |
| 14 | return nil |
| 15 | } |
| 16 | if len(txn.Postings) == 0 { |
| 17 | return []Find{{ |
| 18 | Code: e.ID(), |
| 19 | Severity: e.Severity(), |
| 20 | Message: e.Description(), |
| 21 | Span: txn.Span, |
| 22 | }} |
| 23 | } |
| 24 | return nil |
| 25 | } |