;doc:check: edits

This commit is contained in:
Simon Michael 2025-04-24 10:53:44 -10:00
parent fea127fcb5
commit 650901901f

View File

@ -36,59 +36,59 @@ These important checks are performed by default, by almost all hledger commands:
- **autobalanced** - all transactions are [balanced](#postings), - **autobalanced** - all transactions are [balanced](#postings),
after inferring missing amounts and conversion [costs] where possible, after inferring missing amounts and conversion [costs] where possible,
and then converting to cost. and then converting to cost.
This ensures that each individual transaction is well formed. This ensures that each transaction's entry is well formed.
- **assertions** - all [balance assertions] in the journal are passing. - **assertions** - all [balance assertions] in the journal are passing.
Balance assertions are like canaries in your journal, they catch many problems. Balance assertions are a strong defense against errors; they help catch many problems.
They can get in the way sometimes; you can disable them temporarily with `-I`/`--ignore-assertions` You can disable this check by adding `-I`/`--ignore-assertions` to a command or to your config file.
(unless overridden with `-s`/`--strict` or `hledger check assertions`). When you want to re-enable it, use `-s`/`--strict` or `hledger check assertions`.
### Strict checks ### Strict checks
These additional checks are performed by any command when the `-s`/`--strict` flag is used ([strict mode]). These additional checks are performed by any command when the `-s`/`--strict` flag is used ([strict mode]).
Strict mode always enables the balance assertions check, also. Strict mode also always enables the `assertions` check.
These provide extra error-catching power when you are serious about keeping your data clean and free of typos: These provide extra error-catching power when you are serious about keeping your data clean and free of typos:
- **balanced** - like `autobalanced`, but in [conversion transactions](#recording-costs), - **balanced** - more strict than `autobalanced`: any commodity conversions must be explicit,
costs must be written explicitly. This ensures some redundancy in the entry, which helps prevent typos. using either [cost notation](#recording-costs) or [equity postings](#equity-conversion-postings).
This prevents wrong conversions caused by typos.
- **commodities** - all commodity symbols used [must be declared](#commodity-error-checking). - **commodities** - all commodity symbols used must be [declared](#commodity-error-checking).
This guards against mistyping or omitting commodity symbols. This guards against mistyping or omitting commodity symbols.
commodity declarations also set their precision for display and transaction balancing.
- **accounts** - all account names used [must be declared](#account-error-checking). - **accounts** - all account names used must be [declared](#account-error-checking).
This prevents the use of mis-spelled or outdated account names. This prevents the use of mis-spelled or outdated account names.
### Other checks ### Other checks
These other checks are not wanted by everyone, but can be run using the `check` command: These are not wanted by everyone, but can be run using the `check` command:
- **ordereddates** - within each file, transactions are ordered by date. - **tags** - all tags used must be [declared](#tag-directive).
This is a simple and effective error catcher, and you should use it. This prevents mis-spelled tag names.
Alas! not everyone wants it. If you do, use `hledger check -s ordereddates`. Note hledger fairly often finds unintended tags in comments.
When enabled, this check is performed early, before balance assertions
(because copy-pasted dates are often the root cause of balance assertion failures).
- **payees** - all payees used by transactions [must be declared](#payee-directive). - **payees** - all payees used in transactions must be [declared](#payee-directive).
This will force you to always use known/declared payee names. This will force you to declare any new payee name before using it.
For most people this is a bit too restrictive. Most people will probably find this a bit too strict.
- **tags** - all tags used by transactions [must be declared](#tag-directive). - **ordereddates** - within each file, transactions must be ordered by date.
This prevents mistyped tag names. This is a simple and effective error catcher. It's not included in strict mode,
but you can add it by running `hledger check -s ordereddates`.
If enabled, this check is performed before balance assertions.
- **recentassertions** - all accounts with balance assertions must have - **recentassertions** - all accounts with balance assertions must have one that's
a balance assertion within the last 7 days before their latest posting. within the 7 days before their latest posting.
This encourages you to add balance assertions fairly regularly for This will encourage adding balance assertions for your active asset/liability accounts,
your active asset/liability accounts, which in turn should encourage which in turn should encourage you to reconcile regularly with those real world balances -
you to check and reconcile with their real world balances fairly regularly. another strong defense against errors.
[`close --assert`](#close---assert) can be helpful. [`hledger close --assert`](#close---assert) can help generate assertion entries.
(The older balance assertions become redundant; you can remove them Over time the older assertions become somewhat redundant, and you can remove them if you like
periodically, or leave them in place, perhaps commented, as documentation.) (they don't affect performance much, but they add some noise to the journal).
- **uniqueleafnames** - no two accounts may have the same leaf name. - **uniqueleafnames** - no two accounts may have the same last account name part
The leaf name is the last colon-separated part of an account name, eg (eg the `checking` in `assets:bank:checking`).
`checking` in `assets:bank:checking`. This ensures each account can be matched by a unique short name, easier to remember and to type.
This encourages you to keep those unique, effectively giving each account
a short name which is easier to remember and to type in reporting commands.
### Custom checks ### Custom checks