From fad0fc3c9a9759dfb2bb1bdf1aaa5e1d08c0ab9c Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Tue, 10 Apr 2018 14:39:22 -0400 Subject: [PATCH] Refine travis check for duplicate includes This partially reverts commit c36b720d009f1ab1c3900750e05c1f17412e564d. --- contrib/devtools/lint-includes.sh | 11 ----------- doc/developer-notes.md | 3 +-- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/contrib/devtools/lint-includes.sh b/contrib/devtools/lint-includes.sh index baca2f8a1..f54be46b5 100755 --- a/contrib/devtools/lint-includes.sh +++ b/contrib/devtools/lint-includes.sh @@ -19,17 +19,6 @@ for HEADER_FILE in $(filter_suffix h); do 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) diff --git a/doc/developer-notes.md b/doc/developer-notes.md index 980eed44f..6b5311d3e 100644 --- a/doc/developer-notes.md +++ b/doc/developer-notes.md @@ -569,8 +569,7 @@ Source code organization - *Rationale*: Shorter and simpler header files are easier to read, and reduce compile time - Every `.cpp` and `.h` file should `#include` every header file it directly uses classes, functions or other - definitions from, even if those headers are already included indirectly through other headers. One exception - is that a `.cpp` file does not need to re-include the includes already included in its corresponding `.h` file. + definitions from, even if those headers are already included indirectly through other headers. - *Rationale*: Excluding headers because they are already indirectly included results in compilation failures when those indirect dependencies change. Furthermore, it obscures what the real code