Skip to content

THRIFT-5940: Make generated Ruby code RuboCop compliant#3388

Open
kpumuk wants to merge 1 commit intoapache:masterfrom
kpumuk:rb-gen-rubocop
Open

THRIFT-5940: Make generated Ruby code RuboCop compliant#3388
kpumuk wants to merge 1 commit intoapache:masterfrom
kpumuk:rb-gen-rubocop

Conversation

@kpumuk
Copy link
Copy Markdown
Member

@kpumuk kpumuk commented Apr 9, 2026

This change addresses Rubocop offenses in the generated code, mostly spacing:

  • extra blank lines around top-level generated blocks
  • message=nil instead of message = nil
  • trailing whitespace in generated service inheritance lines
  • enum constant rendering with incorrect indentation
  • blank RDoc lines emitted as # (trailing whitespace) instead of #

Additionally, we generate all Thrift files for Ruby so that SCA job actually ensures they are compliant.

  • Did you create an Apache Jira ticket? THRIFT-5940
  • If a ticket exists: Does your pull request title follow the pattern "THRIFT-NNNN: describe my issue"?
  • Did you squash your changes to a single commit? (not required, but preferred)
  • Did you do your best to avoid breaking changes? If one was needed, did you label the Jira ticket with "Breaking-Change"?
  • If your change does not involve any code, include [skip ci] anywhere in the commit message to free up build resources.

@mergeable mergeable bot added compiler github_actions Pull requests that update GitHub Actions code labels Apr 9, 2026
Copy link
Copy Markdown
Member

@Jens-G Jens-G left a comment

Choose a reason for hiding this comment

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

Not a blocker, so +1

stringstream docs(tdoc->get_doc(), std::ios_base::in);
string line;
while (std::getline(docs, line)) {
out.indent() << "#";
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

std::getline() only strips \n, so a CRLF-terminated blank line leaves line == "\r" -> line.empty() is false -> output becomes # \r —> reintroducing trailing whitespace.

Reference: https://en.cppreference.com/w/cpp/string/basic_string/getline

See also:

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Oh wow, it has been a while since I touched C++. Thank you!

I am thinking about enabling Ruby compiler on compiler tests and starting adding those (currently only C++, .NET and Ocaml are there).

Client: rb

Co-Authored-By: OpenAI Codex (GPT-5.4) <codex@openai.com>
@mergeable mergeable bot added the build and general CI cmake, automake and build system changes label Apr 14, 2026
REQUIRE(generated_content.find("\r") == string::npos);
REQUIRE(generated_content.find("# * first line\n") != string::npos);
REQUIRE(generated_content.find("# *\n") != string::npos);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I just noticed we may not have a CI step yet that runs these tests.

REQUIRE(generated_content.find("# *\n") != string::npos);

std::remove(thrift_path.c_str());
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The generated gen-rbstuff is not cleaned up.

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

Labels

build and general CI cmake, automake and build system changes compiler github_actions Pull requests that update GitHub Actions code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants