mirror of
https://github.com/dashpay/dash.git
synced 2024-12-27 13:03:17 +01:00
481254c86d
341f7c7b0e macOS fix: Check for correct version of flake8 to avoid spurious warnings. The brew installed flake8 version is Python 2 based and does not work. (practicalswift) 908a559f33 macOS fix: Add excludes for checks added in the newer shellcheck version installed by brew (practicalswift) ec4d57bbb3 macOS fix: Work around empty (sub)expression error when using BSD grep (practicalswift) b57d7d92fe macOS fix: Avoid mapfile due to ancient version of bash shipped with macOS (practicalswift) Pull request description: The linters are thoroughly tested under Ubuntu which is what we use in Travis. When reading #14041 I understood that some developers were experiencing problems when running the linters on their local machines. Assuming these local machines were running macOS I installed a fresh macOS VM, followed the instructions in `build-osx.md` and ran the linters. This PR contains the changes needed to make `lint-all.sh` run as expected. Ideally the linters would continuously run also under a Travis macOS environment to make sure we catch these kind of issues before merge. Tree-SHA512: b39c9a970d14d27db1fb592539923c0bc676b5217f415d02fda3f17bf54d46faa172376e8a3ecab07ca68a3acba9aebe00b2b1b2161b2a36b85fbb672e7efb5c
48 lines
2.4 KiB
Bash
Executable File
48 lines
2.4 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# Copyright (c) 2018 The Bitcoin Core developers
|
|
# Distributed under the MIT software license, see the accompanying
|
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
#
|
|
# Check for shellcheck warnings in shell scripts.
|
|
|
|
export LC_ALL=C
|
|
|
|
# The shellcheck binary segfault/coredumps in Travis with LC_ALL=C
|
|
# It does not do so in Ubuntu 14.04, 16.04, 18.04 in versions 0.3.3, 0.3.7, 0.4.6
|
|
# respectively. So export LC_ALL=C is set as required by lint-shell-locale.sh
|
|
# but unset here in case of running in Travis.
|
|
if [ "$TRAVIS" = "true" ]; then
|
|
unset LC_ALL
|
|
fi
|
|
|
|
if ! command -v shellcheck > /dev/null; then
|
|
echo "Skipping shell linting since shellcheck is not installed."
|
|
exit 0
|
|
fi
|
|
|
|
# Disabled warnings:
|
|
# SC1087: Use braces when expanding arrays, e.g. ${array[idx]} (or ${var}[.. to quiet).
|
|
# SC1117: Backslash is literal in "\.". Prefer explicit escaping: "\\.".
|
|
# SC2001: See if you can use ${variable//search/replace} instead.
|
|
# SC2004: $/${} is unnecessary on arithmetic variables.
|
|
# SC2005: Useless echo? Instead of 'echo $(cmd)', just use 'cmd'.
|
|
# SC2006: Use $(..) instead of legacy `..`.
|
|
# SC2016: Expressions don't expand in single quotes, use double quotes for that.
|
|
# SC2028: echo won't expand escape sequences. Consider printf.
|
|
# SC2046: Quote this to prevent word splitting.
|
|
# SC2048: Use "$@" (with quotes) to prevent whitespace problems.
|
|
# SC2066: Since you double quoted this, it will not word split, and the loop will only run once.
|
|
# SC2086: Double quote to prevent globbing and word splitting.
|
|
# SC2116: Useless echo? Instead of 'cmd $(echo foo)', just use 'cmd foo'.
|
|
# SC2148: Tips depend on target shell and yours is unknown. Add a shebang.
|
|
# SC2162: read without -r will mangle backslashes.
|
|
# SC2166: Prefer [ p ] && [ q ] as [ p -a q ] is not well defined.
|
|
# SC2166: Prefer [ p ] || [ q ] as [ p -o q ] is not well defined.
|
|
# SC2181: Check exit code directly with e.g. 'if mycmd;', not indirectly with $?.
|
|
# SC2206: Quote to prevent word splitting, or split robustly with mapfile or read -a.
|
|
# SC2207: Prefer mapfile or read -a to split command output (or quote to avoid splitting).
|
|
# SC2230: which is non-standard. Use builtin 'command -v' instead.
|
|
shellcheck -e SC1087,SC1117,SC2001,SC2004,SC2005,SC2006,SC2016,SC2028,SC2046,SC2048,SC2066,SC2086,SC2116,SC2148,SC2162,SC2166,SC2181,SC2206,SC2207,SC2230 \
|
|
$(git ls-files -- "*.sh" | grep -vE 'src/(secp256k1|univalue)/')
|