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

Allow checkers convert suspicious state to non-standard errors #1795

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

doublep
Copy link
Member

@doublep doublep commented May 31, 2020

This implements what is proposed in issue #1787.

Rationale: Eldev (for example) can fail before even starting to byte-compile .el file. For example, because package headers are missing, because a dependency cannot be downloaded, because Eldev is too old — multitude of reasons. So, it can return nonzero exit status, but there are no byte-compilation warnings/errors in the output. Flycheck treats this as "suspicious", gives an ugly message and eventually disables the checker if it fails like this too often.

With the proposed change I would be able to add

:handle-suspicious flycheck-eldev--suspicious-state-handler

to the checker definition, with the function being something like this:

(defun flycheck-eldev--suspicious-state-handler (checker _exit-status output)
  (let ((message (string-trim output)))
    ;; Don't add clarification to a few obvious errors.
    (unless (string-match-p (rx bos "Dependency " (1+ any) " is not available") message)
      (setf message (concat message "\n\n" flycheck-eldev-general-error)))
    `(,(flycheck-error-new-at 1 1 'error message :checker checker))))

@cpitclaudel
Copy link
Member

Thanks, that's an interesting approach. But why not do that on the eldev side? Could you pass it a flag to say "please report all your errors with a line and a column"?

@doublep
Copy link
Member Author

doublep commented Jun 9, 2020

But why not do that on the eldev side? Could you pass it a flag to say "please report all your errors with a line and a column"?

Because the errors in question have nothing to do with the file Flycheck byte-compiles. They can happen even before the file is looked at. It would be strange to report errors like "foo.el:1: Error: Dependency ‘dashe’ 2.12.1 is not available" when I made a typo in bar-pkg.el.

You once mentioned a Haskell checker that can autoinstall dependencies. I'd guess it can also fail for reasons unrelated to the file being checked (when it fails to install dependencies) and then "suspicious" state is triggered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants