Skip to content

unused parameters in parsers#545

Closed
KostinPavel wants to merge 6 commits into
getml:mainfrom
KostinPavel:main
Closed

unused parameters in parsers#545
KostinPavel wants to merge 6 commits into
getml:mainfrom
KostinPavel:main

Conversation

@KostinPavel
Copy link
Copy Markdown
Contributor

unused parameters in parsers

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @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

  • Unused Parameter Marking: The _result parameter within a lambda in rfl::OneOf::validate_impl has been explicitly marked as unused to improve code clarity and suppress potential compiler warnings.
  • Schema Generation Cleanup: The _types parameter in rfl::parsing::FieldVariantParser::to_schema was marked as unused, indicating its intentional non-use in the schema generation logic.
  • Parser Definition Cleanup: The _definitions parameter in rfl::parsing::Parser_bytestring::to_schema and rfl::parsing::Parser_vectorstring::to_schema methods has been marked as unused, clarifying that these specific parsers do not require the definitions map for schema generation.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 = {}*/) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

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 = {}) {

Comment thread include/rfl/OneOf.hpp
std::vector<Error> _errors) {
return Head::validate(_value)
.and_then([&](auto&& _result) -> rfl::Result<T> {
.and_then([&](auto&& /*_result*/) -> rfl::Result<T> {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
.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*/) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

While using /*_definitions*/ 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.

      std::map<std::string, schema::Type>* [[maybe_unused]] _definitions) {


static schema::Type to_schema(
std::map<std::string, schema::Type>* _definitions) {
std::map<std::string, schema::Type>* /*_definitions*/) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

While using /*_definitions*/ 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.

      std::map<std::string, schema::Type>* [[maybe_unused]] _definitions) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant