Skip to content

Enforce Ruby whitespace layout rules - #3719

Merged
kpumuk merged 1 commit into
apache:masterfrom
kpumuk:rb-rubocop-empty-lines
Aug 16, 2026
Merged

Enforce Ruby whitespace layout rules#3719
kpumuk merged 1 commit into
apache:masterfrom
kpumuk:rb-rubocop-empty-lines

Conversation

@kpumuk

@kpumuk kpumuk commented Aug 16, 2026

Copy link
Copy Markdown
Member

This enables RuboCop checks for empty-line placement, rescue and ensure alignment, and spacing before block braces across the Ruby library, tests, and tutorials. Existing sources are autocorrected to match the rules.

The Ruby generator now emits the same empty-line layout for structs, unions, and service classes, including classes without fields or methods, so regenerating code does not reintroduce offenses. Functional generator coverage records the expected output shape.

  • Did you create an Apache Jira ticket? (Request account here, not required for trivial changes)
  • 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.

Client: rb

Co-Authored-By: OpenAI Codex (GPT-5.6) <codex@openai.com>
Copilot AI lite review requested due to automatic review settings August 16, 2026 16:31
@mergeable mergeable Bot added ruby Pull requests that update Ruby code compiler labels Aug 16, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR tightens and enforces Ruby layout/whitespace rules via RuboCop across the Ruby library, specs, tests, and tutorials, and updates the Ruby code generator so regenerated code consistently follows the same layout (preventing new lint offenses).

Changes:

  • Enable additional RuboCop Layout/* cops in lib/rb/.rubocop.yml and autocorrect existing Ruby sources to comply.
  • Adjust the Ruby generator (t_rb_generator) to avoid introducing extra empty lines in generated structs/unions/services (including empty services).
  • Extend Ruby generator functional tests to assert the new generated formatting for services, structs, unions, and multiline literals/metadata.

Reviewed changes

Copilot reviewed 22 out of 25 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tutorial/rb/RubyServer.rb Removes trailing whitespace-only blank lines to satisfy layout rules.
tutorial/rb/RubyClient.rb Removes a whitespace-only blank line before rescue to satisfy layout rules.
test/rb/integration/TestServer.rb Removes a whitespace-only blank line at class boundary.
test/rb/integration/TestClient.rb Removes a whitespace-only blank line before closing end.
test/rb/generation/test_struct.rb Removes whitespace-only blank lines inside the test class.
test/rb/generation/test_recursive.rb Removes an extra blank line at the start of a test body.
test/rb/generation/test_enum.rb Adds an empty line after include to match enforced layout rules.
lib/rb/spec/union_spec.rb Adjusts brace spacing in expect { ... } to match enforced RuboCop layout.
lib/rb/spec/base_transport_spec.rb Adjusts brace spacing in expect { ... } occurrences.
lib/rb/lib/thrift/transport/server_socket.rb Removes trailing whitespace-only blank line at class end.
lib/rb/lib/thrift/transport/io_stream_transport.rb Adds an empty line before to_s to satisfy empty-line placement rules.
lib/rb/lib/thrift/transport/http_client_transport.rb Normalizes empty lines around one-line defs (open?, read, write) and class body.
lib/rb/lib/thrift/struct_union.rb Removes trailing whitespace-only blank line at module/class end.
lib/rb/lib/thrift/server/thin_http_server.rb Removes an extra blank line after class declaration.
lib/rb/lib/thrift/protocol/protocol_decorator.rb Removes an extra blank line after module declaration.
lib/rb/lib/thrift/protocol/multiplexed_protocol.rb Removes an extra blank line after class declaration.
lib/rb/lib/thrift/protocol/json_protocol.rb Removes extra blank lines inside nested class definitions.
lib/rb/lib/thrift/protocol/compact_protocol.rb Removes an extra blank line after class declaration.
lib/rb/lib/thrift/protocol/base_protocol.rb Removes extra blank lines after class declarations.
lib/rb/lib/thrift/multiplexed_processor.rb Removes an extra blank line after nested class declaration.
lib/rb/lib/thrift/exceptions.rb Removes extra blank lines in exception definitions.
lib/rb/ext/extconf.rb Normalizes block brace spacing (`File.open(...) {
lib/rb/.rubocop.yml Enables additional RuboCop Layout/* cops (empty-line placement, alignment, and block-brace spacing).
compiler/cpp/tests/rb/t_rb_generator_functional_tests.cc Updates/extends functional tests to assert generator output formatting for services, structs, unions, and multiline layouts.
compiler/cpp/src/thrift/generate/t_rb_generator.cc Updates the Ruby generator to emit consistent empty-line layout and avoid blank lines before end for empty/last definitions.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@kpumuk
kpumuk merged commit 759b0fa into apache:master Aug 16, 2026
94 of 95 checks passed
@kpumuk
kpumuk deleted the rb-rubocop-empty-lines branch August 16, 2026 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

compiler ruby Pull requests that update Ruby code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants