all repos

clerk @ 936917268b03e2cc3e324e0a632172cfdcbc5f69

missing tooling for ledger/hledger

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

Oleksandr Smirnov Oleksandr Smirnov
olexsmir@gmail.com
linter: add missing-payee rule, 1 month ago
1
package linter
2
3
import (
4
	"olexsmir.xyz/clerk/journal/ast"
5
6
	"olexsmir.xyz/clerk/journal/semantic"
7
)
8
9
type RuleID string
10
11
// Rule is the best interface that every rule must implement.
12
type Rule interface {
13
	ID() RuleID
14
	Severity() Severity
15
}
16
17
// EntryChecker implements per-entry linting.
18
type EntryChecker interface {
19
	Rule
20
	CheckEntry(entry ast.Entry) []Find
21
}
22
23
// JournalChecker implements whole-journal linting using the semantic context.
24
type JournalChecker interface {
25
	Rule
26
	CheckJournal(ctx *semantic.Context) []Find
27
}
28
29
// Rules is list of all available rules.
30
var Rules = []Rule{
31
	&ParseError{},
32
	&EmptyPostings{},
33
	&OmittedPrecision{},
34
	&MissingCommodity{},
35
	&MissingStatus{},
36
	&MissingPayee{},
37
	&AccountDepthLimit{MaxDepth: 4},
38
	&MultipleOmittedAmounts{},
39
	&OrderDate{},
40
	&DuplicatedAccount{},
41
	&DuplicatedCommodity{},
42
	&UndeclaredCommodity{},
43
	&UndeclaredAccount{},
44
	&UnbalancedTransaction{},
45
}