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

@@ -3,14 +3,14 @@ cite "about-completion"
about-completion "composer completion"
function __composer_completion() {
local cur coms opts com
local cur coms opts com words
COMPREPLY=()
_get_comp_words_by_ref -n : cur words
# lookup for command
for word in "${words[@]:1}"; do
if [[ $word != -* ]]; then
com=$word
if [[ "${word}" != -* ]]; then
com="${word}"
break
fi
done
@@ -19,7 +19,7 @@ function __composer_completion() {
if [[ ${cur} == --* ]]; then
opts="--help --quiet --verbose --version --ansi --no-ansi --no-interaction --profile --no-plugins --working-dir"
case "$com" in
case "${com}" in
about)
opts="${opts} "
;;
@@ -109,18 +109,18 @@ function __composer_completion() {
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "${opts}" -- "${cur}"))
__ltrim_colon_completions "$cur"
__ltrim_colon_completions "${cur}"
return 0
fi
# completing for a command
if [[ "$cur" == "$com" ]]; then
if [[ "${cur}" == "${com}" ]]; then
coms="about archive browse clear-cache config create-project depends diagnose dump-autoload exec global help init install licenses list outdated prohibits remove require run-script search self-update show status suggests update validate"
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "${coms}" -- "${cur}"))
__ltrim_colon_completions "$cur"
__ltrim_colon_completions "${cur}"
return 0
fi

View File

@@ -1,7 +1,9 @@
# shellcheck shell=bash
__dart_completion() {
# shellcheck disable=SC2155
local prev=$(_get_pword)
# shellcheck disable=SC2155
local curr=$(_get_cword)
local HELP="--help -h"

View File

@@ -1,7 +1,9 @@
# shellcheck shell=bash
function __dmidecode_completion() {
# shellcheck disable=SC2155
local prev=$(_get_pword)
# shellcheck disable=SC2155
local curr=$(_get_cword)
case $prev in

View File

@@ -42,6 +42,7 @@ _KAC_is_file_newer_than() {
_KAC_regen_cache() {
local CACHE_NAME=$1
local CACHE_PATH="$_KNIFE_AUTOCOMPLETE_CACHE_DIR/$CACHE_NAME"
# shellcheck disable=SC2155
local TMP_FILE=$(mktemp "$_KAC_CACHE_TMP_DIR/$CACHE_NAME.XXXX")
shift 1
# discard the temp file if it's empty AND the previous command didn't exit successfully, but still mark the cache as updated
@@ -66,6 +67,7 @@ _KAC_get_command_from_cache_name() {
# otherwise it waits for the cache to be generated
# in either case, it regenerates the cache, and sets the _KAC_CACHE_PATH env variable
# for obvious reason, do NOT call that in a sub-shell (in particular, no piping)
# shellcheck disable=SC2155
_KAC_get_and_regen_cache() {
# the cache name can't have space in it
local CACHE_NAME=$(_KAC_get_cache_name_from_command "$@")
@@ -100,7 +102,7 @@ _KAC_clean_cache() {
# perform a cache cleaning when loading this file
# On big systems this could baloon up to a 30 second run or more, so not enabling by default.
[[ "${KNIFE_CACHE_CLEAN}" ]] && _KAC_clean_cache
[[ -n "${KNIFE_CACHE_CLEAN}" ]] && _KAC_clean_cache
#####################################
### End of cache helper functions ###
@@ -118,7 +120,7 @@ _KAC_get_current_base_command() {
local PREVIOUS="knife"
local I=1
local CURRENT
while [ $I -le "$COMP_CWORD" ]; do
while [[ "${I}" -le "${COMP_CWORD}" ]]; do
# command words are all lower-case
echo "${COMP_WORDS[$I]}" | grep -E "^[a-z]+$" > /dev/null || break
CURRENT="$PREVIOUS ${COMP_WORDS[$I]}"
@@ -127,12 +129,13 @@ _KAC_get_current_base_command() {
I=$((I + 1))
done
_KAC_CURRENT_COMMAND=$PREVIOUS
[ $I -le "$COMP_CWORD" ] && _KAC_CURRENT_COMMAND_NB_WORDS=$I
[[ "${I}" -le "${COMP_CWORD}" ]] && _KAC_CURRENT_COMMAND_NB_WORDS="${I}"
}
# searches the position of the currently completed argument in the current base command
# (i.e. handles "plural" arguments such as knife cookbook upload cookbook1 cookbook2 and so on...)
# assumes the current base command is complete
# shellcheck disable=SC2155
_KAC_get_current_arg_position() {
local CURRENT_ARG_POS=$((_KAC_CURRENT_COMMAND_NB_WORDS + 1))
local COMPLETE_COMMAND=$(grep -E "^$_KAC_CURRENT_COMMAND" "$_KAC_CACHE_PATH")
@@ -150,10 +153,11 @@ _KAC_get_current_arg_position() {
_knife() {
_KAC_get_and_regen_cache _KAC_knife_commands
local RAW_LIST ITEM REGEN_CMD ARG_POSITION
# shellcheck disable=SC2034
COMREPLY=()
# get correct command & arg pos
_KAC_get_current_base_command && ARG_POSITION=$(_KAC_get_current_arg_position) || ARG_POSITION=$((COMP_CWORD + 1))
RAW_LIST=$(grep -E "^$_KAC_CURRENT_COMMAND" "$_KAC_CACHE_PATH" | cut -d ' ' -f $ARG_POSITION | uniq)
RAW_LIST=$(grep -E "^${_KAC_CURRENT_COMMAND}" "${_KAC_CACHE_PATH}" | cut -d ' ' -f "${ARG_POSITION}" | uniq)
# we need to process that raw list a bit, most notably for placeholders
# NOTE: I chose to explicitely fetch & cache _certain_ informations for the server (cookbooks & node names, etc)

View File

@@ -1,7 +1,9 @@
# shellcheck shell=bash
__ngrok_completion() {
# shellcheck disable=SC2155
local prev=$(_get_pword)
# shellcheck disable=SC2155
local curr=$(_get_cword)
local BASE_NO_CONF="--log --log-format --log-level --help"

View File

@@ -1,7 +1,9 @@
# shellcheck shell=bash
function __notify-send_completions() {
# shellcheck disable=SC2155
local curr=$(_get_cword)
# shellcheck disable=SC2155
local prev=$(_get_pword)
case $prev in

View File

@@ -1,7 +1,9 @@
# shellcheck shell=bash
_sdkman_complete() {
function _sdkman_complete() {
local CANDIDATES
local CANDIDATE_VERSIONS
local SDKMAN_CANDIDATES_CSV="${SDKMAN_CANDIDATES_CSV:-}"
COMPREPLY=()
@@ -10,7 +12,7 @@ _sdkman_complete() {
elif [ "$COMP_CWORD" -eq 2 ]; then
case "${COMP_WORDS[COMP_CWORD - 1]}" in
"install" | "i" | "uninstall" | "rm" | "list" | "ls" | "use" | "u" | "default" | "d" | "home" | "h" | "current" | "c" | "upgrade" | "ug")
CANDIDATES=$(echo "${SDKMAN_CANDIDATES_CSV}" | tr ',' ' ')
CANDIDATES="${SDKMAN_CANDIDATES_CSV//,/${IFS:0:1}}"
mapfile -t COMPREPLY < <(compgen -W "$CANDIDATES" -- "${COMP_WORDS[COMP_CWORD]}")
;;
"env")
@@ -46,17 +48,17 @@ _sdkman_complete() {
return 0
}
_sdkman_candidate_local_versions() {
function _sdkman_candidate_local_versions() {
CANDIDATE_VERSIONS=$(__sdkman_cleanup_local_versions "$1")
}
_sdkman_candidate_all_versions() {
function _sdkman_candidate_all_versions() {
candidate="$1"
CANDIDATE_LOCAL_VERSIONS=$(__sdkman_cleanup_local_versions "$candidate")
if [ "$SDKMAN_OFFLINE_MODE" = "true" ]; then
if [[ "${SDKMAN_OFFLINE_MODE:-false}" == "true" ]]; then
CANDIDATE_VERSIONS=$CANDIDATE_LOCAL_VERSIONS
else
# sdkman has a specific output format for Java candidate since
@@ -70,12 +72,12 @@ _sdkman_candidate_all_versions() {
# "+" - local version
# "*" - installed
# ">" - currently in use
CANDIDATE_VERSIONS="$(echo "$CANDIDATE_ONLINE_VERSIONS $CANDIDATE_LOCAL_VERSIONS" | tr ' ' '\n' | grep -v -e '^[[:space:]|\*|\>|\+]*$' | sort | uniq -u) "
CANDIDATE_VERSIONS="$(echo "$CANDIDATE_ONLINE_VERSIONS $CANDIDATE_LOCAL_VERSIONS" | tr ' ' '\n' | grep -v -e '^[[:space:]|\*|\>|\+]*$' | sort -u) "
fi
}
__sdkman_cleanup_local_versions() {
function __sdkman_cleanup_local_versions() {
__sdkman_build_version_csv "$1" | tr ',' ' '

View File

@@ -1,7 +1,9 @@
# shellcheck shell=bash
__vuejs_completion() {
# shellcheck disable=SC2155
local prev=$(_get_pword)
# shellcheck disable=SC2155
local curr=$(_get_cword)
case $prev in