all repos

clerk @ f3b258b6c2faf2042ec439726a44238041014d24

missing tooling for ledger/hledger

clerk/internal/linter/rule_empty_postings.go (view raw)

Oleksandr Smirnov Oleksandr Smirnov
olexsmir@gmail.com
improve analyzer, 1 day ago
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
}