unused parameters in parsers#545
Conversation
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 code hygiene by explicitly marking several parameters as unused across various parser implementations. This practice improves code clarity, prevents potential compiler warnings about unused variables, and communicates the intentional non-use of these parameters to future developers, ensuring a cleaner and more maintainable codebase. 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 addresses unused parameters across several files. The intent is good, but one of the changes in FieldVariantParser.hpp introduces a critical breaking change by altering a function's signature. The other changes are functional but could be improved for clarity and maintainability by using the C++17 [[maybe_unused]] attribute instead of C-style comments to mark parameters as unused. My review includes suggestions to fix the critical issue and to consistently apply the modern C++ approach for handling unused parameters.
| static schema::Type to_schema( | ||
| std::map<std::string, schema::Type>* _definitions, | ||
| std::vector<schema::Type> _types = {}) { | ||
| std::vector<schema::Type> /*_types = {}*/) { |
There was a problem hiding this comment.
This change is problematic. By commenting out _types = {}, you have removed the default argument for this parameter. This is a breaking change for any code that calls this function with only one argument. If the parameter is unused but needs to be kept for API compatibility, please use the [[maybe_unused]] attribute to mark it as such while preserving the function signature, including the default argument.
std::vector<schema::Type> [[maybe_unused]] _types = {}) {| std::vector<Error> _errors) { | ||
| return Head::validate(_value) | ||
| .and_then([&](auto&& _result) -> rfl::Result<T> { | ||
| .and_then([&](auto&& /*_result*/) -> rfl::Result<T> { |
There was a problem hiding this comment.
While using /*_result*/ to mark a parameter as unused works, using the [[maybe_unused]] attribute is a more modern and clearer way to express this intent in C++17 and later. It makes the code more self-documenting.
| .and_then([&](auto&& /*_result*/) -> rfl::Result<T> { | |
| .and_then([&]([[maybe_unused]] auto&& _result) -> rfl::Result<T> { |
|
|
||
| static schema::Type to_schema( | ||
| std::map<std::string, schema::Type>* _definitions) { | ||
| std::map<std::string, schema::Type>* /*_definitions*/) { |
There was a problem hiding this comment.
|
|
||
| static schema::Type to_schema( | ||
| std::map<std::string, schema::Type>* _definitions) { | ||
| std::map<std::string, schema::Type>* /*_definitions*/) { |
There was a problem hiding this comment.
unused parameters in parsers