emacs-eldev / eldev

Elisp development tool
https://emacs-eldev.github.io/eldev/
GNU General Public License v3.0
226 stars 17 forks source link

undefined vars in .dir-locals.el break linting #83

Open sellout opened 1 year ago

sellout commented 1 year ago

I have a .dir-locals.el in my project with

((nil
  (fill-column . 100)
  (indent-tabs-mode . nil)
  (projectile-project-type . nix-flake)
  (sentence-end-double-space . nil)))

and eldev lint doc elisp dumps warnings

`eldev lint` output ``` agenix.el:35: There should be two spaces after a period agenix.el:30: There should be two spaces after a period Found 2 warnings in file ‘agenix.el’ agenix.el:13:0 (fill-column) line length 70 exceeded agenix.el:14:0 (fill-column) line length 70 exceeded agenix.el:24:0 (fill-column) line length 70 exceeded agenix.el:30:0 (checkdoc) There should be two spaces after a period agenix.el:30:0 (fill-column) line length 70 exceeded agenix.el:35:0 (checkdoc) There should be two spaces after a period agenix.el:35:0 (fill-column) line length 70 exceeded agenix.el:61:0 (fill-column) line length 70 exceeded agenix.el:64:0 (indent-character) spaces instead of tabs agenix.el:70:0 (indent-character) spaces instead of tabs agenix.el:71:0 (indent-character) spaces instead of tabs agenix.el:72:0 (indent-character) spaces instead of tabs agenix.el:73:0 (indent-character) spaces instead of tabs agenix.el:73:0 (fill-column) line length 70 exceeded agenix.el:74:0 (indent-character) spaces instead of tabs agenix.el:74:0 (fill-column) line length 70 exceeded agenix.el:75:0 (indent-character) spaces instead of tabs agenix.el:75:0 (fill-column) line length 70 exceeded agenix.el:76:0 (indent-character) spaces instead of tabs agenix.el:77:0 (indent-character) spaces instead of tabs agenix.el:78:0 (indent-character) spaces instead of tabs agenix.el:78:0 (fill-column) line length 70 exceeded agenix.el:79:0 (indent-character) spaces instead of tabs agenix.el:80:0 (indent-character) spaces instead of tabs agenix.el:81:0 (indent-character) spaces instead of tabs agenix.el:84:0 (fill-column) line length 70 exceeded agenix.el:87:0 (fill-column) line length 70 exceeded agenix.el:91:0 (fill-column) line length 70 exceeded agenix.el:93:0 (indent-character) spaces instead of tabs agenix.el:94:0 (indent-character) spaces instead of tabs agenix.el:95:0 (indent-character) spaces instead of tabs agenix.el:96:0 (indent-character) spaces instead of tabs agenix.el:97:0 (indent-character) spaces instead of tabs agenix.el:98:0 (indent-character) spaces instead of tabs agenix.el:99:0 (indent-character) spaces instead of tabs agenix.el:100:0 (indent-character) spaces instead of tabs agenix.el:101:0 (indent-character) spaces instead of tabs agenix.el:102:0 (indent-character) spaces instead of tabs agenix.el:103:0 (indent-character) spaces instead of tabs agenix.el:110:0 (indent-character) spaces instead of tabs agenix.el:111:0 (indent-character) spaces instead of tabs agenix.el:112:0 (indent-character) spaces instead of tabs agenix.el:114:0 (indent-character) spaces instead of tabs agenix.el:115:0 (indent-character) spaces instead of tabs agenix.el:116:0 (indent-character) spaces instead of tabs agenix.el:116:0 (fill-column) line length 70 exceeded agenix.el:117:0 (indent-character) spaces instead of tabs agenix.el:118:0 (indent-character) spaces instead of tabs agenix.el:119:0 (indent-character) spaces instead of tabs agenix.el:120:0 (indent-character) spaces instead of tabs agenix.el:121:0 (indent-character) spaces instead of tabs agenix.el:122:0 (indent-character) spaces instead of tabs agenix.el:123:0 (indent-character) spaces instead of tabs agenix.el:124:0 (indent-character) spaces instead of tabs agenix.el:125:0 (indent-character) spaces instead of tabs agenix.el:126:0 (indent-character) spaces instead of tabs agenix.el:127:0 (indent-character) spaces instead of tabs agenix.el:128:0 (indent-character) spaces instead of tabs agenix.el:129:0 (indent-character) spaces instead of tabs agenix.el:130:0 (indent-character) spaces instead of tabs agenix.el:131:0 (indent-character) spaces instead of tabs agenix.el:132:0 (indent-character) spaces instead of tabs agenix.el:133:0 (indent-character) spaces instead of tabs agenix.el:134:0 (indent-character) spaces instead of tabs Found 64 warnings in file ‘agenix.el’ Linting produced warnings ```

If I then remove the (projectile-project-type . nix-flake) line and re-run eldev lint, it succeeds. Since I don’t have projectile loaded in the Emacs that eldev is using, I’m guessing that the undefined var is causing an error somewhere.

I would assume the bug was in the linter, except that it seems to be happening with two different linters. Also, eldev doesn’t tell me which linter is reporting the warnings, so if this isn’t a bug in eldev, then consider this issue to be about reporting which sub-process eldev is running 😄

doublep commented 1 year ago

Linter elisp requires quite extensive configuration to be useful, that's why it is no longer enabled by default: you have to name it explicitly. Anyway, would be nice to have a link to the project to see for myself.

sellout commented 1 year ago

Here’s the branch where I added .dir-locals.el: https://github.com/sellout/agenix.el/tree/nix-flake

So yeah … elisp seems to be the bulk of them. If I run package only, I get no warnings; doc only, I get two warnings; and elisp only, I get 64 warnings. So both doc and elisp are complaining. However, package doesn’t have any warnings that would be silenced by the .dir-locals.el settings, so I think I can’t actually determine if it’s behaving.

At the moment, it looks like a general issue affecting all linters, so I’m inclined to think it is eldev somehow. But I’ll try to dig in deeper when I can.

doublep commented 1 year ago

The problem appears to be that Elisp linter generates the autoloads file (even though the project doesn't have any autoloads) and then complains about it.

Note that the linter tool hasn't seen any commits in quite a while, not sure how useful it is to report bugs in it.

doublep commented 1 year ago

By the way, here is a bit of configuration from CIDER:

(setf eldev-lint-default '(elisp))
(with-eval-after-load 'elisp-lint
  ;; We will byte-compile with Eldev.
  (setf elisp-lint-ignored-validators '("package-lint" "fill-column" "byte-compile")
        enable-local-variables        :safe))

I guess autoloads are not generated by Elisp linter if byte-compile validator is skipped.