diff --git a/doc/developer-notes.md b/doc/developer-notes.md index 8f6c662f1..4821a59f1 100644 --- a/doc/developer-notes.md +++ b/doc/developer-notes.md @@ -622,8 +622,8 @@ namespace { - *Rationale*: Avoids confusion about the namespace context -- Prefer `#include ` bracket syntax instead of - `#include "primitives/transactions.h"` quote syntax when possible. +- Use `#include ` bracket syntax instead of + `#include "primitives/transactions.h"` quote syntax. - *Rationale*: Bracket syntax is less ambiguous because the preprocessor searches a fixed list of include directories without taking location of the diff --git a/src/bench/merkle_root.cpp b/src/bench/merkle_root.cpp index ae2a0a28d..fab12da31 100644 --- a/src/bench/merkle_root.cpp +++ b/src/bench/merkle_root.cpp @@ -2,11 +2,11 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#include "bench.h" +#include -#include "uint256.h" -#include "random.h" -#include "consensus/merkle.h" +#include +#include +#include static void MerkleRoot(benchmark::State& state) { diff --git a/src/crypto/sha256_avx2.cpp b/src/crypto/sha256_avx2.cpp index f45c1d4ab..b338b0692 100644 --- a/src/crypto/sha256_avx2.cpp +++ b/src/crypto/sha256_avx2.cpp @@ -7,8 +7,8 @@ #include #endif -#include "crypto/sha256.h" -#include "crypto/common.h" +#include +#include namespace sha256d64_avx2 { namespace { diff --git a/src/crypto/sha256_sse41.cpp b/src/crypto/sha256_sse41.cpp index a11d658c7..be71dd8fb 100644 --- a/src/crypto/sha256_sse41.cpp +++ b/src/crypto/sha256_sse41.cpp @@ -7,8 +7,8 @@ #include #endif -#include "crypto/sha256.h" -#include "crypto/common.h" +#include +#include namespace sha256d64_sse41 { namespace { diff --git a/src/test/blockchain_tests.cpp b/src/test/blockchain_tests.cpp index d2d000812..7d8ae46fb 100644 --- a/src/test/blockchain_tests.cpp +++ b/src/test/blockchain_tests.cpp @@ -1,9 +1,9 @@ #include -#include "stdlib.h" +#include -#include "rpc/blockchain.h" -#include "test/test_bitcoin.h" +#include +#include /* Equality between doubles is imprecise. Comparison should be done * with a small threshold of tolerance, rather than exact equality. diff --git a/src/wallet/test/coinselector_tests.cpp b/src/wallet/test/coinselector_tests.cpp index e90370cf0..d90be3300 100644 --- a/src/wallet/test/coinselector_tests.cpp +++ b/src/wallet/test/coinselector_tests.cpp @@ -2,14 +2,14 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#include "wallet/wallet.h" -#include "wallet/coinselection.h" -#include "wallet/coincontrol.h" -#include "amount.h" -#include "primitives/transaction.h" -#include "random.h" -#include "test/test_bitcoin.h" -#include "wallet/test/wallet_test_fixture.h" +#include +#include +#include +#include +#include +#include +#include +#include #include #include diff --git a/test/lint/lint-includes.sh b/test/lint/lint-includes.sh index 2c3456b64..f5daf4f9a 100755 --- a/test/lint/lint-includes.sh +++ b/test/lint/lint-includes.sh @@ -6,9 +6,12 @@ # # Check for duplicate includes. # Guard against accidental introduction of new Boost dependencies. +# Check includes: Check for duplicate includes. Enforce bracket syntax includes. + +IGNORE_REGEXP="/(leveldb|secp256k1|univalue)/" filter_suffix() { - git ls-files | grep -E "^src/.*\.${1}"'$' | grep -Ev "/(leveldb|secp256k1|univalue)/" + git ls-files | grep -E "^src/.*\.${1}"'$' | grep -Ev "${IGNORE_REGEXP}" } EXIT_CODE=0 @@ -105,4 +108,12 @@ for EXPECTED_BOOST_INCLUDE in "${EXPECTED_BOOST_INCLUDES[@]}"; do fi done +QUOTE_SYNTAX_INCLUDES=$(git grep '^#include "' -- "*.cpp" "*.h" | grep -Ev "${IGNORE_REGEXP}") +if [[ ${QUOTE_SYNTAX_INCLUDES} != "" ]]; then + echo "Please use bracket syntax includes (\"#include \") instead of quote syntax includes:" + echo "${QUOTE_SYNTAX_INCLUDES}" + echo + EXIT_CODE=1 +fi + exit ${EXIT_CODE}