From d9e594463a571ff37b5e810918843081460e5b0c Mon Sep 17 00:00:00 2001 From: Kyle Knoepfel Date: Wed, 28 Oct 2026 23:25:50 -0500 Subject: [PATCH] chore(clang-tidy): address findings and suppress false positives Remove unused includes and redundant initialization, add direct declaration includes, and improve const correctness. Disable noisy template virtual-function portability diagnostics and ignore libstdc++ internal headers in include-cleaner. Add targeted suppressions for const-correctness and the sanitizer-checked FORM writer leak false positive. --- .clang-tidy | 2 ++ form/persistence/persistence_reader.cpp | 8 +------- form/persistence/persistence_reader.hpp | 2 +- phlex/core/framework_graph.hpp | 4 ++-- phlex/model/fixed_hierarchy.cpp | 2 ++ plugins/generate_layers.cpp | 1 - plugins/python/src/modulewrap.cpp | 2 +- test/accumulator_test.cpp | 1 + test/form/cell_number_vector.cpp | 2 +- test/form/form_basics_test.cpp | 2 ++ test/multilayer_join_test.cpp | 2 -- test/replicated_test.cpp | 2 +- test/yielding_driver_test.cpp | 1 + 13 files changed, 15 insertions(+), 16 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 9939d292a..56c579b75 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -27,6 +27,7 @@ Checks: - '-modernize-use-nodiscard' - 'performance-*' - 'portability-*' + - '-portability-template-virtual-member-function' - 'readability-*' - '-readability-function-cognitive-complexity' - '-readability-identifier-length' @@ -114,6 +115,7 @@ CheckOptions: - key: misc-include-cleaner.IgnoreHeaders value: >- __[^/]+/.*; + bits/.*; .*python[0-9.]+/.*; boost/mp11/detail/.*; boost/program_options/.* diff --git a/form/persistence/persistence_reader.cpp b/form/persistence/persistence_reader.cpp index 58f507171..779049c12 100644 --- a/form/persistence/persistence_reader.cpp +++ b/form/persistence/persistence_reader.cpp @@ -8,7 +8,6 @@ #include "persistence_utils.hpp" #include "storage/istorage.hpp" -#include #include #include #include @@ -24,12 +23,7 @@ namespace form::detail::experimental { } } -persistence_reader::persistence_reader() : - store_reader_(create_storage_reader()), - config_items_(), - tech_settings_() // constructor takes form config -{ -} +persistence_reader::persistence_reader() : store_reader_(create_storage_reader()) {} void persistence_reader::configure_tech_settings( form::experimental::config::tech_setting_config const& tech_config_settings) diff --git a/form/persistence/persistence_reader.hpp b/form/persistence/persistence_reader.hpp index 4ba1bb41d..072163145 100644 --- a/form/persistence/persistence_reader.hpp +++ b/form/persistence/persistence_reader.hpp @@ -53,7 +53,7 @@ namespace form::detail::experimental { std::unique_ptr store_reader_; form::experimental::config::item_config config_items_; - form::experimental::config::tech_setting_config tech_settings_; + form::experimental::config::tech_setting_config tech_settings_{}; }; } // namespace form::detail::experimental diff --git a/phlex/core/framework_graph.hpp b/phlex/core/framework_graph.hpp index b38eb45dc..1e68fb1a4 100644 --- a/phlex/core/framework_graph.hpp +++ b/phlex/core/framework_graph.hpp @@ -220,11 +220,11 @@ namespace phlex::detail { fixed_hierarchy fixed_hierarchy_; // The graph_ object uses the filters_, nodes_, resources_, and hierarchy_ objects implicitly. // These must be declared before graph_ so that they outlive it during destruction. - data_layer_hierarchy hierarchy_{}; + data_layer_hierarchy hierarchy_; resource_catalog resources_; node_catalog nodes_; std::map filters_; - tbb::flow::graph graph_{}; + tbb::flow::graph graph_; std::optional driver_; std::vector registration_errors_; data_cell_tracker cell_tracker_; diff --git a/phlex/model/fixed_hierarchy.cpp b/phlex/model/fixed_hierarchy.cpp index 9ac859e7b..9d1cc5de1 100644 --- a/phlex/model/fixed_hierarchy.cpp +++ b/phlex/model/fixed_hierarchy.cpp @@ -26,6 +26,8 @@ namespace { // NOLINTNEXTLINE(performance-unnecessary-value-param) std::vector unique_paths(std::vector paths) { + // clang-tidy doesn't recognize the following line as a move, so it produces a false positive. + // NOLINTNEXTLINE(misc-const-correctness) std::set unique{std::from_range, std::move(paths)}; return {std::from_range, std::move(unique)}; } diff --git a/plugins/generate_layers.cpp b/plugins/generate_layers.cpp index 84692d065..6e9c7d90e 100644 --- a/plugins/generate_layers.cpp +++ b/plugins/generate_layers.cpp @@ -19,7 +19,6 @@ #include "phlex/driver.hpp" #include "plugins/layer_generator.hpp" -#include #include PHLEX_REGISTER_DRIVER(d, config) diff --git a/plugins/python/src/modulewrap.cpp b/plugins/python/src/modulewrap.cpp index eaf1cf8d5..c2928ac87 100644 --- a/plugins/python/src/modulewrap.cpp +++ b/plugins/python/src/modulewrap.cpp @@ -353,7 +353,7 @@ namespace { break; } - Py_ssize_t sz = PyUnicode_GetLength(item); + Py_ssize_t const sz = PyUnicode_GetLength(item); cargs.emplace_back(p, static_cast(sz)); } diff --git a/test/accumulator_test.cpp b/test/accumulator_test.cpp index cedbb20a6..309757d22 100644 --- a/test/accumulator_test.cpp +++ b/test/accumulator_test.cpp @@ -1,6 +1,7 @@ #include "phlex/core/detail/accumulator_node.hpp" #include "phlex/core/message.hpp" #include "phlex/model/data_cell_index.hpp" +#include "phlex/model/fwd.hpp" #include "phlex/model/identifier.hpp" #include "phlex/model/product_specification.hpp" #include "test/ostream_logger.hpp" diff --git a/test/form/cell_number_vector.cpp b/test/form/cell_number_vector.cpp index 61d6f7d3b..bc0c347d5 100644 --- a/test/form/cell_number_vector.cpp +++ b/test/form/cell_number_vector.cpp @@ -58,7 +58,7 @@ PHLEX_REGISTER_ALGORITHMS(m, config) m.transform( "stamp", [](std::vector const& values) { - thread_local std::mt19937 gen{std::random_device{}()}; + static thread_local std::mt19937 gen{std::random_device{}()}; std::this_thread::sleep_for( std::chrono::microseconds(std::uniform_int_distribution(0, 2000)(gen))); return values; diff --git a/test/form/form_basics_test.cpp b/test/form/form_basics_test.cpp index 7feba1ba2..51f8cbbac 100644 --- a/test/form/form_basics_test.cpp +++ b/test/form/form_basics_test.cpp @@ -1786,6 +1786,8 @@ TEST_CASE("stage: an empty stage is written like any other stage", "[form]") TEST_CASE("stage: different creators at different stages each get their own stream", "[form]") { + // False positive: staged_writer::form retains unique_ptr ownership; leak-sanitizer test passes. + // NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks) auto writer = make_staged_writer({"hits", "showers"}); int const payload = 0; auto& form = *writer.form; diff --git a/test/multilayer_join_test.cpp b/test/multilayer_join_test.cpp index dac4a4c70..379678191 100644 --- a/test/multilayer_join_test.cpp +++ b/test/multilayer_join_test.cpp @@ -10,9 +10,7 @@ #include #include -#include #include -#include #include #include diff --git a/test/replicated_test.cpp b/test/replicated_test.cpp index 5da14d7fa..cd9602511 100644 --- a/test/replicated_test.cpp +++ b/test/replicated_test.cpp @@ -21,7 +21,7 @@ namespace { auto increment(unsigned int i) { - thread_counter c{counter}; + thread_counter const c{counter}; ++processed_messages; return i; } diff --git a/test/yielding_driver_test.cpp b/test/yielding_driver_test.cpp index 439e571cf..ef5b656d5 100644 --- a/test/yielding_driver_test.cpp +++ b/test/yielding_driver_test.cpp @@ -1,4 +1,5 @@ #include "phlex/model/data_cell_index.hpp" +#include "phlex/model/fwd.hpp" #include "phlex/model/index_generator.hpp" #include "phlex/utilities/resumable_driver.hpp"