Linting has always been a thing that interested me.
* checkdoc
I did quite the serious checkdoc overhaul on proof-general and debbugs.
Both of those also included running the spell checker by adding a local
dictionary contained in a "checkdoc-config.el" file which got checked
into both of those projects.
I just pushed a fix for 40ish checkdoc warnings but we do have quite a
few more.
* byte compiler
I've also fiddled a bit with the Emacs byte compiler to try and add more
diagnostics. For example one can enable an extra unused return value
warning with the following patch to Emacs, but it has a lot of false
positives.
#+begin_src diff
diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el
index a596dee6844..2a7313244bf 100644
--- a/lisp/emacs-lisp/byte-opt.el
+++ b/lisp/emacs-lisp/byte-opt.el
@@ -485,6 +485,14 @@ byte-optimize-form-code-walker
(or byte-compile-delete-errors
(eq tmp 'error-free)))))
(byte-compile-log " %s called for effect; deleted" fn)
+ (unless (eq (car form) 'car-safe)
+ (byte-compile-warn-x
+ (car form)
+ "value from call to `%s' is unused%s"
+ (car form)
+ (cond ((eq (car form) 'mapcar)
+ "; use `mapc' or `dolist' instead")
+ (t ""))))
(byte-optimize-form (cons 'progn (cdr form)) t))
(_
#+end_src
The two warnings this reveals in the Org repo might not be false
though... I haven't taken a super close look at these but they do look
suspicious.
;; Warning: value from call to ‘current-buffer’ is unused
;; Warning: value from call to ‘not’ is unused
#+begin_src diff
diff --git a/lisp/ob-eval.el b/lisp/ob-eval.el
index b7b79a501..9249d8086 100644
--- a/lisp/ob-eval.el
+++ b/lisp/ob-eval.el
@@ -135,8 +135,7 @@ org-babel--shell-command-on-region
;; don't want that to cause an infinite recursion.
(format-insert-file error-file nil)
;; Put point after the inserted errors.
- (goto-char (- (point-max) pos-from-end)))
- (current-buffer)))
+ (goto-char (- (point-max) pos-from-end)))))
(delete-file error-file))
exit-status))
diff --git a/lisp/org-table.el b/lisp/org-table.el
index c36fce71a..502a548ed 100644
--- a/lisp/org-table.el
+++ b/lisp/org-table.el
@@ -1925,7 +1925,8 @@ org-table-copy-down
(setq field-above
(let ((f (unless (= beg (line-beginning-position))
(forward-line -1)
- (not (org-at-table-hline-p))
+ ;; uhhh was this supposed to do something?
+ ;; (not (org-at-table-hline-p))
(org-table-get-field column))))
(and (org-string-nw-p f)
(org-trim f)))))
#+end_src
* relint
https://github.com/mattiase/relint
I think there are more things to find from relint by enabling more
warnings. However, it will be hard to get rid of all the warnings. For
example, it's mad about `org-tag--valid-char-set` because it looks like
a regex but it's actually a regex snippet that it meant to go inside of
a "[]" construct.
* other linting
I would love to hear if anyone has anything else we could play with!
Maybe playing with `flyspell-prog-mode` would be fun but we might need
to figure out how to add a custom ispell dictionary to the repo. For
checkdoc I just set 'checkdoc-ispell-lisp-words'. Ideally we would add
the words using ".dir-locals.el" and I seem to recall I couldn't figure
out a good way to do that last time I tried.
Quickly searching the guix package repository shows these packages which
might be promising to try:
https://github.com/purcell/package-lint
https://github.com/alphapapa/makem.sh