DamienCassou / flycheck-hledger

hledger checker for flycheck
GNU General Public License v3.0
13 stars 6 forks source link

Latest code not compatible with latest hledger #11

Closed DamienCassou closed 2 years ago

DamienCassou commented 2 years ago

Here is what hledger 1.25 outputs for an unbalanced transaction:

hledger: "/home/cassou/configuration/ledger/accounting.hledger" (lines 3335-3343)
could not balance this transaction:
real postings' sum should be 0 but is: -0.20€
2022-03-21 ...

And here is how the matching code looks in flycheck-hledger:

(error line-start "hledger: " (file-name) ":" line "-" end-line "\n"
          (message (zero-or-more line-start (zero-or-more not-newline) "\n")) "\n")

As you can see, there are double-quotes around the filename in the error message but not in the matching code. These double-quotes were removes by 0f11d6ea4d6f85b7f1cb243815f7b967a080e6d0:

-   (error line-start "hledger: balance assertion: \"" (file-name) "\" (line " line ", column " column ")\n"
+   (error line-start "hledger: " (file-name) ":" line "-" end-line "\n"
DamienCassou commented 2 years ago

It seems the undeclared account error message is also wrong.

DamienCassou commented 2 years ago

Here is a patch to fix both but there are probably more to fix:

@@ -72,7 +72,7 @@ (flycheck-define-checker hledger
   :error-patterns
   (
    ;; Unbalanced transaction:
-   (error line-start "hledger: " (file-name) ":" line "-" end-line "\n"
+   (error line-start "hledger: \"" (file-name) "\" (lines " line "-" end-line ")\n"
           (message (zero-or-more line-start (zero-or-more not-newline) "\n")) "\n")
    ;; Failing balance assertion:
    (error line-start "hledger: balance assertion: " (file-name) ":" line ":" column "\n"
@@ -82,7 +82,7 @@ (flycheck-define-checker hledger
    (error line-start "hledger: " (message "this regular expression" (zero-or-more not-newline)) "\n")
    ;; Undeclared account:
    (error line-start "hledger: " (message) "\n"
-          "in transaction at: " (file-name) ":" line "-" end-line "\n")
+          "in transaction at: \"" (file-name) "\" (lines " line "-" end-line ")\n")
    ;; Undeclared commodity:
    (error line-start "hledger: " (message) "\n"  ; hledger: prefix
           "at: " (file-name) ":" line "-" end-line "\n")
simonmichael commented 2 years ago

It turns out #10's commit 0f11d6e actually updates flycheck-hledger for current hledger master, not hledger 1.25. It was already compatible with 1.25. I'm sorry for the confusion.

DamienCassou commented 2 years ago

It turns out https://github.com/DamienCassou/flycheck-hledger/pull/10's commit https://github.com/DamienCassou/flycheck-hledger/commit/0f11d6ea4d6f85b7f1cb243815f7b967a080e6d0 actually updates flycheck-hledger for current hledger master, not hledger 1.25. It was already compatible with 1.25.

Thank you for your analysis. I'm reverting your PR in #12. Feel free to reopen it when 1.26 is out.

I'm sorry for the confusion.

Don't worry about that. Only those who do things make mistakes :-).