clerk/internal/linter/rules.go (view raw)
| 1 | package linter |
| 2 | |
| 3 | import "olexsmir.xyz/clerk/journal/ast" |
| 4 | |
| 5 | type RuleID string |
| 6 | |
| 7 | // Rule is the best interface that every rule must implement. |
| 8 | type Rule interface { |
| 9 | ID() RuleID |
| 10 | Severity() Severity |
| 11 | } |
| 12 | |
| 13 | // EntryChecker implements pre entry linting during. |
| 14 | type EntryChecker interface { |
| 15 | Rule |
| 16 | CheckEntry(entry ast.Entry) []Find |
| 17 | } |
| 18 | |
| 19 | // JournalChecker implements whole journal linting. |
| 20 | type JournalChecker interface { |
| 21 | Rule |
| 22 | CheckJournal(journal *ast.Journal) []Find |
| 23 | } |
| 24 | |
| 25 | // Rules is list of all available rules. |
| 26 | var Rules = []Rule{ |
| 27 | &ParseError{}, |
| 28 | &EmptyPostings{}, |
| 29 | &OmittedPrecision{}, |
| 30 | &MissingCommodity{}, |
| 31 | &MissingStatus{}, |
| 32 | &AccountDepthLimit{MaxDepth: 4}, |
| 33 | &MultipleOmittedAmounts{}, |
| 34 | &OrderDate{}, |
| 35 | &DuplicatedAccount{}, |
| 36 | &DuplicatedCommodity{}, |
| 37 | &UndeclaredAccount{}, |
| 38 | } |