ci, iwyu: Fix warnings in `src/univalue` and treat them as errors
What changed, and why it matters
This commit is a routine code-quality cleanup. It removes unused C++ header includes from the univalue JSON library and adds the univalue source files to a CI check that treats 'include what you use' warnings as errors. There is no change to program behavior, no bug fix, and no security relevance.
No security action needed. Treat as normal CI/code-quality maintenance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff adjusts the IWYU (Include What You Use) enforced-files regex in ci/test/03_test_script.sh to cover src/univalue/lib/.cpp and src/univalue/test/.cpp. It then removes unused standard-library headers (
Changed components
src/univalue/lib/univalue.cppsrc/univalue/lib/univalue_get.cppsrc/univalue/lib/univalue_read.cppsrc/univalue/lib/univalue_write.cppsrc/univalue/test/object.cppsrc/univalue/test/unitester.cppci/test/03_test_script.shInspect captured patch +3 / −10
diff --git a/ci/test/03_test_script.sh b/ci/test/03_test_script.sh
index 454eadd9..3908b274 100755
--- a/ci/test/03_test_script.sh
+++ b/ci/test/03_test_script.sh
@@ -213,7 +213,7 @@ fi
if [[ "${RUN_IWYU}" == true ]]; then
# TODO: Consider enforcing IWYU across the entire codebase.
- FILES_WITH_ENFORCED_IWYU="/src/((crypto|index|kernel|primitives|zmq)/.*\\.cpp|node/blockstorage.cpp|node/utxo_snapshot.cpp|core_io.cpp|signet.cpp)"
+ FILES_WITH_ENFORCED_IWYU="/src/((crypto|index|kernel|primitives|univalue/(lib|test)|zmq)/.*\\.cpp|node/blockstorage\\.cpp|node/utxo_snapshot\\.cpp|core_io\\.cpp|signet\\.cpp)"
jq --arg patterns "$FILES_WITH_ENFORCED_IWYU" 'map(select(.file | test($patterns)))' "${BASE_BUILD_DIR}/compile_commands.json" > "${BASE_BUILD_DIR}/compile_commands_iwyu_errors.json"
jq --arg patterns "$FILES_WITH_ENFORCED_IWYU" 'map(select(.file | test($patterns) | not))' "${BASE_BUILD_DIR}/compile_commands.json" > "${BASE_BUILD_DIR}/compile_commands_iwyu_warnings.json"
diff --git a/src/univalue/lib/univalue.cpp b/src/univalue/lib/univalue.cpp
index 4d37c81f..6aeff001 100644
--- a/src/univalue/lib/univalue.cpp
+++ b/src/univalue/lib/univalue.cpp
@@ -7,7 +7,6 @@
#include <iomanip>
#include <map>
-#include <memory>
#include <sstream>
#include <string>
#include <utility>
diff --git a/src/univalue/lib/univalue_get.cpp b/src/univalue/lib/univalue_get.cpp
index 037449ca..146cc421 100644
--- a/src/univalue/lib/univalue_get.cpp
+++ b/src/univalue/lib/univalue_get.cpp
@@ -5,11 +5,7 @@
#include <univalue.h>
-#include <cerrno>
-#include <cstdint>
-#include <cstdlib>
#include <cstring>
-#include <limits>
#include <locale>
#include <sstream>
#include <stdexcept>
diff --git a/src/univalue/lib/univalue_read.cpp b/src/univalue/lib/univalue_read.cpp
index 40d465f4..89d8b900 100644
--- a/src/univalue/lib/univalue_read.cpp
+++ b/src/univalue/lib/univalue_read.cpp
@@ -6,7 +6,6 @@
#include <univalue_utffilter.h>
#include <cstdint>
-#include <cstdio>
#include <cstring>
#include <string>
#include <string_view>
diff --git a/src/univalue/lib/univalue_write.cpp b/src/univalue/lib/univalue_write.cpp
index 4a221906..0161967a 100644
--- a/src/univalue/lib/univalue_write.cpp
+++ b/src/univalue/lib/univalue_write.cpp
@@ -5,7 +5,6 @@
#include <univalue.h>
#include <univalue_escapes.h>
-#include <memory>
#include <string>
#include <vector>
diff --git a/src/univalue/test/object.cpp b/src/univalue/test/object.cpp
index 1d072c34..be98ae41 100644
--- a/src/univalue/test/object.cpp
+++ b/src/univalue/test/object.cpp
@@ -8,7 +8,6 @@
#include <cassert>
#include <cstdint>
#include <map>
-#include <memory>
#include <stdexcept>
#include <string>
#include <string_view>
diff --git a/src/univalue/test/unitester.cpp b/src/univalue/test/unitester.cpp
index e517e641..e82ea74d 100644
--- a/src/univalue/test/unitester.cpp
+++ b/src/univalue/test/unitester.cpp
@@ -63,8 +63,9 @@
#include <array>
#include <cassert>
-#include <cstdio>
#include <string>
+#include <string_view>
+#include <tuple>
static std::string rtrim(std::string s)
{
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.