all repos

clerk @ 17c786e

missing tooling for ledger/hledger

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

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