refactor: Enable misc-definitions-in-headers
What changed, and why it matters
This commit is a code cleanup: it turns on a clang-tidy style check called 'misc-definitions-in-headers' and suppresses that check around a large inline implementation block in a benchmark header. There is no change to Bitcoin's runtime behavior, consensus rules, wallet handling, or network code. It only affects static analysis and the internal benchmark tool.
No security action needed. This is a refactoring/static-analysis change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change adds ‘misc-definitions-in-headers’ to src/.clang-tidy and wraps the existing ANKERL_NANOBENCH_IMPLEMENT implementation section in src/bench/nanobench.h with NOLINTBEGIN/NOLINTEND. This tells the clang-tidy linter to ignore the known pattern of placing function definitions in a header when that macro is defined. No functional code was modified.
Changed components
src/.clang-tidysrc/bench/nanobench.hInspect captured patch +3 / −0
diff --git a/src/.clang-tidy b/src/.clang-tidy
index 56f4b71f..4e0af3f3 100644
--- a/src/.clang-tidy
+++ b/src/.clang-tidy
@@ -9,6 +9,7 @@ bugprone-lambda-function-name,
bugprone-unhandled-self-assignment,
bugprone-unused-return-value,
fuchsia-header-anon-namespaces,
+misc-definitions-in-headers,
misc-no-recursion,
misc-unused-using-decls,
modernize-avoid-bind,
diff --git a/src/bench/nanobench.h b/src/bench/nanobench.h
index a66e92a4..ffcc4802 100644
--- a/src/bench/nanobench.h
+++ b/src/bench/nanobench.h
@@ -1369,6 +1369,7 @@ void doNotOptimizeAway(T const& val) {
} // namespace ankerl
#if defined(ANKERL_NANOBENCH_IMPLEMENT)
+// NOLINTBEGIN(misc-definitions-in-headers)
///////////////////////////////////////////////////////////////////////////////////////////////////
// implementation part - only visible in .cpp
@@ -3563,5 +3564,6 @@ std::ostream& operator<<(std::ostream& os, std::vector<ankerl::nanobench::BigO>
} // namespace nanobench
} // namespace ankerl
+// NOLINTEND(misc-definitions-in-headers)
#endif // ANKERL_NANOBENCH_IMPLEMENT
#endif // ANKERL_NANOBENCH_H_INCLUDED
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.