Skip to content

Commit 5515116

Browse files
committed
Lint using `package-lint'
* Makefile (INSTALL_DEPENDENCIES): Install `package-lint' from added melpa archive. (IGNORED_LINT_WARNINGS): New variable. (%.lint-checkdoc): (%.lint-long-lines): New targets split from old `lint'. (%.lint-package): New target. (lint): Depend on the created lint targets. * asm-data.el: * asm-jump.el: * asm-x86.el: * asm2src.el: * bdx.el: * binfile.el: * compdb.el: * emacs-binary-utils.el: * untemplatize-cxx.el: Address newly found linter warnings.
1 parent 775bdc4 commit 5515116

File tree

10 files changed

+68
-45
lines changed

10 files changed

+68
-45
lines changed

Makefile

Lines changed: 40 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,26 @@ ELC := $(FILES:.el=.elc)
1919

2020
PACKAGE_INIT := -f package-initialize
2121

22-
INSTALL_DEPENDENCIES := ${PACKAGE_INIT} --eval '(progn \
23-
(load "seq" nil t) \
24-
(load "project" nil t) \
25-
(unless (and (fboundp `seq-contains-p) (fboundp `project-name)) \
26-
(package-refresh-contents) \
27-
(package-install (cadr (assoc `project package-archive-contents))) \
28-
(package-install (cadr (assoc `map package-archive-contents))) \
29-
(package-install (cadr (assoc `seq package-archive-contents)))) \
30-
(unless (package-installed-p `ivy) \
31-
(package-refresh-contents) \
22+
INSTALL_DEPENDENCIES := ${PACKAGE_INIT} --eval '(progn \
23+
(load "seq" nil t) \
24+
(load "project" nil t) \
25+
(unless (and (fboundp `seq-contains-p) \
26+
(fboundp `project-name) \
27+
(package-installed-p (quote package-lint))) \
28+
(push (quote ("melpa" . "https://melpa.org/packages/")) package-archives)\
29+
(package-refresh-contents) \
30+
(package-install (quote package-lint)) \
31+
(package-install (cadr (assoc `project package-archive-contents))) \
32+
(package-install (cadr (assoc `map package-archive-contents))) \
33+
(package-install (cadr (assoc `seq package-archive-contents)))) \
34+
(unless (package-installed-p `ivy) \
35+
(package-refresh-contents) \
3236
(package-install `ivy)))'
3337
38+
IGNORED_LINT_WARNINGS := \
39+
-e "You should depend on (emacs \"29\\.1\") or the compat package if you need \`take'\\." \
40+
-e "warning: \`with-eval-after-load' is for use in configurations," \
41+
3442
LIBS := $(patsubst %.el,-l %,${FILES})
3543
3644
SELECTOR ?= .*
@@ -50,28 +58,29 @@ check: compile
5058
--eval '(setq byte-compile-error-on-warn t)' \
5159
-f batch-byte-compile $<
5260
53-
lint:
54-
set -e; \
55-
files=( \
56-
asm-data.el \
57-
asm-jump.el \
58-
asm-x86.el \
59-
asm2src.el \
60-
bdx.el \
61-
binfile.el \
62-
compdb.el \
63-
untemplatize-cxx.el \
64-
); \
65-
for f in $${files[@]}; do \
66-
lint=$$(mktemp) \
67-
&& ${emacs} -Q --batch $$f \
61+
%.lint-checkdoc: %.el
62+
@lint=$$(mktemp); \
63+
${emacs} -Q --batch $< \
6864
--eval '(checkdoc-file (buffer-file-name))' 2>&1 | tee $$lint \
69-
&& test -z "$$(cat $$lint)"; \
70-
done; \
71-
for f in $${files[@]}; do \
72-
sed '1{s/.*//}' $$f | grep -n -E "^.{80,}" `# Catch long lines` \
73-
| sed -r 's/^([0-9]+).*/'$$f':\1: Too long/;q1'; \
74-
done
65+
&& test -z "$$(cat $$lint)"
66+
67+
%.lint-long-lines: %.el
68+
@sed '1{s/.*//}' $< | grep -n -E "^.{80,}" `# Catch long lines` \
69+
| sed -r 's/^([0-9]+).*/'$<':\1: Too long/;q1';
70+
71+
72+
%.lint-package: %.el
73+
@file=$$(mktemp);result=$$(mktemp); \
74+
${emacs} -Q --batch ${PACKAGE_INIT} \
75+
-f 'package-lint-batch-and-exit' $< 2>$$file || true \
76+
&& sed -i "/^Entering directory/d" $$file \
77+
&& grep -v ${IGNORED_LINT_WARNINGS} $$file | tee $$result \
78+
&& test -z "$$(cat $$result)"
79+
80+
%.lint: %.el %.lint-checkdoc %.lint-long-lines %.lint-package
81+
@true
82+
83+
lint: $(patsubst %.el,%.lint,$(filter-out %-test.el,$(FILES)))
7584
7685
clean:
7786
rm -f *.elc

asm-data.el

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
;; Author: Michał Krzywkowski <[email protected]>
66
;; Keywords: languages, tools
7+
;; Version: 0.1.0
8+
;; Homepage: https://github.com/mkcms/emacs-binary-utils
9+
;; Package-Requires: ((emacs "27") (seq "2.24"))
710

811
;; This program is free software; you can redistribute it and/or modify
912
;; it under the terms of the GNU General Public License as published by
@@ -82,9 +85,7 @@
8285
".single" ".float" ; 32 bit float
8386
".double" ; 64 bit float
8487

85-
".zero"
86-
87-
)))
88+
".zero")))
8889
(unless asm-data--big-values-support
8990
(setq val (delete ".8byte" val))
9091
(setq val (delete ".octa" val)))
@@ -97,8 +98,7 @@
9798
(".long" . ".int")
9899
(".short" . ".2byte")
99100
(".hword" . ".short")
100-
(".float" . ".single")
101-
)
101+
(".float" . ".single"))
102102
"Alist of directive aliases. Keys are aliases, values are directives.")
103103

104104
(defcustom asm-data-endianness 'little

asm-jump.el

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
;; Author: Michał Krzywkowski <[email protected]>
66
;; Keywords: languages, tools
7+
;; Version: 0.1.0
8+
;; Homepage: https://github.com/mkcms/emacs-binary-utils
79
;; Package-Requires: ((emacs "27"))
810

911
;; This program is free software; you can redistribute it and/or modify

asm-x86.el

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
;; Author: Michał Krzywkowski <[email protected]>
66
;; Keywords: languages, tools
7+
;; Version: 0.1.0
8+
;; Homepage: https://github.com/mkcms/emacs-binary-utils
79
;; Package-Requires: ((emacs "27"))
810

911
;; This program is free software; you can redistribute it and/or modify
@@ -21,6 +23,7 @@
2123

2224
;;; Commentary:
2325
;;
26+
;; This package provides x86 handlers for the binfile package.
2427

2528
;;; Code:
2629

asm2src.el

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
;; Author: Michał Krzywkowski <[email protected]>
66
;; Keywords: languages, tools
7+
;; Version: 0.1.0
8+
;; Homepage: https://github.com/mkcms/emacs-binary-utils
79
;; Package-Requires: ((emacs "27"))
810

911
;; This program is free software; you can redistribute it and/or modify
@@ -97,8 +99,7 @@
9799
`(
98100
asm2src-file ,file
99101
asm2src-line ,line
100-
asm2src-id ,(gensym)
101-
))))
102+
asm2src-id ,(gensym)))))
102103

103104
(defun asm2src-process-buffer ()
104105
"Process source mappings in current buffer.

bdx.el

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
;; Author: Michał Krzywkowski <[email protected]>
66
;; Keywords: tools, c
7+
;; Version: 0.1.0
8+
;; Homepage: https://github.com/mkcms/emacs-binary-utils
9+
;; Package-Requires: ((emacs "29.1"))
710

811
;; This program is free software; you can redistribute it and/or modify
912
;; it under the terms of the GNU General Public License as published by
@@ -496,8 +499,7 @@ This will error if `bdx-demangle-names' is nil."
496499
(pcase-let (((map (:outdated (map (:binary binary-outdated)
497500
(:symbol symbol-outdated)))
498501
:demangled :name :path
499-
:size :section :address :type
500-
)
502+
:size :section :address :type)
501503
(bdx-data cand)))
502504
(insert (propertize (or demangled name "(ERROR: No name)")
503505
'face 'font-lock-constant-face)

binfile.el

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
;; Author: Michał Krzywkowski <[email protected]>
66
;; Keywords: languages, tools
7+
;; Version: 0.1.0
8+
;; Homepage: https://github.com/mkcms/emacs-binary-utils
79
;; Package-Requires: ((emacs "27"))
810

911
;; This program is free software; you can redistribute it and/or modify
@@ -59,8 +61,7 @@
5961
binfile-postprocess-boring-comments
6062
binfile-postprocess-numeric-to-symbolic-references
6163
binfile-postprocess-unused-symbolic-local-references
62-
binfile-postprocess-add-relocation-buttons
63-
)
64+
binfile-postprocess-add-relocation-buttons)
6465
"List of functions that postprocess ASM regions.
6566
Each function is called with three arguments (BEG END NAME),
6667
where BEG and END are region bounds and NAME is the name of the
@@ -189,8 +190,7 @@ The groups are:
189190
?<
190191
,function-name
191192
(optional "+0x" (+ hex-digit))
192-
?>
193-
)))
193+
?>)))
194194

195195
(defun binfile-postprocess-local-jumps (_beg _end function-name)
196196
"Labelize FUNCTION-NAME and rewrite jumps to symbolic jumps to those labels."

compdb.el

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
;; Author: Michał Krzywkowski <[email protected]>
66
;; Keywords: c, tools
7+
;; Version: 0.1.0
8+
;; Homepage: https://github.com/mkcms/emacs-binary-utils
9+
;; Package-Requires: ((emacs "27.1"))
710

811
;; This program is free software; you can redistribute it and/or modify
912
;; it under the terms of the GNU General Public License as published by

emacs-binary-utils.el

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
;; Author: Michał Krzywkowski <[email protected]>
66
;; Keywords: languages, tools
7-
;; Package-Requires: ((emacs "27") (seq "2.24") (project "0.10.0") (map "3.3.1"))
7+
;; Package-Requires: ((emacs "29.1") (seq "2.24") (project "0.10.0") (map "3.3.1"))
88

99
;; This program is free software; you can redistribute it and/or modify
1010
;; it under the terms of the GNU General Public License as published by

untemplatize-cxx.el

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
;; Author: Michał Krzywkowski <[email protected]>
66
;; Keywords: c, tools
7+
;; Version: 0.1.0
8+
;; Homepage: https://github.com/mkcms/emacs-binary-utils
9+
;; Package-Requires: ((emacs "27"))
710

811
;; This program is free software; you can redistribute it and/or modify
912
;; it under the terms of the GNU General Public License as published by

0 commit comments

Comments
 (0)