all repos

clerk @ 8e87a985b56c8eb8aa941f2509e1eca5e4aa9697

missing tooling for ledger/hledger

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

Oleksandr Smirnov Oleksandr Smirnov
olexsmir@gmail.com
linter: remove Description() method, 1 month ago
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 (e *EmptyPostings) CheckEntry(entry ast.Entry) []Find {
11
	txn, ok := entry.(*ast.Transaction)
12
	if !ok {
13
		return nil
14
	}
15
	if len(txn.Postings) == 0 {
16
		return []Find{{
17
			Code:     e.ID(),
18
			Severity: e.Severity(),
19
			Message:  "transaction has no postings",
20
			Span:     txn.Span,
21
		}}
22
	}
23
	return nil
24
}