clerk/internal/linter/rules.go (view raw)
| 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 | &UnusedAccount{}, |
| 46 | } |