Delete .shellcheckrc (#1947)

* CI: disable Ubuntu 16.04 as it's EOL

https://github.blog/changelog/2021-04-29-github-actions-ubuntu-16-04-lts-virtual-environment-will-be-removed-on-september-20-2021/

* main: lint false positive

* install: lint

* plugins/cmd-returned-notify: don't `export`

* plugins/xterm: lint

* plugins/git: lint

* plugins/goenv: lint

* plugins/alias-completion: lint false positives

* plugins/alias-completion: fix SC2155, SC2154

Declare `locals` at the top of the function

* completion: lint completions using `bash_completion` functions

Match the style of the existing code

* completion/knife: lint false positives

* completion/knife: lint

* completion/sdkman: lint

* completion/composer: lint

* Move `.shellcheckrc` under `themes/`

* lib/theme: fix SC2155, SC2154, SC2034

* lib/colors: don't warn on unused variables

We assign a large number of variables here and they may or may not be used anywhere else, so disable SC2034 for this file (only).

Alsö disable SC2005 as the functions in this file were written before `printf` was invented and have to do some fancy metascripting to get escape sequences interpreted reliably. I’m not smart enough to fix this to use `printf`, so leave it for now.

* themes/agnoster: lint

* themes: disable SC2154 for colors

Each one of these themes will need it’s own fix for SC2154, possibly upstream.

Due to the way themes are, it's entirely normal to have a *lot* of false positives for SC2034. So much so, that I have to admit that it is probably just not worth linting for SC2034 despite my dislike of blanket ignore rules.

* themes: disable SC2154, fix SC2155

Each one of these themes will need it’s own fix for SC2154, possibly upstream.

Due to the way themes are, it's entirely normal to have a *lot* of false positives for SC2034. So much so, that I have to admit that it is probably just not worth linting for SC2034 despite my dislike of blanket ignore rules.

* Delete `.shellcheckrc`

* remove executable bit
This commit is contained in:
John D Pell
2021-09-18 02:50:59 -07:00
committed by GitHub
parent b48f3fd7d3
commit 1c3cbf7ca6
44 changed files with 183 additions and 126 deletions

View File

@@ -19,6 +19,8 @@ about-plugin 'Automatic completion of aliases'
# Automatically add completion for all aliases to commands having completion functions
function alias_completion {
local namespace="alias_completion"
local tmp_file completion_loader alias_name alias_tokens line completions
local alias_arg_words new_completion compl_func compl_wrapper
# parse function based completion definitions, where capture group 2 => function and 3 => trigger
local compl_regex='complete( +[^ ]+)* -F ([^ ]+) ("[^"]+"|[^ ]+)'
@@ -26,28 +28,25 @@ function alias_completion {
local alias_regex="alias( -- | )([^=]+)='(\"[^\"]+\"|[^ ]+)(( +[^ ]+)*)'"
# create array of function completion triggers, keeping multi-word triggers together
eval "local completions=($(complete -p | sed -Ene "/$compl_regex/s//'\3'/p"))"
eval "completions=($(complete -p | sed -Ene "/$compl_regex/s//'\3'/p"))"
((${#completions[@]} == 0)) && return 0
# create temporary file for wrapper functions and completions
local tmp_file
tmp_file="$(mktemp -t "${namespace}-${RANDOM}XXXXXX")" || return 1
local completion_loader
completion_loader="$(complete -p -D 2> /dev/null | sed -Ene 's/.* -F ([^ ]*).*/\1/p')"
# read in "<alias> '<aliased command>' '<command args>'" lines from defined aliases
local line
# shellcheck disable=SC2162
# some aliases do have backslashes that needs to be interpreted
# shellcheck disable=SC2162
while read line; do
eval "local alias_tokens; alias_tokens=($line)" 2> /dev/null || continue # some alias arg patterns cause an eval parse error
local alias_name="${alias_tokens[0]}" alias_cmd="${alias_tokens[1]}" alias_args="${alias_tokens[2]# }"
eval "alias_tokens=($line)" 2> /dev/null || continue # some alias arg patterns cause an eval parse error
# shellcheck disable=SC2154 # see `eval` above
alias_name="${alias_tokens[0]}" alias_cmd="${alias_tokens[1]}" alias_args="${alias_tokens[2]# }"
# skip aliases to pipes, boolean control structures and other command lists
# (leveraging that eval errs out if $alias_args contains unquoted shell metacharacters)
eval "local alias_arg_words; alias_arg_words=($alias_args)" 2> /dev/null || continue
eval "alias_arg_words=($alias_args)" 2> /dev/null || continue
# avoid expanding wildcards
read -a alias_arg_words <<< "$alias_args"
@@ -63,15 +62,15 @@ function alias_completion {
continue
fi
fi
local new_completion="$(complete -p "$alias_cmd" 2> /dev/null)"
new_completion="$(complete -p "$alias_cmd" 2> /dev/null)"
# create a wrapper inserting the alias arguments if any
if [[ -n $alias_args ]]; then
local compl_func="${new_completion/#* -F /}"
compl_func="${new_completion/#* -F /}"
compl_func="${compl_func%% *}"
# avoid recursive call loops by ignoring our own functions
if [[ "${compl_func#_"$namespace"::}" == "$compl_func" ]]; then
local compl_wrapper="_${namespace}::${alias_name}"
compl_wrapper="_${namespace}::${alias_name}"
echo "function $compl_wrapper {
local compl_word=\$2
local prec_word=\$3