From 196155499c04b2c2050302e6575f1bcbbed052f1 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 31 Oct 2017 20:28:49 +1300 Subject: Drastically simplify `lint` scripts Using find(1) to run the appropriate lint program over a set of files allows us to be terse and deal a little more dynamically with new files placed in the directories, but the downsides are that it's error-prone and that the order of testing is not predictable, and we'd ideally like the testing to be a little more deterministic than that. Case in point: writing the code for this commit unintentionally uncovered a longstanding issue where the URxvt Perl script `select.pl` was actually not being checked at all, due to an unneeded exclamation mark inverting the `-name` test for `*.pl` files. `select.pl` is presently not passing `perlcritic --brutal` on my machine, and likely has not been compliant since as early as commit 5000365 in March this year: >commit 500036564541ff2d65a7b2f6f6f556202d72d6ce >Author: Tom Ryder >Date: Fri Mar 24 11:01:05 2017 > > Lots of Makefile tidying > > ... > * Favour find(1) calls over shell loops > ... This commit also more clearly delineates between the language being "linted" and the target for which it's being linted. The latter is likely more desirable. This needs clarification. --- lint/bash.sh | 8 +++++++- lint/bin.sh | 3 ++- lint/games.sh | 3 ++- lint/ksh.sh | 8 +++++--- lint/sh.sh | 12 ++++++------ lint/urxvt.sh | 3 ++- lint/vim.sh | 13 ++++++++----- lint/xinit.sh | 4 +++- 8 files changed, 35 insertions(+), 19 deletions(-) (limited to 'lint') diff --git a/lint/bash.sh b/lint/bash.sh index 2fe1ba13..4830b90a 100644 --- a/lint/bash.sh +++ b/lint/bash.sh @@ -1 +1,7 @@ -find bash -type f -print -exec shellcheck -e SC1090 -s bash -- {} + +shellcheck -e SC1090 -s bash -- \ + bash/bash_completion \ + bash/bash_completion.d/*.bash \ + bash/bash_logout \ + bash/bash_profile \ + bash/bashrc \ + bash/bashrc.d/*.bash diff --git a/lint/bin.sh b/lint/bin.sh index 0fe82d7a..2c990d2a 100644 --- a/lint/bin.sh +++ b/lint/bin.sh @@ -1 +1,2 @@ -find bin -type f -name '*.sh' -print -exec shellcheck -e SC1090 -s sh -- {} + +shellcheck -e SC1090 -s sh -- \ + bin/*.sh diff --git a/lint/games.sh b/lint/games.sh index 6e3e3024..772c8678 100644 --- a/lint/games.sh +++ b/lint/games.sh @@ -1 +1,2 @@ -find games -type f -name '*.sh' -print -exec shellcheck -e SC1090 -s sh -- {} + +shellcheck -e SC1090 -s sh -- \ + games/*.sh diff --git a/lint/ksh.sh b/lint/ksh.sh index 4cedc6f7..fd558727 100644 --- a/lint/ksh.sh +++ b/lint/ksh.sh @@ -1,3 +1,5 @@ -find ksh \ - -type f -name '*.sh' -exec shellcheck -e SC1090 -s sh -- {} + -o \ - -type f -exec shellcheck -e SC1090 -s ksh -- {} + +shellcheck -e SC1090 -s sh -- \ + ksh/shrc.d/*.sh +shellcheck -e SC1090 -s ksh -- \ + ksh/kshrc \ + ksh/kshrc.d/*.ksh diff --git a/lint/sh.sh b/lint/sh.sh index 89704c0b..4f796b09 100644 --- a/lint/sh.sh +++ b/lint/sh.sh @@ -1,6 +1,6 @@ -find sh \ - keychain/profile.d keychain/shrc.d \ - ksh/shrc.d \ - mpd/profile.d \ - plenv/profile.d plenv/shrc.d \ - -type f -print -exec shellcheck -e SC1090 -s sh -- {} + +shellcheck -e SC1090 -s sh -- \ + sh/profile \ + sh/profile.d/* \ + sh/shinit \ + sh/shrc \ + sh/shrc.d/* diff --git a/lint/urxvt.sh b/lint/urxvt.sh index 507034be..7c7b1876 100644 --- a/lint/urxvt.sh +++ b/lint/urxvt.sh @@ -1 +1,2 @@ -find urxvt/ext -type f ! -name '*.pl' -print -exec perlcritic --brutal -- {} \; +perlcritic --brutal -- \ + urxvt/ext/*.pl diff --git a/lint/vim.sh b/lint/vim.sh index 6714ac9a..8197217e 100644 --- a/lint/vim.sh +++ b/lint/vim.sh @@ -1,5 +1,8 @@ -for v in vim/* ; do - [ "$v" != vim/bundle ] || continue - printf '%s\n' "$v" - vint -s -- "$v" -done +vint -s -- \ + vim/after/ \ + vim/config/ \ + vim/ftdetect/ \ + vim/ftplugin/ \ + vim/indent/ \ + vim/gvimrc \ + vim/vimrc diff --git a/lint/xinit.sh b/lint/xinit.sh index b5ff6937..cebb59a7 100644 --- a/lint/xinit.sh +++ b/lint/xinit.sh @@ -1 +1,3 @@ -find X -type f \( -name xinitrc -o -name '*.sh' \) -print -exec shellcheck -e SC1090 -s sh -- {} + +shellcheck -e SC1090 -s sh -- \ + X/xinitrc \ + X/xinitrc.d/*.sh -- cgit v1.2.3