From 906bee8e5f474f8718d02e6f1938f20dcfe3d2cc Mon Sep 17 00:00:00 2001 From: practicalswift Date: Mon, 14 May 2018 09:51:03 +0200 Subject: Use bracket syntax includes ("#include ") --- src/bench/merkle_root.cpp | 8 ++++---- src/crypto/sha256_avx2.cpp | 4 ++-- src/crypto/sha256_sse41.cpp | 4 ++-- src/test/blockchain_tests.cpp | 6 +++--- src/wallet/test/coinselector_tests.cpp | 16 ++++++++-------- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/bench/merkle_root.cpp b/src/bench/merkle_root.cpp index ae2a0a28dc..fab12da311 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 f45c1d4ab6..b338b06927 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 a11d658c70..be71dd8fb8 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 d2d0008122..7d8ae46fb8 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 e90370cf06..d90be33000 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 -- cgit v1.2.3 From 6d10f43738d58bf623975e3124fd5735aac7d3e1 Mon Sep 17 00:00:00 2001 From: practicalswift Date: Mon, 14 May 2018 09:51:29 +0200 Subject: Enforce the use of bracket syntax includes ("#include ") --- test/lint/lint-includes.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/test/lint/lint-includes.sh b/test/lint/lint-includes.sh index 7cab0ca4d1..b0ba5f63af 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 @@ -97,4 +100,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} -- cgit v1.2.3 From 16e3cd380af570fb2f656e0344bab88829a4bcda Mon Sep 17 00:00:00 2001 From: practicalswift Date: Sun, 20 May 2018 22:12:25 +0200 Subject: Clarify include recommendation --- doc/developer-notes.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/developer-notes.md b/doc/developer-notes.md index 9081cab911..b722448a07 100644 --- a/doc/developer-notes.md +++ b/doc/developer-notes.md @@ -594,8 +594,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 -- cgit v1.2.3