Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check command should not stop after the first error #2203

Open
pwseo opened this issue Jun 8, 2024 · 4 comments
Open

check command should not stop after the first error #2203

pwseo opened this issue Jun 8, 2024 · 4 comments
Labels
A-WISH Some kind of improvement request, hare-brained proposal, or plea. check

Comments

@pwseo
Copy link

pwseo commented Jun 8, 2024

Currently, if one turns on strict mode or uses the check command (eg. check accounts, check payees), hledger stops after the first undeclared account/payee is encountered.

While this is technically correct, it makes one repeat the edit-check-fix cycle more times than should be needed.

Here's an example:

$ hledger --version
hledger 1.34, linux-x86_64
$ cat a.j
2024-06-08 A | Txn 1
    Undeclared:One      +5 EUR
    Undeclared:Another  -5 EUR

2024-06-08 B | Txn 2
    Undeclared:Another  +5 EUR
    Undeclared:One      -5 EUR
$ hledger -f a.j accounts
Undeclared:Another
Undeclared:One
$ hledger -f a.j payees
A
B

As it stands, we have 2 undeclared accounts and 2 undeclared payees. Let's check them with hledger:

$ hledger -f a.j check accounts
hledger: Error: /tmp/tmp.EQDr9awkqd/a.j:2:
  | 2024-06-08 A | Txn 1
2 |     Undeclared:One               5 EUR
  |     ^^^^^^^^^^^^^^
  |     Undeclared:Another          -5 EUR

Strict account checking is enabled, and
account "Undeclared:One" has not been declared.
Consider adding an account directive. Examples:

account Undeclared:One
account Undeclared:One    ; type:A  ; (L,E,R,X,C,V)

The same thing happens for payees: hledger never sees payee B and thus never complains about it because it quits after reporting A is not declared.

I think it would be helpful if hledger continued processing the data and collected as much undeclared accounts / payees as possible before presenting them to the user.
Perhaps this would not belong in the -s argument's default behaviour (so as not to overwhelm new users), but only in the explicit check command (it does make sense to report all undeclared accounts if I ask to check accounts, I think).

@pwseo pwseo changed the title hledger check command should not stop after the first error check command should not stop after the first error Jun 8, 2024
@simonmichael simonmichael added A-WISH Some kind of improvement request, hare-brained proposal, or plea. check labels Jun 8, 2024
@simonmichael
Copy link
Owner

I'd be happy to test a PR exploring this. Some checks are relatively easy to continue from on failure; others are not.

But I don't find it causing pain in practice, do you ? I don't have a slow edit-check-fix cycle.

@pwseo
Copy link
Author

pwseo commented Jun 10, 2024

I'd be happy to test a PR exploring this. Some checks are relatively easy to continue from on failure; others are not.

Maybe one day. Right now my Haskell skills are subpar and I have no familiarity with hledger's code base (sadly). I'll try and change that in the future.

But I don't find it causing pain in practice, do you ? I don't have a slow edit-check-fix cycle.

In a carefully maintained chart of accounts this isn't problematic (especially if one has some kind of auto-complete for account names), but scenarios vary.
I recently started tracking my finances with hledger and there was a lot of checking and fixing to do in the beginning (because my chart of accounts wasn't fully developed).

Still, on a more general note, I think having the check command try and report as many errors as it can is a positive change, while passing the --strict flag should still quit after the first error is found.

@simonmichael
Copy link
Owner

Not detracting from your point, but remember strict account checking is optional and simply avoiding it is another option when the chart of accounts hasn't yet stabilised.

@pwseo
Copy link
Author

pwseo commented Jun 10, 2024

Yes, I know, but strictness checking is also the only way to know which accounts have not been declared and are being used. One can always get the used accounts' listing from a non-strict hledger accounts, but it has its downsides.

Thank you for the suggestion, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-WISH Some kind of improvement request, hare-brained proposal, or plea. check
Projects
None yet
Development

No branches or pull requests

2 participants