diff options
author | MarcoFalke <falke.marco@gmail.com> | 2018-05-19 10:27:54 -0400 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2018-05-24 12:02:15 -0400 |
commit | fa3c910bfeab00703c947c5200a64c21225b50ef (patch) | |
tree | 6d8e8ad2d248c22fece1f5c1bebd6cf9ace38db0 /test/lint/lint-includes.sh | |
parent | d9ebb63919fb311ace0ae977e3183ccb80ed7d3c (diff) |
test: Move linters to test/lint, add readme
Diffstat (limited to 'test/lint/lint-includes.sh')
-rwxr-xr-x | test/lint/lint-includes.sh | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/lint/lint-includes.sh b/test/lint/lint-includes.sh new file mode 100755 index 0000000000..f54be46b52 --- /dev/null +++ b/test/lint/lint-includes.sh @@ -0,0 +1,32 @@ +#!/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 duplicate includes. + +filter_suffix() { + git ls-files | grep -E "^src/.*\.${1}"'$' | grep -Ev "/(leveldb|secp256k1|univalue)/" +} + +EXIT_CODE=0 +for HEADER_FILE in $(filter_suffix h); do + DUPLICATE_INCLUDES_IN_HEADER_FILE=$(grep -E "^#include " < "${HEADER_FILE}" | sort | uniq -d) + if [[ ${DUPLICATE_INCLUDES_IN_HEADER_FILE} != "" ]]; then + echo "Duplicate include(s) in ${HEADER_FILE}:" + echo "${DUPLICATE_INCLUDES_IN_HEADER_FILE}" + echo + EXIT_CODE=1 + fi +done +for CPP_FILE in $(filter_suffix cpp); do + DUPLICATE_INCLUDES_IN_CPP_FILE=$(grep -E "^#include " < "${CPP_FILE}" | sort | uniq -d) + if [[ ${DUPLICATE_INCLUDES_IN_CPP_FILE} != "" ]]; then + echo "Duplicate include(s) in ${CPP_FILE}:" + echo "${DUPLICATE_INCLUDES_IN_CPP_FILE}" + echo + EXIT_CODE=1 + fi +done +exit ${EXIT_CODE} |