From 94cfd51d45e562d1e1b14ea7c8f23eda3bb47882 Mon Sep 17 00:00:00 2001 From: Kyle Knoepfel Date: Thu, 23 Jul 2026 11:10:01 -0500 Subject: [PATCH 1/2] Resolve readability-braces-around-statements clang-tidy warning --- form/form/config.cpp | 3 +- form/form/form_writer.cpp | 3 +- form/persistence/persistence_utils.cpp | 3 +- form/storage/storage_reader.cpp | 24 +++++--- form/storage/storage_writer.cpp | 6 +- phlex/app/load_module.cpp | 3 +- phlex/model/data_cell_index.cpp | 3 +- plugins/python/src/configwrap.cpp | 21 ++++--- plugins/python/src/dyncall.cpp | 52 +++++++++------- plugins/python/src/errorwrap.cpp | 3 +- plugins/python/src/lifelinewrap.cpp | 3 +- plugins/python/src/modulewrap.cpp | 72 +++++++++++++++-------- plugins/python/src/pymodule.cpp | 27 ++++++--- test/form/form_root_schema_read_test.cpp | 3 +- test/form/form_root_schema_write_test.cpp | 3 +- test/form/form_storage_test.cpp | 3 +- test/form/generate_vector.cpp | 3 +- test/form/reader.cpp | 12 ++-- test/form/test_utils.hpp | 6 +- test/form/writer.cpp | 12 ++-- 20 files changed, 171 insertions(+), 94 deletions(-) diff --git a/form/form/config.cpp b/form/form/config.cpp index 998e4c340..3c5d98ca7 100644 --- a/form/form/config.cpp +++ b/form/form/config.cpp @@ -5,8 +5,9 @@ namespace { auto const_lookup(const MAP_LIKE& map, typename MAP_LIKE::key_type const& key) { auto const found = map.find(key); - if (found != map.end()) + if (found != map.end()) { return found->second; + } return decltype(found->second)(); } } diff --git a/form/form/form_writer.cpp b/form/form/form_writer.cpp index 6a30c82cb..f56641f63 100644 --- a/form/form/form_writer.cpp +++ b/form/form/form_writer.cpp @@ -47,8 +47,9 @@ namespace form::experimental { std::vector const& products) { - if (products.empty()) + if (products.empty()) { return; + } auto it = m_product_to_config.find(products[0].label); if (it == m_product_to_config.end()) { diff --git a/form/persistence/persistence_utils.cpp b/form/persistence/persistence_utils.cpp index 372eae13c..a98fa1d5d 100644 --- a/form/persistence/persistence_utils.cpp +++ b/form/persistence/persistence_utils.cpp @@ -6,12 +6,13 @@ namespace form::detail::experimental { form::experimental::config::ItemConfig const& config, std::string const& label) { auto const& items = config.getItems(); - if (label == "index") + if (label == "index") { return (items.empty()) ? std::nullopt : std::make_optional( *items .begin()); //emulate how FORM did this before Phlex PR #22. Will be fixed in a future FORM update. + } return config.findItem(label); } diff --git a/form/storage/storage_reader.cpp b/form/storage/storage_reader.cpp index 8634a4b06..4e77811d5 100644 --- a/form/storage/storage_reader.cpp +++ b/form/storage/storage_reader.cpp @@ -211,15 +211,17 @@ int StorageReader::getIndex(Token const& token, m_files.insert({token.fileName(), createFile(token.technology(), token.fileName(), 'i')}) .first; for (auto const& [key, value] : - get_file_table(settings, token.technology(), token.fileName())) + get_file_table(settings, token.technology(), token.fileName())) { file->second->setAttribute(key, value); + } } cont = m_read_containers .insert({key, createReadContainer(token.technology(), token.containerName())}) .first; for (auto const& [key, value] : - get_container_table(settings, token.technology(), token.containerName())) + get_container_table(settings, token.technology(), token.containerName())) { cont->second->setAttribute(key, value); + } cont->second->setFile(file->second); } auto const& type = typeid(std::string); @@ -286,16 +288,18 @@ void StorageReader::prime(Token const& token, m_files.insert({token.fileName(), createFile(token.technology(), token.fileName(), 'i')}) .first; for (auto const& [key, value] : - get_file_table(settings, token.technology(), token.fileName())) + get_file_table(settings, token.technology(), token.fileName())) { file->second->setAttribute(key, value); + } } cont = m_read_containers .insert({key, createReadContainer(token.technology(), token.containerName())}) .first; cont->second->setFile(file->second); for (auto const& [key, value] : - get_container_table(settings, token.technology(), token.containerName())) + get_container_table(settings, token.technology(), token.containerName())) { cont->second->setAttribute(key, value); + } } cont->second->prime(type); } @@ -313,15 +317,17 @@ std::vector StorageReader::listIndices( m_files.insert({token.fileName(), createFile(token.technology(), token.fileName(), 'i')}) .first; for (auto const& [key, value] : - get_file_table(settings, token.technology(), token.fileName())) + get_file_table(settings, token.technology(), token.fileName())) { file->second->setAttribute(key, value); + } } cont = m_read_containers .insert({key, createReadContainer(token.technology(), token.containerName())}) .first; for (auto const& [key, value] : - get_container_table(settings, token.technology(), token.containerName())) + get_container_table(settings, token.technology(), token.containerName())) { cont->second->setAttribute(key, value); + } cont->second->setFile(file->second); } @@ -371,16 +377,18 @@ void StorageReader::readContainer(Token const& token, m_files.insert({token.fileName(), createFile(token.technology(), token.fileName(), 'i')}) .first; for (auto const& [key, value] : - get_file_table(settings, token.technology(), token.fileName())) + get_file_table(settings, token.technology(), token.fileName())) { file->second->setAttribute(key, value); + } } cont = m_read_containers .insert({key, createReadContainer(token.technology(), token.containerName())}) .first; cont->second->setFile(file->second); for (auto const& [key, value] : - get_container_table(settings, token.technology(), token.containerName())) + get_container_table(settings, token.technology(), token.containerName())) { cont->second->setAttribute(key, value); + } } cont->second->read(token.id(), data, type); return; diff --git a/form/storage/storage_writer.cpp b/form/storage/storage_writer.cpp index a5c4f9b03..720b7bbb6 100644 --- a/form/storage/storage_writer.cpp +++ b/form/storage/storage_writer.cpp @@ -68,8 +68,9 @@ void StorageWriter::createContainers( .insert({plcmnt->fileName(), createFile(plcmnt->technology(), plcmnt->fileName(), 'o')}) .first; for (auto const& [key, value] : - get_file_table(settings, plcmnt->technology(), plcmnt->fileName())) + get_file_table(settings, plcmnt->technology(), plcmnt->fileName())) { file->second->setAttribute(key, value); + } } // Create and bind container to file auto container = createWriteContainer(plcmnt->technology(), plcmnt->containerName()); @@ -93,8 +94,9 @@ void StorageWriter::createContainers( } for (auto const& [key, value] : - get_container_table(settings, plcmnt->technology(), plcmnt->containerName())) + get_container_table(settings, plcmnt->technology(), plcmnt->containerName())) { container->setAttribute(key, value); + } container->setFile(file->second); container->setupWrite(*type); } diff --git a/phlex/app/load_module.cpp b/phlex/app/load_module.cpp index 04286af0d..2878030e6 100644 --- a/phlex/app/load_module.cpp +++ b/phlex/app/load_module.cpp @@ -68,8 +68,9 @@ namespace phlex::detail { // Called during single-threaded graph construction char const* plugin_path_ptr = std::getenv("PHLEX_PLUGIN_PATH"); // NOLINT(concurrency-mt-unsafe) - if (!plugin_path_ptr) + if (!plugin_path_ptr) { throw std::runtime_error("PHLEX_PLUGIN_PATH has not been set."); + } std::vector subdirs; boost::split(subdirs, plugin_path_ptr, boost::is_any_of(":")); diff --git a/phlex/model/data_cell_index.cpp b/phlex/model/data_cell_index.cpp index 13ea07302..2010c36f5 100644 --- a/phlex/model/data_cell_index.cpp +++ b/phlex/model/data_cell_index.cpp @@ -89,8 +89,9 @@ namespace phlex { bool data_cell_index::operator==(data_cell_index const& other) const { - if (depth_ != other.depth_) + if (depth_ != other.depth_) { return false; + } auto const same_numbers = number_ == other.number_; if (not parent_) { return same_numbers; diff --git a/plugins/python/src/configwrap.cpp b/plugins/python/src/configwrap.cpp index d4957e25c..ad4f6cb43 100644 --- a/plugins/python/src/configwrap.cpp +++ b/plugins/python/src/configwrap.cpp @@ -30,8 +30,9 @@ PyObject* phlex::experimental::wrap_configuration(configuration const& config) static py_config_map* pcm_new(PyTypeObject* subtype, PyObject*, PyObject*) { auto* pcm = reinterpret_cast(subtype->tp_alloc(subtype, 0)); - if (!pcm) + if (!pcm) { return nullptr; + } pcm->ph_config_cache = PyDict_New(); @@ -91,8 +92,9 @@ static PyObject* pcm_subscript(py_config_map* pycmap, PyObject* pykey) if (k.first == boost::json::kind::bool_) { auto const& cvalue = pycmap->ph_config->get>(ckey); auto const cvalue_size = checked_tuple_size(cvalue.size()); - if (!cvalue_size) + if (!cvalue_size) { return nullptr; + } pyvalue = PyTuple_New(*cvalue_size); // We can use std::views::enumerate once the AppleClang C++ STL supports it. for (Py_ssize_t i = 0; i < *cvalue_size; ++i) { @@ -102,8 +104,9 @@ static PyObject* pcm_subscript(py_config_map* pycmap, PyObject* pykey) } else if (k.first == boost::json::kind::int64) { auto const& cvalue = pycmap->ph_config->get>(ckey); auto const cvalue_size = checked_tuple_size(cvalue.size()); - if (!cvalue_size) + if (!cvalue_size) { return nullptr; + } pyvalue = PyTuple_New(*cvalue_size); // We can use std::views::enumerate once the AppleClang C++ STL supports it. for (Py_ssize_t i = 0; i < *cvalue_size; ++i) { @@ -114,8 +117,9 @@ static PyObject* pcm_subscript(py_config_map* pycmap, PyObject* pykey) } else if (k.first == boost::json::kind::uint64) { auto const& cvalue = pycmap->ph_config->get>(ckey); auto const cvalue_size = checked_tuple_size(cvalue.size()); - if (!cvalue_size) + if (!cvalue_size) { return nullptr; + } pyvalue = PyTuple_New(*cvalue_size); // We can use std::views::enumerate once the AppleClang C++ STL supports it. for (Py_ssize_t i = 0; i < *cvalue_size; ++i) { @@ -126,8 +130,9 @@ static PyObject* pcm_subscript(py_config_map* pycmap, PyObject* pykey) } else if (k.first == boost::json::kind::double_) { auto const& cvalue = pycmap->ph_config->get>(ckey); auto const cvalue_size = checked_tuple_size(cvalue.size()); - if (!cvalue_size) + if (!cvalue_size) { return nullptr; + } pyvalue = PyTuple_New(*cvalue_size); // We can use std::views::enumerate once the AppleClang C++ STL supports it. for (Py_ssize_t i = 0; i < *cvalue_size; ++i) { @@ -137,8 +142,9 @@ static PyObject* pcm_subscript(py_config_map* pycmap, PyObject* pykey) } else if (k.first == boost::json::kind::string) { auto const& cvalue = pycmap->ph_config->get>(ckey); auto const cvalue_size = checked_tuple_size(cvalue.size()); - if (!cvalue_size) + if (!cvalue_size) { return nullptr; + } pyvalue = PyTuple_New(*cvalue_size); // We can use std::views::enumerate once the AppleClang C++ STL supports it. for (Py_ssize_t i = 0; i < *cvalue_size; ++i) { @@ -150,8 +156,9 @@ static PyObject* pcm_subscript(py_config_map* pycmap, PyObject* pykey) auto const& cvalue = pycmap->ph_config->get>>(ckey); auto const cvalue_size = checked_tuple_size(cvalue.size()); - if (!cvalue_size) + if (!cvalue_size) { return nullptr; + } pyvalue = PyTuple_New(*cvalue_size); // We can use std::views::enumerate once the AppleClang C++ STL supports it. for (Py_ssize_t i = 0; i < *cvalue_size; ++i) { diff --git a/plugins/python/src/dyncall.cpp b/plugins/python/src/dyncall.cpp index 80ec220e4..5892ddd95 100644 --- a/plugins/python/src/dyncall.cpp +++ b/plugins/python/src/dyncall.cpp @@ -14,23 +14,30 @@ using namespace phlex::experimental; phlex::experimental::dcarg phlex::experimental::dcarg::from_str(std::string const& stype) { // only types currently used in modulewrap are added, not all ffi types - if (stype == "bool") + if (stype == "bool") { return dcarg(false); - if (stype == "int32_t") + } + if (stype == "int32_t") { return dcarg(static_cast(0)); - else if (stype == "uint32_t") + } + if (stype == "uint32_t") { return dcarg(static_cast(0)); - else if (stype == "int64_t") + } + if (stype == "int64_t") { return dcarg(static_cast(0)); - else if (stype == "uint64_t") + } + if (stype == "uint64_t") { return dcarg(static_cast(0)); - else if (stype == "float") + } + if (stype == "float") { return dcarg(0.0f); - else if (stype == "double") + } + if (stype == "double") { return dcarg(0.0); - else if (stype == "void") + } + if (stype == "void") { return dcarg{}; - + } throw std::invalid_argument("unknown type string: " + stype); } @@ -60,32 +67,33 @@ namespace { // with each type on its own line, however, rather than combining the // two in a single predicate as a special case // NOLINTBEGIN(bugprone-branch-clone) - if constexpr (std::is_same_v) + if constexpr (std::is_same_v) { return &ffi_type_void; - else if constexpr (std::is_same_v) + } else if constexpr (std::is_same_v) { return &ffi_type_pointer; - else if constexpr (std::is_same_v) + } else if constexpr (std::is_same_v) { return &ffi_type_uint8; - else if constexpr (std::is_same_v) + } else if constexpr (std::is_same_v) { return &ffi_type_sint8; - else if constexpr (std::is_same_v) + } else if constexpr (std::is_same_v) { return &ffi_type_uint8; - else if constexpr (std::is_same_v) + } else if constexpr (std::is_same_v) { return &ffi_type_sint16; - else if constexpr (std::is_same_v) + } else if constexpr (std::is_same_v) { return &ffi_type_uint16; - else if constexpr (std::is_same_v) + } else if constexpr (std::is_same_v) { return &ffi_type_sint32; - else if constexpr (std::is_same_v) + } else if constexpr (std::is_same_v) { return &ffi_type_uint32; - else if constexpr (std::is_same_v) + } else if constexpr (std::is_same_v) { return &ffi_type_sint64; - else if constexpr (std::is_same_v) + } else if constexpr (std::is_same_v) { return &ffi_type_uint64; - else if constexpr (std::is_same_v) + } else if constexpr (std::is_same_v) { return &ffi_type_float; - else if constexpr (std::is_same_v) + } else if constexpr (std::is_same_v) { return &ffi_type_double; + } // NOLINTEND(bugprone-branch-clone) }, d.m_value); diff --git a/plugins/python/src/errorwrap.cpp b/plugins/python/src/errorwrap.cpp index 1ff3901b8..e4020177b 100644 --- a/plugins/python/src/errorwrap.cpp +++ b/plugins/python/src/errorwrap.cpp @@ -69,8 +69,9 @@ bool phlex::experimental::msg_from_py_error(std::string& msg, bool check_error) PyGILRAII g; if (check_error) { - if (!PyErr_Occurred()) + if (!PyErr_Occurred()) { return false; + } } #if PY_VERSION_HEX < 0x30c000000 diff --git a/plugins/python/src/lifelinewrap.cpp b/plugins/python/src/lifelinewrap.cpp index 50e98fd9b..57a38f3d5 100644 --- a/plugins/python/src/lifelinewrap.cpp +++ b/plugins/python/src/lifelinewrap.cpp @@ -19,8 +19,9 @@ static py_lifeline_t* ll_new(PyTypeObject* pytype, PyObject*, PyObject*) static int ll_traverse(py_lifeline_t* pyobj, visitproc visit, void* args) { - if (pyobj->m_view) + if (pyobj->m_view) { visit(pyobj->m_view, args); + } return 0; } diff --git a/plugins/python/src/modulewrap.cpp b/plugins/python/src/modulewrap.cpp index fcc04f733..ff6a4fd06 100644 --- a/plugins/python/src/modulewrap.cpp +++ b/plugins/python/src/modulewrap.cpp @@ -181,19 +181,22 @@ namespace { std::string error_msg; if (!result.get()) { - if (!msg_from_py_error(error_msg)) + if (!msg_from_py_error(error_msg)) { error_msg = "Unknown python error"; + } } decref_all(args...); - if (!error_msg.empty()) + if (!error_msg.empty()) { throw std::runtime_error(error_msg.c_str()); + } - if constexpr (!std::is_void_v) + if constexpr (!std::is_void_v) { return result; - else + } else { Py_DECREF(result.get()); + } } private: @@ -227,8 +230,9 @@ namespace { dyncall((void*)m_ccallback, result, argsv); // TODO: error reporting? - if constexpr (!std::is_void_v) + if constexpr (!std::is_void_v) { return result; + } } }; @@ -281,12 +285,14 @@ namespace { std::vector validate_input(PyObject* input) { std::vector cargs; - if (!input) + if (!input) { return cargs; + } PyObject* coll = PySequence_Fast(input, "input_family must be a sequence"); - if (!coll) + if (!coll) { return cargs; + } Py_ssize_t len = PySequence_Fast_GET_SIZE(coll); cargs.reserve(static_cast(len)); @@ -306,21 +312,23 @@ namespace { Py_DECREF(coll); - if (PyErr_Occurred()) + if (PyErr_Occurred()) { cargs.clear(); // error handled through Python - + } return cargs; } std::vector validate_output(PyObject* output) { std::vector cargs; - if (!output) + if (!output) { return cargs; + } PyObject* coll = PySequence_Fast(output, "output_product_suffixes must be a sequence"); - if (!coll) + if (!coll) { return cargs; + } Py_ssize_t len = PySequence_Fast_GET_SIZE(coll); cargs.reserve(static_cast(len)); @@ -344,8 +352,9 @@ namespace { Py_DECREF(coll); - if (PyErr_Occurred()) + if (PyErr_Occurred()) { cargs.clear(); // error handled through Python + } return cargs; } @@ -367,13 +376,15 @@ namespace { Py_DECREF(nbmod); } - if (!cfunc_type) + if (!cfunc_type) { PyErr_Clear(); + } // hard reference to cfunc_type here if not null } - if (!cfunc_type) + if (!cfunc_type) { return false; + } int result = PyObject_IsInstance(obj, cfunc_type); return result == 1; @@ -393,19 +404,22 @@ namespace { // this would only fail if the phlex installation were broken and // only exists to get a proper error message instead of a segfault // in that rather unlikely case - if (!normalizer) + if (!normalizer) { return ""; + } // LCOV_EXCL_STOP } PyObject* norm = PyObject_CallOneArg(normalizer, pyobj); - if (!norm) + if (!norm) { return ""; + } char const* ann = PyUnicode_AsUTF8(norm); Py_DECREF(norm); - if (!ann) + if (!ann) { return ""; + } return ann; } @@ -478,8 +492,9 @@ namespace { } } } else { - if (!PyErr_Occurred()) + if (!PyErr_Occurred()) { PyErr_SetString(PyExc_TypeError, "unknown annotation formatting"); + } } Py_XDECREF(annot); @@ -831,12 +846,14 @@ static PyObject* parse_args(PyObject* args, // retrieve C++ (matching) types if provided input_types.reserve(input_selectors.size()); - if (!annotations_to_strings(callable, input_types, output_types)) + if (!annotations_to_strings(callable, input_types, output_types)) { return nullptr; // Python error already set + } // ignore None as Python's conventional "void" return, which is meaningless in C++ - if (output_types.size() == 1 && output_types[0] == "None") + if (output_types.size() == 1 && output_types[0] == "None") { output_types.clear(); + } // if annotations were correct (and correctly parsed), there should be as many // input types as input product selectors @@ -1029,8 +1046,9 @@ static PyObject* md_transform(py_phlex_module* mod, PyObject* args, PyObject* kw PyObject* callable = parse_args( args, kwds, cname, input_selectors, input_types, output_suffixes, output_types, nconcur); - if (!callable) + if (!callable) { return nullptr; // error already set + } // detect numba and extract C function pointer if any, else use default Python // callable dispatcher @@ -1041,8 +1059,9 @@ static PyObject* md_transform(py_phlex_module* mod, PyObject* args, PyObject* kw ccallf = PyLong_AsVoidPtr(pyaddr); Py_DECREF(pyaddr); } - if (!ccallf) + if (!ccallf) { PyErr_Clear(); + } } if (output_types.empty()) { @@ -1175,8 +1194,9 @@ static PyObject* md_observe(py_phlex_module* mod, PyObject* args, PyObject* kwds PyObject* callable = parse_args( args, kwds, cname, input_selectors, input_types, output_suffixes, output_types, nconcur); - if (!callable) + if (!callable) { return nullptr; // error already set + } // detect numba and extract C function pointer if any, else use default Python // callable dispatcher @@ -1187,8 +1207,9 @@ static PyObject* md_observe(py_phlex_module* mod, PyObject* args, PyObject* kwds ccallf = PyLong_AsVoidPtr(pyaddr); Py_DECREF(pyaddr); } - if (!ccallf) + if (!ccallf) { PyErr_Clear(); + } } if (!output_types.empty()) { @@ -1374,8 +1395,9 @@ static PyObject* sc_provide(py_phlex_source* src, PyObject* args, PyObject* kwds // retrieve C++ (matching) types from annotations std::vector input_types; std::vector output_types; - if (!annotations_to_strings(callable, input_types, output_types)) + if (!annotations_to_strings(callable, input_types, output_types)) { return nullptr; // Python error already set + } // provider needs to take a single "data_cell_input" if (input_types.size() != 1 || input_types[0] != "data_cell_index") { diff --git a/plugins/python/src/pymodule.cpp b/plugins/python/src/pymodule.cpp index 520acdf4a..a437cada3 100644 --- a/plugins/python/src/pymodule.cpp +++ b/plugins/python/src/pymodule.cpp @@ -53,8 +53,9 @@ namespace pymodule_register_providers { if (PyErr_Occurred()) { std::string error_msg; - if (!msg_from_py_error(error_msg)) + if (!msg_from_py_error(error_msg)) { error_msg = "Unknown python error"; + } throw std::runtime_error(error_msg.c_str()); } @@ -91,8 +92,9 @@ namespace pymodule_register_algorithms { if (PyErr_Occurred()) { std::string error_msg; - if (!msg_from_py_error(error_msg)) + if (!msg_from_py_error(error_msg)) { error_msg = "Unknown python error"; + } throw std::runtime_error(error_msg.c_str()); } } @@ -104,8 +106,9 @@ static void import_numpy(bool control_interpreter) if (!numpy_imported.exchange(true)) { if (_import_array() < 0) { PyErr_Print(); - if (control_interpreter) + if (control_interpreter) { Py_Finalize(); + } throw std::runtime_error("build with numpy support, but numpy not importable"); } } @@ -167,21 +170,27 @@ static bool initialize() } // try again to see if the interpreter is now initialized - if (!Py_IsInitialized()) + if (!Py_IsInitialized()) { throw std::runtime_error("Python can not be initialized"); + } // LCOV_EXCL_START // add custom types - if (PyType_Ready(&PhlexConfig_Type) < 0) + if (PyType_Ready(&PhlexConfig_Type) < 0) { return false; - if (PyType_Ready(&PhlexModule_Type) < 0) + } + if (PyType_Ready(&PhlexModule_Type) < 0) { return false; - if (PyType_Ready(&PhlexSource_Type) < 0) + } + if (PyType_Ready(&PhlexSource_Type) < 0) { return false; - if (PyType_Ready(&PhlexDataCellIndex_Type) < 0) + } + if (PyType_Ready(&PhlexDataCellIndex_Type) < 0) { return false; - if (PyType_Ready(&PhlexLifeline_Type) < 0) + } + if (PyType_Ready(&PhlexLifeline_Type) < 0) { return false; + } // LCOV_EXCL_STOP // FIXME: Spack does not set PYTHONPATH or VIRTUAL_ENV, but it does set diff --git a/test/form/form_root_schema_read_test.cpp b/test/form/form_root_schema_read_test.cpp index 400d91f09..15c27f58b 100644 --- a/test/form/form_root_schema_read_test.cpp +++ b/test/form/form_root_schema_read_test.cpp @@ -18,8 +18,9 @@ int main(int const argc, char const** argv) auto const& [prods] = read>(technology); std::ofstream outFile("form_root_schema_read_log_" + tech_string + ".txt"); - for (auto const& prod : *prods) + for (auto const& prod : *prods) { outFile << prod << '\n'; + } } catch (std::exception const& e) { std::cerr << "Exception caught in main: " << e.what() << '\n'; return 1; diff --git a/test/form/form_root_schema_write_test.cpp b/test/form/form_root_schema_write_test.cpp index 203b3bef0..6cca0fc8c 100644 --- a/test/form/form_root_schema_write_test.cpp +++ b/test/form/form_root_schema_write_test.cpp @@ -19,8 +19,9 @@ int main(int const argc, char const** argv) std::vector const prods = tracker(); std::ofstream outFile("form_root_schema_write_log_" + tech_string + ".txt"); - for (auto const& prod : prods) + for (auto const& prod : prods) { outFile << prod << '\n'; + } write(technology, prods); diff --git a/test/form/form_storage_test.cpp b/test/form/form_storage_test.cpp index 3082d3450..bb34258e1 100644 --- a/test/form/form_storage_test.cpp +++ b/test/form/form_storage_test.cpp @@ -37,8 +37,9 @@ int main(int const argc, char** const argv) session.cli(cli); int const returnCode = session.applyCommandLine(argc, argv); - if (returnCode != 0) + if (returnCode != 0) { return returnCode; + } technology = form::test::getTechnology(tech_string); diff --git a/test/form/generate_vector.cpp b/test/form/generate_vector.cpp index c7a76dd97..b09e6a8c6 100644 --- a/test/form/generate_vector.cpp +++ b/test/form/generate_vector.cpp @@ -21,8 +21,9 @@ class GaussianGenerator { std::vector operator()([[maybe_unused]] data_cell_index const& idx) { std::vector randoms(m_n_time_ticks); - for (auto& random : randoms) + for (auto& random : randoms) { random = static_cast(m_dist(m_gen)); + } return randoms; } diff --git a/test/form/reader.cpp b/test/form/reader.cpp index a1477963b..dc9da8c7e 100644 --- a/test/form/reader.cpp +++ b/test/form/reader.cpp @@ -119,13 +119,16 @@ int main(int argc, char** argv) static_cast const*>(pb_points.data)); float check = 0.0; - for (float val : *track_start_x) + for (float val : *track_start_x) { check += val; - for (int val : *track_n_hits) + } + for (int val : *track_n_hits) { check += static_cast(val); + } TrackStart checkPoints; - for (TrackStart val : *start_points) + for (TrackStart val : *start_points) { checkPoints += val; + } std::cout << "PHLEX: Segment = " << nseg << ": seg_id_text = " << seg_id_text << ", check = " << check << '\n'; std::cout << "PHLEX: Segment = " << nseg << ": seg_id_text = " << seg_id_text @@ -171,8 +174,9 @@ int main(int argc, char** argv) track_x.reset(static_cast const*>(pb.data)); float check = 0.0; - for (float val : *track_x) + for (float val : *track_x) { check += val; + } std::cout << "PHLEX: Event = " << nevent << ": evt_id_text = " << evt_id_text << ", check = " << check << '\n'; diff --git a/test/form/test_utils.hpp b/test/form/test_utils.hpp index cc0e981d5..8fb92720c 100644 --- a/test/form/test_utils.hpp +++ b/test/form/test_utils.hpp @@ -31,8 +31,9 @@ namespace form::test { { auto branchName = std::string(testTreeName) + "/" + getTypeName(); for (size_t firstSpace = branchName.find_first_of(' '); firstSpace != std::string::npos; - firstSpace = branchName.find_first_of(' ')) + firstSpace = branchName.find_first_of(' ')) { branchName = branchName.erase(firstSpace, 1); + } return branchName; } @@ -88,8 +89,9 @@ namespace form::test { container->setFile(file); void const* rawPtr = nullptr; - if (!container->read(0, &rawPtr, typeid(PROD))) + if (!container->read(0, &rawPtr, typeid(PROD))) { throw std::runtime_error("Failed to read a " + getTypeName()); + } return std::unique_ptr(static_cast(rawPtr)); } diff --git a/test/form/writer.cpp b/test/form/writer.cpp index 8f109102d..1700da089 100644 --- a/test/form/writer.cpp +++ b/test/form/writer.cpp @@ -82,8 +82,9 @@ int main(int argc, char** argv) std::vector track_start_x; generate(track_start_x, 4 * 1024 /* * 1024*/); // sub-event processing float check = 0.0; - for (float val : track_start_x) + for (float val : track_start_x) { check += val; + } std::string const seg_id_text = std::format("[EVENT={:08X};SEG={:08X}]", nevent, nseg); @@ -97,8 +98,9 @@ int main(int argc, char** argv) products.push_back(pb); std::vector track_n_hits(std::from_range, std::views::iota(0, 100)); - for (int val : track_n_hits) + for (int val : track_n_hits) { check += static_cast(val); + } std::cout << "PHLEX: Segment = " << nseg << ": seg_id_text = " << seg_id_text << ", check = " << check << '\n'; @@ -108,8 +110,9 @@ int main(int argc, char** argv) std::vector start_points = tracker(); TrackStart checkPoints; - for (TrackStart const& point : start_points) + for (TrackStart const& point : start_points) { checkPoints += point; + } std::cout << "PHLEX: Segment = " << nseg << ": seg_id_text = " << seg_id_text << ", checkPoints = " << checkPoints << '\n'; @@ -129,8 +132,9 @@ int main(int argc, char** argv) std::cout << "PHLEX: Write Event segments done " << nevent << '\n'; float check = 0.0; - for (float val : track_x) + for (float val : track_x) { check += val; + } std::string const evt_id_text = std::format("[EVENT={:08X}]", nevent); From 01e2d2e1e2e2bec1b0354c096a3a7b3a7e48ccb0 Mon Sep 17 00:00:00 2001 From: Kyle Knoepfel Date: Thu, 23 Jul 2026 11:10:06 -0500 Subject: [PATCH 2/2] docs: record PR #762 for readability-braces-around-statements clang-tidy fixes --- docs/dev/clang-tidy-fixes-2026-04.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/dev/clang-tidy-fixes-2026-04.md b/docs/dev/clang-tidy-fixes-2026-04.md index 6e3d4085d..ec9cb707a 100644 --- a/docs/dev/clang-tidy-fixes-2026-04.md +++ b/docs/dev/clang-tidy-fixes-2026-04.md @@ -146,7 +146,8 @@ - [PR #591](https://github.com/Framework-R-D/phlex/pull/591) - [x] [readability-avoid-const-params-in-decls](https://clang.llvm.org/extra/clang-tidy/checks/readability/avoid-const-params-in-decls.html) (7) - [PR #747](https://github.com/Framework-R-D/phlex/pull/747) -- [ ] [readability-braces-around-statements](https://clang.llvm.org/extra/clang-tidy/checks/readability/braces-around-statements.html) (74) +- [x] [readability-braces-around-statements](https://clang.llvm.org/extra/clang-tidy/checks/readability/braces-around-statements.html) (74) + - [PR #762](https://github.com/Framework-R-D/phlex/pull/762) - [ ] [readability-const-return-type](https://clang.llvm.org/extra/clang-tidy/checks/readability/const-return-type.html) (1) - [ ] [readability-container-contains](https://clang.llvm.org/extra/clang-tidy/checks/readability/container-contains.html) (7) - [x] [readability-container-size-empty](https://clang.llvm.org/extra/clang-tidy/checks/readability/container-size-empty.html) (3)