aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2018-04-09 07:55:34 -0400
committerMarcoFalke <falke.marco@gmail.com>2018-04-09 07:57:47 -0400
commita04440feb9c93507f6248a37dfa82c548cede82e (patch)
treecd0e2ac953e382149f87a350d50b91285eb6bf6f
parent6fc5a050f216109bcd9b6ac099a3dd9518701f65 (diff)
parentc36b720d009f1ab1c3900750e05c1f17412e564d (diff)
Merge #11878: Add Travis check for duplicate includes
c36b720d00 Add Travis check for duplicate includes (practicalswift) 280023f31d Remove duplicate includes (practicalswift) Pull request description: This enforces parts of the project header include guidelines (added by @sipa in #10575). Example run: ``` $ git diff diff --git a/src/warnings.cpp b/src/warnings.cpp index c52a1fd..d8994dd 100644 --- a/src/warnings.cpp +++ b/src/warnings.cpp @@ -5,6 +5,8 @@ #include <sync.h> #include <clientversion.h> +#include <string> #include <util.h> #include <warnings.h> +#include <util.h> diff --git a/src/warnings.h b/src/warnings.h index e8e982c..8d2252e 100644 --- a/src/warnings.h +++ b/src/warnings.h @@ -7,6 +7,7 @@ #define BITCOIN_WARNINGS_H #include <stdlib.h> #include <string> +#include <stdlib.h> void SetMiscWarning(const std::string& strWarning); $ contrib/devtools/lint-includes.sh Duplicate include(s) in src/warnings.h: #include <stdlib.h> Include(s) from src/warnings.h duplicated in src/warnings.cpp: #include <string> Duplicate include(s) in src/warnings.cpp: #include <util.h> $ echo $? 1 $ git checkout . $ contrib/devtools/lint-includes.sh $ echo $? 0 ``` Tree-SHA512: f653d23c58ebc024dfc5b1fb8570698fd3c515c75b60b5cabbc43595548c488fca92349fa4c8b64460edbe61c879ff1d24f37f959e18552e202a7342460ddbf1
-rwxr-xr-xcontrib/devtools/lint-includes.sh43
-rw-r--r--src/chainparams.cpp1
-rw-r--r--src/chainparamsbase.cpp1
-rw-r--r--src/init.cpp1
-rw-r--r--src/interfaces/handler.cpp1
-rw-r--r--src/interfaces/wallet.cpp2
-rw-r--r--src/miner.cpp1
-rw-r--r--src/net.cpp1
-rw-r--r--src/qt/paymentrequestplus.cpp1
-rw-r--r--src/random.cpp1
-rw-r--r--src/support/lockedpool.cpp1
-rw-r--r--src/test/test_bitcoin.cpp2
-rw-r--r--src/wallet/db.cpp1
-rw-r--r--src/wallet/test/wallet_test_fixture.cpp1
-rw-r--r--src/wallet/wallet.cpp2
15 files changed, 43 insertions, 17 deletions
diff --git a/contrib/devtools/lint-includes.sh b/contrib/devtools/lint-includes.sh
new file mode 100755
index 0000000000..baca2f8a1f
--- /dev/null
+++ b/contrib/devtools/lint-includes.sh
@@ -0,0 +1,43 @@
+#!/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
+ CPP_FILE=${HEADER_FILE/%\.h/.cpp}
+ if [[ ! -e $CPP_FILE ]]; then
+ continue
+ fi
+ DUPLICATE_INCLUDES_IN_HEADER_AND_CPP_FILES=$(grep -hE "^#include " <(sort -u < "${HEADER_FILE}") <(sort -u < "${CPP_FILE}") | grep -E "^#include " | sort | uniq -d)
+ if [[ ${DUPLICATE_INCLUDES_IN_HEADER_AND_CPP_FILES} != "" ]]; then
+ echo "Include(s) from ${HEADER_FILE} duplicated in ${CPP_FILE}:"
+ echo "${DUPLICATE_INCLUDES_IN_HEADER_AND_CPP_FILES}"
+ 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}
diff --git a/src/chainparams.cpp b/src/chainparams.cpp
index adf8e6ae5b..6067503b0b 100644
--- a/src/chainparams.cpp
+++ b/src/chainparams.cpp
@@ -11,7 +11,6 @@
#include <utilstrencodings.h>
#include <assert.h>
-#include <memory>
#include <chainparamsseeds.h>
diff --git a/src/chainparamsbase.cpp b/src/chainparamsbase.cpp
index c51a3fc960..e840a2ed30 100644
--- a/src/chainparamsbase.cpp
+++ b/src/chainparamsbase.cpp
@@ -9,7 +9,6 @@
#include <util.h>
#include <assert.h>
-#include <memory>
const std::string CBaseChainParams::MAIN = "main";
const std::string CBaseChainParams::TESTNET = "test";
diff --git a/src/init.cpp b/src/init.cpp
index 9684b0c702..9b6216d656 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -47,7 +47,6 @@
#include <walletinitinterface.h>
#include <stdint.h>
#include <stdio.h>
-#include <memory>
#ifndef WIN32
#include <signal.h>
diff --git a/src/interfaces/handler.cpp b/src/interfaces/handler.cpp
index 1443fe9f18..8e45faa2a5 100644
--- a/src/interfaces/handler.cpp
+++ b/src/interfaces/handler.cpp
@@ -7,7 +7,6 @@
#include <util.h>
#include <boost/signals2/connection.hpp>
-#include <memory>
#include <utility>
namespace interfaces {
diff --git a/src/interfaces/wallet.cpp b/src/interfaces/wallet.cpp
index 0244fe70f5..21543552db 100644
--- a/src/interfaces/wallet.cpp
+++ b/src/interfaces/wallet.cpp
@@ -22,8 +22,6 @@
#include <wallet/feebumper.h>
#include <wallet/wallet.h>
-#include <memory>
-
namespace interfaces {
namespace {
diff --git a/src/miner.cpp b/src/miner.cpp
index d2be393538..0660df928c 100644
--- a/src/miner.cpp
+++ b/src/miner.cpp
@@ -27,7 +27,6 @@
#include <validationinterface.h>
#include <algorithm>
-#include <memory>
#include <queue>
#include <utility>
diff --git a/src/net.cpp b/src/net.cpp
index f45592ab83..342dfbaeb9 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -20,7 +20,6 @@
#include <ui_interface.h>
#include <utilstrencodings.h>
-#include <memory>
#ifdef WIN32
#include <string.h>
#else
diff --git a/src/qt/paymentrequestplus.cpp b/src/qt/paymentrequestplus.cpp
index 357e98a53c..b0ef475b35 100644
--- a/src/qt/paymentrequestplus.cpp
+++ b/src/qt/paymentrequestplus.cpp
@@ -9,7 +9,6 @@
#include <qt/paymentrequestplus.h>
-#include <script/script.h>
#include <util.h>
#include <stdexcept>
diff --git a/src/random.cpp b/src/random.cpp
index a845526d8a..b004dcac39 100644
--- a/src/random.cpp
+++ b/src/random.cpp
@@ -15,7 +15,6 @@
#include <utilstrencodings.h> // for GetTime()
#include <stdlib.h>
-#include <limits>
#include <chrono>
#include <thread>
diff --git a/src/support/lockedpool.cpp b/src/support/lockedpool.cpp
index 51c337ed2f..f10fd07c63 100644
--- a/src/support/lockedpool.cpp
+++ b/src/support/lockedpool.cpp
@@ -27,7 +27,6 @@
#endif
#include <algorithm>
-#include <memory>
LockedPoolManager* LockedPoolManager::_instance = nullptr;
std::once_flag LockedPoolManager::init_flag;
diff --git a/src/test/test_bitcoin.cpp b/src/test/test_bitcoin.cpp
index 9390a93b99..4c758b9953 100644
--- a/src/test/test_bitcoin.cpp
+++ b/src/test/test_bitcoin.cpp
@@ -17,8 +17,6 @@
#include <rpc/register.h>
#include <script/sigcache.h>
-#include <memory>
-
void CConnmanTest::AddNode(CNode& node)
{
LOCK(g_connman->cs_vNodes);
diff --git a/src/wallet/db.cpp b/src/wallet/db.cpp
index 553cae4d02..91dde45423 100644
--- a/src/wallet/db.cpp
+++ b/src/wallet/db.cpp
@@ -8,7 +8,6 @@
#include <addrman.h>
#include <hash.h>
#include <protocol.h>
-#include <util.h>
#include <utilstrencodings.h>
#include <wallet/walletutil.h>
diff --git a/src/wallet/test/wallet_test_fixture.cpp b/src/wallet/test/wallet_test_fixture.cpp
index 5c550742c8..1452c5b548 100644
--- a/src/wallet/test/wallet_test_fixture.cpp
+++ b/src/wallet/test/wallet_test_fixture.cpp
@@ -6,7 +6,6 @@
#include <rpc/server.h>
#include <wallet/db.h>
-#include <wallet/wallet.h>
WalletTestingSetup::WalletTestingSetup(const std::string& chainName):
TestingSetup(chainName), m_wallet("mock", CWalletDBWrapper::CreateMock())
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index 894dfb035c..5485eb797e 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -8,7 +8,6 @@
#include <checkpoints.h>
#include <chain.h>
#include <wallet/coincontrol.h>
-#include <wallet/coinselection.h>
#include <consensus/consensus.h>
#include <consensus/validation.h>
#include <fs.h>
@@ -26,7 +25,6 @@
#include <scheduler.h>
#include <timedata.h>
#include <txmempool.h>
-#include <util.h>
#include <utilmoneystr.h>
#include <wallet/fees.h>