Repository navigation
Cleanup includes - #519
Cleanup includes#519
Conversation
KostinPavel
commented
Oct 12, 2025
- try 3
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…ast.hpp и неиспользуемые include из Result.hpp - Удален #include <bit> из include/rfl/internal/ptr_cast.hpp (не используется в коде) - Удалены неиспользуемые include из include/rfl/Result.hpp: - #include <algorithm> (не используется) - #include <iostream> (не используется) - #include <optional> (не используется)
Этап 2: Базовые типы (средний риск) Удалены неиспользуемые include из файла Tuple.hpp: - <algorithm> - не используется в коде - <bit> - не используется в коде - <cstdint> - не используется в коде - <limits> - не используется в коде - <memory> - не используется в коде - <optional> - не используется в коде Оставлены только необходимые заголовки: - <array> - используется для std::array - <tuple> - используется для std::tuple - <type_traits> - используется для различных type traits - <utility> - используется для std::integer_sequence и других утилит Все остальные файлы (Literal.hpp, Field.hpp, Object.hpp, Variant.hpp) уже имели оптимальный набор include файлов без неиспользуемых зависимостей. Компиляция проекта проверена и проходит успешно.
…вки <string>, <version>, упрощен оператор сравнения spaceship
unused arguments shaded variables
impl 1
correct1
Summary of ChangesHello @KostinPavel, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request focuses on a significant cleanup and refinement of the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request is a significant cleanup and refactoring effort. It successfully removes a large number of unused includes across the codebase, which is great for build times and code hygiene. The error handling in the Avro backend has been substantially improved by adding checks for avro_* function return values and throwing exceptions on failure. Additionally, the code has been modernized by using explicit std::hash, brace initialization for members, and simplifying operator<=> to rely on C++20 features.
I've added a few comments on potential improvements, mainly concerning error handling consistency and a potential overflow bug in the Cap'n Proto writer. Overall, this is an excellent pull request that improves code quality and robustness.
| OutputUnionType* _parent) const { | ||
| avro_value_t new_array; | ||
| avro_value_set_branch(&_parent->val_, static_cast<int>(_index), &new_array); | ||
| int result = avro_value_set_branch(&_parent->val_, static_cast<int>(_index), &new_array); |
There was a problem hiding this comment.
The _index parameter is a size_t, but it's cast to an int for avro_value_set_branch. This can lead to an integer overflow if _index is larger than INT_MAX. A check should be added to prevent this, similar to the one in add_value_to_union in Writer.hpp. This issue also applies to add_map_to_union, add_object_to_union, add_union_to_union, and add_null_to_union in this file.
For example:
if (_index > static_cast<size_t>(INT_MAX)) {
throw std::runtime_error(std::string(__FUNCTION__) + " index error");
}| inline unsigned int SafeSizeToUInt(size_t sizeValue) { | ||
| if (sizeValue > static_cast<size_t>(std::numeric_limits<unsigned int>::max())) { | ||
| throw std::overflow_error("size_t value is too big to fit into an unsigned int."); | ||
| } | ||
| return static_cast<unsigned int>(sizeValue); | ||
| } |
There was a problem hiding this comment.
This is a great utility function for safe conversions. However, it's defined as inline within a .cpp file, limiting its scope to this translation unit. The template methods in include/rfl/capnproto/Writer.hpp (e.g., add_value_to_array) also perform size_t to unsigned int conversions implicitly when calling capnp methods, and they could benefit from this check to prevent potential overflows. Consider moving SafeSizeToUInt to a shared internal header and applying it in the template methods within Writer.hpp as well.
| int result_value = 0; | ||
| int result = avro_value_get_boolean(_var.val_, &result_value); | ||
| if (result != 0) { | ||
| return error(std::string(__FUNCTION__) + " error("+ std::to_string(result)+"): " + avro_strerror()); |
There was a problem hiding this comment.
Constructing error messages using + on std::string can lead to multiple memory allocations, which can be inefficient. Consider using std::stringstream to build the error string more efficiently. This pattern is repeated in this file and others (like avro/Writer.hpp).
For example:
std::stringstream ss;
ss << __FUNCTION__ << " error(" << result << "): " << avro_strerror();
return error(ss.str());avro_value_set_double avro_value_set_long bug?
|
Please let us know what else is needed to merge the branches? |
|
@KostinPavel , nothing. I will merge right now. Thank you so much for your effort! |
…arnings/linters Isolate reflect-cpp from consumer warning/linter policies while keeping top-level CI warning coverage intact (building on #113 / 4861aaf): - Split target_include_directories(reflectcpp ...) into non-SYSTEM PRIVATE includes for compiling reflectcpp itself and ${_REFLECTCPP_INCLUDE_SYSTEM} INTERFACE includes for consumers, where _REFLECTCPP_INCLUDE_SYSTEM is SYSTEM only when NOT _REFLECTCPP_IS_TOP_LEVEL and NOT REFLECTCPP_STRICT_WARNINGS. Top-level builds and REFLECTCPP_STRICT_WARNINGS=ON keep non-SYSTEM interface includes so CI still catches warnings inside include/rfl/. (On CMake >= 3.23, FILE_SET reflectcpp_headers preserves SYSTEM because INTERFACE_SYSTEM_INCLUDE_DIRECTORIES already contains the same include directory.) - Mark bundled thirdparty include directory SYSTEM PUBLIC, remove the duplicate thirdparty target_include_directories() call, and silence warnings on vendored src/yyjson.c with -w / /w. - Mark transitive pugixml include directories SYSTEM (and YAS private includes SYSTEM). - When embedded as a subproject, clear CXX_CLANG_TIDY / C_CLANG_TIDY, CXX_CPPCHECK / C_CPPCHECK, and CXX_INCLUDE_WHAT_YOU_USE / C_INCLUDE_WHAT_YOU_USE on reflectcpp, and (unless REFLECTCPP_STRICT_WARNINGS=ON) disable COMPILE_WARNING_AS_ERROR (CMake >= 3.24) and add PRIVATE -Wno-error -w (GNU/Clang/AppleClang) or /WX- /w (MSVC) so strict parent flags (-Weverything, -Wconversion, -Wold-style-cast, -Werror) neither fail nor spam reflectcpp's own sources while keeping all warnings active on top-level builds and REFLECTCPP_STRICT_WARNINGS=ON. - Remove the redundant target_compile_options(reflectcpp PRIVATE $<$<CONFIG:Release>:-DNDEBUG>) block left over from munich-data-engineering#519 (CMake's CMAKE_CXX_FLAGS_RELEASE already defines -DNDEBUG / /DNDEBUG on Release builds, and injecting -DNDEBUG unconditionally via compile options duplicated the flag and overrode custom parent Release flags). - Initialize .values = {} / .fields = {} in src/rfl/env/Writer.cpp to eliminate -Wmissing-field-initializers / -Wmissing-designated-field-initializers warnings in compiled sources on Clang and GCC. Addresses #140.
…arnings/linters Isolate reflect-cpp from consumer warning/linter policies while keeping top-level CI warning coverage intact (building on #113 / 4861aaf): - Split target_include_directories(reflectcpp ...) into non-SYSTEM PRIVATE includes for compiling reflectcpp itself and ${_REFLECTCPP_INCLUDE_SYSTEM} INTERFACE includes for consumers, where _REFLECTCPP_INCLUDE_SYSTEM is SYSTEM only when NOT _REFLECTCPP_IS_TOP_LEVEL and NOT REFLECTCPP_STRICT_WARNINGS. Top-level builds and REFLECTCPP_STRICT_WARNINGS=ON keep non-SYSTEM interface includes so CI still catches warnings inside include/rfl/. (On CMake >= 3.23, FILE_SET reflectcpp_headers preserves SYSTEM because INTERFACE_SYSTEM_INCLUDE_DIRECTORIES already contains the same include directory.) - Mark bundled thirdparty include directory SYSTEM PUBLIC, remove the duplicate thirdparty target_include_directories() call, and silence warnings on vendored src/yyjson.c with -w / /w. - Mark transitive pugixml include directories SYSTEM (and YAS private includes SYSTEM). - When embedded as a subproject, clear CXX_CLANG_TIDY / C_CLANG_TIDY, CXX_CPPCHECK / C_CPPCHECK, and CXX_INCLUDE_WHAT_YOU_USE / C_INCLUDE_WHAT_YOU_USE on reflectcpp, and (unless REFLECTCPP_STRICT_WARNINGS=ON) disable COMPILE_WARNING_AS_ERROR (CMake >= 3.24) and add PRIVATE -Wno-error -w (GNU/Clang/AppleClang) or /WX- /w (MSVC) so strict parent flags (-Weverything, -Wconversion, -Wold-style-cast, -Werror) neither fail nor spam reflectcpp's own sources while keeping all warnings active on top-level builds and REFLECTCPP_STRICT_WARNINGS=ON. - Remove the redundant target_compile_options(reflectcpp PRIVATE $<$<CONFIG:Release>:-DNDEBUG>) block left over from munich-data-engineering#519 (CMake's CMAKE_CXX_FLAGS_RELEASE already defines -DNDEBUG / /DNDEBUG on Release builds, and injecting -DNDEBUG unconditionally via compile options duplicated the flag and overrode custom parent Release flags). - Initialize .values = {} / .fields = {} in src/rfl/env/Writer.cpp to eliminate -Wmissing-field-initializers / -Wmissing-designated-field-initializers warnings in compiled sources on Clang and GCC. Addresses #140.
…arnings/linters Isolate reflect-cpp from consumer warning/linter policies while keeping top-level CI warning coverage intact (building on #113 / 4861aaf): - Split target_include_directories(reflectcpp ...) into non-SYSTEM PRIVATE includes for compiling reflectcpp itself and ${_REFLECTCPP_INCLUDE_SYSTEM} INTERFACE includes for consumers, where _REFLECTCPP_INCLUDE_SYSTEM is SYSTEM only when NOT _REFLECTCPP_IS_TOP_LEVEL and NOT REFLECTCPP_STRICT_WARNINGS. Top-level builds and REFLECTCPP_STRICT_WARNINGS=ON keep non-SYSTEM interface includes so CI still catches warnings inside include/rfl/. (On CMake >= 3.23, FILE_SET reflectcpp_headers preserves SYSTEM because INTERFACE_SYSTEM_INCLUDE_DIRECTORIES already contains the same include directory.) - Mark bundled thirdparty include directory SYSTEM PUBLIC, remove the duplicate thirdparty target_include_directories() call, and silence warnings on vendored src/yyjson.c with -w (GNU/Clang) or /W0 (MSVC / clang-cl, which maps to MSBuild <WarningLevel>TurnOffAllWarnings</WarningLevel> instead of emitting D9025 overrides from /w in <AdditionalOptions>). - Mark transitive pugixml include directories SYSTEM (and YAS private includes SYSTEM). - When embedded as a subproject, clear CXX_CLANG_TIDY / C_CLANG_TIDY, CXX_CPPCHECK / C_CPPCHECK, and CXX_INCLUDE_WHAT_YOU_USE / C_INCLUDE_WHAT_YOU_USE on reflectcpp, and (unless REFLECTCPP_STRICT_WARNINGS=ON) disable COMPILE_WARNING_AS_ERROR (CMake >= 3.24) and add PRIVATE -Wno-error -w (GNU/Clang/AppleClang) or /W0 (MSVC / clang-cl). On MSVC, strip inherited /W[0-4], /Wall, /w, /WX, /WX- (plus GCC/Clang -W* / -w flags on clang-cl) from local CMAKE_{CXX,C}_FLAGS* and directory COMPILE_OPTIONS before add_library(reflectcpp ...) snapshots directory options, preventing D9025 override spam in both VS MSBuild and Ninja MSVC without mutating parent scope or corrupting /wd*, /WIN32, /bigobj, or -Wl,... flags. - Replace -Wall with /W4 on MSVC / clang-cl under REFLECTCPP_STRICT_WARNINGS (stripping inherited /W[0-4], /Wall, /w first to prevent /W3 -> /W4 D9025 warnings) so strict warnings no longer expand to MSVC /Wall or clang-cl -Weverything. - Remove the redundant target_compile_options(reflectcpp PRIVATE $<$<CONFIG:Release>:-DNDEBUG>) block left over from munich-data-engineering#519 (CMake's CMAKE_CXX_FLAGS_RELEASE already defines -DNDEBUG / /DNDEBUG on Release builds, and injecting -DNDEBUG unconditionally via compile options duplicated the flag and overrode custom parent Release flags). - Fix compiled-source warnings under strict Clang/GCC and MSVC /W4: - Initialize .values = {} / .fields = {} in src/rfl/env/Writer.cpp (-Wmissing-field-initializers). - Explicitly declare and out-of-line default copy/move special members on rfl::parsing::schema::Type (MSVC C5267 / -Wdeprecated-copy-dtor). - Rename structured-binding locals in src/rfl/json/to_schema.cpp so default_value no longer hides rfl::default_value (MSVC C4459), and move trailing return t into explicit else branches of if constexpr in handle_size_variant (MSVC C4702). Addresses #140.
…arnings/linters Isolate reflect-cpp from consumer warning/linter policies while keeping top-level CI warning coverage intact (building on #113 / 4861aaf): - Split target_include_directories(reflectcpp ...) into non-SYSTEM PRIVATE includes for compiling reflectcpp itself and ${_REFLECTCPP_INCLUDE_SYSTEM} INTERFACE includes for consumers, where _REFLECTCPP_INCLUDE_SYSTEM is SYSTEM only when NOT _REFLECTCPP_IS_TOP_LEVEL and NOT REFLECTCPP_STRICT_WARNINGS. Top-level builds and REFLECTCPP_STRICT_WARNINGS=ON keep non-SYSTEM interface includes so CI still catches warnings inside include/rfl/. (On CMake >= 3.23, FILE_SET reflectcpp_headers preserves SYSTEM because INTERFACE_SYSTEM_INCLUDE_DIRECTORIES already contains the same include directory.) - Mark bundled thirdparty include directory SYSTEM PUBLIC, remove the duplicate thirdparty target_include_directories() call, and silence warnings on vendored src/yyjson.c with -w (GNU/Clang) or /W0 (MSVC / clang-cl, which maps to MSBuild <WarningLevel>TurnOffAllWarnings</WarningLevel> instead of emitting D9025 overrides from /w in <AdditionalOptions>). - Mark transitive pugixml include directories SYSTEM (and YAS private includes SYSTEM). - When embedded as a subproject, clear CXX_CLANG_TIDY / C_CLANG_TIDY, CXX_CPPCHECK / C_CPPCHECK, and CXX_INCLUDE_WHAT_YOU_USE / C_INCLUDE_WHAT_YOU_USE on reflectcpp, and (unless REFLECTCPP_STRICT_WARNINGS=ON) disable COMPILE_WARNING_AS_ERROR (CMake >= 3.24) and add PRIVATE -Wno-error -w (GNU/Clang/AppleClang) or /W0 (MSVC / clang-cl). On MSVC, strip inherited /W[0-4], /Wall, /w, /WX, /WX- (plus GCC/Clang -W* / -w flags on clang-cl) from local CMAKE_{CXX,C}_FLAGS* and directory COMPILE_OPTIONS before add_library(reflectcpp ...) snapshots directory options, preventing D9025 override spam in both VS MSBuild and Ninja MSVC without mutating parent scope or corrupting /wd*, /WIN32, /bigobj, or -Wl,... flags. - Replace -Wall with /W4 on MSVC / clang-cl under REFLECTCPP_STRICT_WARNINGS (stripping inherited /W[0-4], /Wall, /w first to prevent /W3 -> /W4 D9025 warnings) so strict warnings no longer expand to MSVC /Wall or clang-cl -Weverything. - Remove the redundant target_compile_options(reflectcpp PRIVATE $<$<CONFIG:Release>:-DNDEBUG>) block left over from munich-data-engineering#519 (CMake's CMAKE_CXX_FLAGS_RELEASE already defines -DNDEBUG / /DNDEBUG on Release builds, and injecting -DNDEBUG unconditionally via compile options duplicated the flag and overrode custom parent Release flags). - Fix compiled-source warnings under strict Clang/GCC and MSVC /W4: - Initialize .values = {} / .fields = {} in src/rfl/env/Writer.cpp (-Wmissing-field-initializers). - Explicitly declare and out-of-line default copy/move special members on rfl::parsing::schema::Type (MSVC C5267 / -Wdeprecated-copy-dtor). - Rename structured-binding locals in src/rfl/json/to_schema.cpp so default_value no longer hides rfl::default_value (MSVC C4459), and move trailing return t into explicit else branches of if constexpr in handle_size_variant (MSVC C4702). Addresses #140.