diff --git a/.arclint b/.arclint index b419c2d20e..5991b6707d 100644 --- a/.arclint +++ b/.arclint @@ -1,20 +1,29 @@ { "linters": { "generated": { "type": "generated" }, "clang-format": { "type": "clang-format", "version": "4.0", "bin": ["clang-format-4.0", "clang-format"], "include": "(^src/.*\\.(h|c|cpp)$)", "exclude": [ "(^src/(secp256k1|univalue|leveldb)/)" ] }, "autopep8": { "type": "autopep8", "include": "(\\.py$)" + }, + "lint-format-strings": { + "type": "script-and-regex", + "include": "(^src/.*\\.(h|c|cpp)$)", + "exclude": [ + "(^src/(secp256k1|univalue|leveldb)/)" + ], + "script-and-regex.script": "test/lint/lint-format-strings.sh", + "script-and-regex.regex": "/^(?P.+): (?P.+:.+)$/m" } } } diff --git a/test/lint/lint-format-strings.sh b/test/lint/lint-format-strings.sh index b2beb9f4fb..e8ccd2adf6 100755 --- a/test/lint/lint-format-strings.sh +++ b/test/lint/lint-format-strings.sh @@ -1,41 +1,39 @@ #!/usr/bin/env 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. # # Lint format strings: This program checks that the number of arguments passed # to a variadic format string function matches the number of format specifiers # in the format string. export LC_ALL=C FUNCTION_NAMES_AND_NUMBER_OF_LEADING_ARGUMENTS=( FatalError,0 fprintf,1 LogConnectFailure,1 LogPrint,1 LogPrintf,0 printf,0 snprintf,2 sprintf,1 strprintf,0 vfprintf,1 vprintf,1 vsnprintf,1 vsprintf,1 ) EXIT_CODE=0 if ! python3 -m doctest test/lint/lint-format-strings.py; then EXIT_CODE=1 fi for S in "${FUNCTION_NAMES_AND_NUMBER_OF_LEADING_ARGUMENTS[@]}"; do IFS="," read -r FUNCTION_NAME SKIP_ARGUMENTS <<< "${S}" - mapfile -t MATCHING_FILES < <(git grep --full-name -l "${FUNCTION_NAME}" -- "*.c" "*.cpp" "*.h" | sort | grep -vE "^src/(leveldb|secp256k1|tinyformat|univalue)") - if ! test/lint/lint-format-strings.py --skip-arguments "${SKIP_ARGUMENTS}" "${FUNCTION_NAME}" "${MATCHING_FILES[@]}"; then - EXIT_CODE=1 - fi + mapfile -t MATCHING_FILES < <(git grep --full-name -l "${FUNCTION_NAME}" -- ${1}) + test/lint/lint-format-strings.py --skip-arguments "${SKIP_ARGUMENTS}" "${FUNCTION_NAME}" "${MATCHING_FILES[@]}" done exit ${EXIT_CODE} \ No newline at end of file