Skip to content

Enforce modern Ruby hash syntax - #3716

Open
kpumuk wants to merge 1 commit into
apache:masterfrom
kpumuk:rb-rubocop-hash-syntax
Open

Enforce modern Ruby hash syntax#3716
kpumuk wants to merge 1 commit into
apache:masterfrom
kpumuk:rb-rubocop-hash-syntax

Conversation

@kpumuk

@kpumuk kpumuk commented Aug 14, 2026

Copy link
Copy Markdown
Member

Ruby sources currently use a mixture of hash rockets and label syntax for symbol keys. This enables Style/HashSyntax and normalizes symbol-keyed hashes across the Ruby library and tests while continuing to allow either form of value shorthand.

The Ruby compiler now emits label syntax for generated field metadata and service arguments. Hash rockets remain in generated output where keys are dynamic or non-symbol values.

  • 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.

Copilot AI lite review requested due to automatic review settings August 14, 2026 22:01
@mergeable mergeable Bot added ruby Pull requests that update Ruby code compiler labels Aug 14, 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 standardizes Ruby code to modern symbol-key hash label syntax (e.g., foo: 1) across the Ruby library, Ruby specs/tests, and the Ruby code generator, and enables RuboCop’s Style/HashSyntax to enforce it consistently.

Changes:

  • Normalize symbol-keyed hashes in Ruby specs, integration tests, fixtures, and benchmark code.
  • Enable Style/HashSyntax in lib/rb/.rubocop.yml (with shorthand syntax set to either).
  • Update the Ruby compiler generator to emit label syntax for generated field metadata and service client argument hashes.

Reviewed changes

Copilot reviewed 29 out of 29 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
test/rb/integration/TestServer.rb Converts exception/option hashes to label syntax.
test/rb/integration/TestClient.rb Converts expected-struct hashes to label syntax.
test/rb/generation/test_struct.rb Converts struct init argument hash syntax.
test/rb/fixtures/structs.rb Converts FIELDS metadata hashes to label syntax.
lib/rb/spec/unix_socket_spec.rb Converts RSpec double option hashes to label syntax.
lib/rb/spec/union_spec.rb Converts struct/union constructor hashes to label syntax.
lib/rb/spec/types_spec.rb Converts type descriptor hashes to label syntax.
lib/rb/spec/thin_http_server_spec.rb Converts options hashes passed to ThinHTTPServer to label syntax.
lib/rb/spec/struct_spec.rb Converts struct constructor hashes to label syntax.
lib/rb/spec/ssl_socket_spec.rb Converts RSpec double option hashes to label syntax.
lib/rb/spec/socket_spec.rb Converts RSpec double option hashes to label syntax.
lib/rb/spec/server_socket_spec.rb Converts RSpec double option hashes to label syntax.
lib/rb/spec/serializer_spec.rb Converts struct constructor hashes to label syntax.
lib/rb/spec/recursion_depth_spec.rb Converts type descriptor hashes to label syntax.
lib/rb/spec/processor_spec.rb Converts generated-args constructor hashes to label syntax.
lib/rb/spec/nonblocking_server_spec.rb Converts struct/double option hashes to label syntax.
lib/rb/spec/http_client_spec.rb Converts HTTP client option hashes to label syntax.
lib/rb/spec/compact_protocol_spec.rb Converts test data hashes to label syntax.
lib/rb/spec/client_spec.rb Converts mock/double and message-args hashes to label syntax.
lib/rb/spec/binary_protocol_spec_shared.rb Converts method-to-bytes mapping hashes to label syntax.
lib/rb/spec/base_transport_spec.rb Converts IO double option hashes to label syntax.
lib/rb/spec/base_protocol_spec.rb Converts protocol field/type hashes to label syntax.
lib/rb/Rakefile Converts Rake task dependency hashes to label syntax.
lib/rb/lib/thrift/struct_union.rb Converts internal field-info hash construction to label syntax.
lib/rb/lib/thrift/protocol/base_protocol.rb Converts internal field_info hash construction to label syntax.
lib/rb/benchmark/benchmark.rb Converts ANSI code hash to label syntax.
lib/rb/.rubocop.yml Enables Style/HashSyntax for the Ruby subproject.
compiler/cpp/tests/rb/t_rb_generator_functional_tests.cc Updates generator output expectations for label syntax.
compiler/cpp/src/thrift/generate/t_rb_generator.cc Updates generator to output label syntax for metadata and service args.

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

Comment thread lib/rb/spec/client_spec.rb
Comment thread compiler/cpp/src/thrift/generate/t_rb_generator.cc
Comment thread lib/rb/spec/struct_spec.rb
Comment thread lib/rb/spec/thin_http_server_spec.rb Outdated
Comment thread lib/rb/spec/http_client_spec.rb Outdated
Comment thread test/rb/generation/test_struct.rb
Copilot AI review requested due to automatic review settings August 14, 2026 23:46
@kpumuk
kpumuk force-pushed the rb-rubocop-hash-syntax branch from 83de4c3 to 245dda5 Compare August 14, 2026 23:46

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

Copilot reviewed 29 out of 29 changed files in this pull request and generated 7 comments.

Suppressed comments (7)

lib/rb/spec/union_spec.rb:214

  • Thrift::Union#initialize does not accept keyword arguments, so calls like My_union.new(integer32: 26) / My_union.new(some_enum: ...) / TestUnion.new(binary_field: ...) will fail on Ruby 3. Wrap these in an explicit hash to ensure a positional Hash is passed.
    it "should support old style constructor" do
      union = SpecNamespace::My_union.new(integer32: 26)
      expect(union.get_set_field).to eq(:integer32)
      expect(union.get_value).to eq(26)
    end

    it "should not throw an error when inspected and unset" do
      expect{ SpecNamespace::TestUnion.new().inspect }.not_to raise_error
    end

    it "should print enum value name when inspected" do
      expect(SpecNamespace::My_union.new(some_enum: SpecNamespace::SomeEnum::ONE).inspect).to eq("<SpecNamespace::My_union some_enum: ONE (0)>")

      expect(SpecNamespace::My_union.new(my_map: {SpecNamespace::SomeEnum::ONE => [SpecNamespace::SomeEnum::TWO]}).inspect).to eq("<SpecNamespace::My_union my_map: {ONE (0): [TWO (1)]}>")
    end

    it "should offer field? methods" do
      expect(SpecNamespace::My_union.new.some_enum?).to be_falsey
      expect(SpecNamespace::My_union.new(some_enum: SpecNamespace::SomeEnum::ONE).some_enum?).to be_truthy
      expect(SpecNamespace::My_union.new(im_true: false).im_true?).to be_truthy
      expect(SpecNamespace::My_union.new(im_true: true).im_true?).to be_truthy
    end

    it "should pretty print binary fields" do
      expect(SpecNamespace::TestUnion.new(binary_field: "\001\002\003").inspect).to eq("<SpecNamespace::TestUnion binary_field: 010203>")

lib/rb/spec/struct_spec.rb:182

  • SpecNamespace::Hello is a Thrift::Struct (positional-hash initializer). Hello.new(greeting: ...) will be treated as keyword args on Ruby 3 and raise unless wrapped in an explicit hash.
      expect(struct.simple).to eq(42)
      expect(struct.complex).to eq({1 => {"pi" => Math::PI, "e" => Math::E}, 14 => {"feigenbaum" => 4.669201609}})
      expect(struct.hello).to eq(SpecNamespace::Hello.new(greeting: "what's up?"))
      expect(struct.words).to eq("apple banana")

lib/rb/spec/struct_spec.rb:237

  • BoolStruct.new(yesno: false) passes Ruby keywords; Thrift::Struct#initialize expects a positional hash. This will raise on Ruby 3 unless wrapped in {}.
    it "should serialize false boolean fields correctly" do
      b = SpecNamespace::BoolStruct.new(yesno: false)
      prot = Thrift::BinaryProtocol.new(Thrift::MemoryBufferTransport.new)

lib/rb/spec/struct_spec.rb:269

  • SpecNamespace::Hello.new(greeting: ...) is passing Ruby keyword args; Thrift::Struct#initialize expects a positional hash and will raise on Ruby 3. Use an explicit hash argument.
      expect(struct.simple).to eq(42)
      expect(struct.complex).to be_nil
      expect(struct.words).to eq("foobar")
      expect(struct.hello).to eq(SpecNamespace::Hello.new(greeting: "hello, world!"))
      expect(struct.ints).to eq([1, 2, 2, 3])

lib/rb/spec/struct_spec.rb:330

  • These SpecNamespace::Hello.new(...) calls are passing Ruby keyword arguments (greeting: / fish:). Thrift::Struct#initialize only accepts a positional hash (def initialize(d = {})), so these raise on Ruby 3 unless the hash is explicit.
    it "should support optional type-checking in Thrift::Struct.new" do
      Thrift.type_checking = true
      begin
        expect { SpecNamespace::Hello.new(greeting: 3) }.to raise_error(Thrift::TypeError, "Expected Types::STRING, received Integer for field greeting")
      ensure

lib/rb/spec/serializer_spec.rb:145

  • SpecNamespace::Hello is a Thrift::Struct with initialize(d = {}), so Hello.new(greeting: ...) here will be parsed as keyword args on Ruby 3 and raise. Use an explicit hash argument for all Thrift struct instantiations in this file.

This issue also appears on line 249 of the same file.

      data = serializer.serialize(SpecNamespace::Hello.new(greeting: "'Ello guv'nor!"))
      expect(data).to eq("\x0B\x00\x01\x00\x00\x00\x0E'Ello guv'nor!\x00")
    end

    it "should serialize structs to the given protocol" do

lib/rb/spec/serializer_spec.rb:254

  • These expectations construct SpecNamespace::Hello via Ruby keyword arguments. Since Thrift::Struct#initialize only accepts a positional hash, Hello.new(greeting: ...) will raise on Ruby 3 unless you pass an explicit hash.
  describe Thrift::Deserializer do
    it "should deserialize structs from binary by default" do
      deserializer = Thrift::Deserializer.new
      data = "\x0B\x00\x01\x00\x00\x00\x0E'Ello guv'nor!\x00"
      expect(deserializer.deserialize(SpecNamespace::Hello.new, data)).to eq(SpecNamespace::Hello.new(greeting: "'Ello guv'nor!"))
    end

Comment thread test/rb/generation/test_struct.rb
Comment thread lib/rb/spec/union_spec.rb
Comment thread lib/rb/spec/struct_spec.rb
Comment thread lib/rb/spec/struct_spec.rb
Comment thread lib/rb/spec/struct_spec.rb
Comment thread lib/rb/spec/serializer_spec.rb
Comment thread lib/rb/spec/nonblocking_server_spec.rb
Client: rb

Co-Authored-By: OpenAI Codex (GPT-5.6) <codex@openai.com>
Copilot AI review requested due to automatic review settings August 15, 2026 00:21
@kpumuk
kpumuk force-pushed the rb-rubocop-hash-syntax branch from 245dda5 to 16239d6 Compare August 15, 2026 00:21

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

Copilot reviewed 29 out of 29 changed files in this pull request and generated 7 comments.

Suppressed comments (31)

lib/rb/spec/union_spec.rb:175

  • SpecNamespace::Struct_with_union is a Thrift::Struct and expects a positional hash to initialize(d = {}). Passing fun_union: as keywords will fail on Ruby 3+. Pass an explicit hash instead.
      swu = SpecNamespace::Struct_with_union.new(fun_union: union)

lib/rb/spec/union_spec.rb:215

  • Thrift::Union#initialize does not accept keyword args in Ruby 3+. Pass a positional hash for binary_field.
    it "should pretty print binary fields" do
      expect(SpecNamespace::TestUnion.new(binary_field: "\001\002\003").inspect).to eq("<SpecNamespace::TestUnion binary_field: 010203>")
    end

lib/rb/spec/union_spec.rb:204

  • Thrift::Union#initialize does not accept keyword args in Ruby 3+. These My_union.new(...) calls should pass a positional hash to preserve compatibility.
    it "should print enum value name when inspected" do
      expect(SpecNamespace::My_union.new(some_enum: SpecNamespace::SomeEnum::ONE).inspect).to eq("<SpecNamespace::My_union some_enum: ONE (0)>")

      expect(SpecNamespace::My_union.new(my_map: {SpecNamespace::SomeEnum::ONE => [SpecNamespace::SomeEnum::TWO]}).inspect).to eq("<SpecNamespace::My_union my_map: {ONE (0): [TWO (1)]}>")
    end

lib/rb/spec/union_spec.rb:211

  • Thrift::Union#initialize does not accept keyword args in Ruby 3+. These My_union.new(...) calls should pass a positional hash to preserve compatibility.
    it "should offer field? methods" do
      expect(SpecNamespace::My_union.new.some_enum?).to be_falsey
      expect(SpecNamespace::My_union.new(some_enum: SpecNamespace::SomeEnum::ONE).some_enum?).to be_truthy
      expect(SpecNamespace::My_union.new(im_true: false).im_true?).to be_truthy
      expect(SpecNamespace::My_union.new(im_true: true).im_true?).to be_truthy
    end

lib/rb/spec/union_spec.rb:183

  • SpecNamespace::Struct_with_union is a Thrift::Struct and expects a positional hash to initialize(d = {}). Passing fun_union: as keywords will fail on Ruby 3+. Pass an explicit hash instead.
      other_union = SpecNamespace::My_union.new(:some_characters, "hello there")
      swu2 = SpecNamespace::Struct_with_union.new(fun_union: other_union)

lib/rb/spec/struct_spec.rb:72

  • SpecNamespace::Hello is a Thrift::Struct whose initializer is initialize(d = {}). Calling .new(greeting: ...) passes keyword args and will raise on Ruby 3+. Pass a positional hash instead.
    def validate_default_arguments(object)
      expect(object.simple).to eq(53)
      expect(object.words).to eq("words")
      expect(object.hello).to eq(SpecNamespace::Hello.new(greeting: "hello, world!"))
      expect(object.ints).to eq([1, 2, 2, 3])

lib/rb/spec/struct_spec.rb:91

  • SpecNamespace::BoolStruct is a Thrift::Struct and its initializer takes a positional hash. BoolStruct.new(yesno: false) uses keyword args and will fail on Ruby 3+.
    it "should properly initialize boolean values" do
      struct = SpecNamespace::BoolStruct.new(yesno: false)
      expect(struct.yesno).to be_falsey
    end

lib/rb/spec/struct_spec.rb:97

  • SpecNamespace::Foo is a Thrift::Struct and expects a positional hash to initialize. Foo.new(simple: 52) uses keyword args and will fail on Ruby 3+.
    it "should have proper == semantics" do
      expect(SpecNamespace::Foo.new).not_to eq(SpecNamespace::Hello.new)
      expect(SpecNamespace::Foo.new).to eq(SpecNamespace::Foo.new)
      expect(SpecNamespace::Foo.new(simple: 52)).not_to eq(SpecNamespace::Foo.new)
    end

lib/rb/spec/struct_spec.rb:103

  • These fixtures include Thrift::Struct, so their initializer is initialize(d = {}). Using keyword args here will raise on Ruby 3+. Pass explicit hashes instead.
    it "compares only structs of the same generated class" do
      narrow = StructEqualityFixtures::Narrow.new(shared: "value")
      wide = StructEqualityFixtures::Wide.new(shared: "value", extra: "different")
      same_narrow = StructEqualityFixtures::Narrow.new(shared: "value")

lib/rb/spec/struct_spec.rb:118

  • Thrift::Struct#initialize takes a positional hash. These .new(...) calls currently pass keyword args, which will fail on Ruby 3+. Wrap the field hash in {}.
    it "should print enum value names in inspect" do
      expect(SpecNamespace::StructWithSomeEnum.new(some_enum: SpecNamespace::SomeEnum::ONE).inspect).to eq("<SpecNamespace::StructWithSomeEnum some_enum:ONE (0)>")

      expect(SpecNamespace::StructWithEnumMap.new(my_map: {SpecNamespace::SomeEnum::ONE => [SpecNamespace::SomeEnum::TWO]}).inspect).to eq("<SpecNamespace::StructWithEnumMap my_map:{ONE (0): [TWO (1)]}>")
    end

lib/rb/spec/struct_spec.rb:122

  • SpecNamespace::Foo2 is a Thrift::Struct whose initializer expects a positional hash. Using keyword args here will raise on Ruby 3+.
    it "should pretty print binary fields" do
      expect(SpecNamespace::Foo2.new(my_binary: "\001\002\003").inspect).to eq("<SpecNamespace::Foo2 my_binary:010203>")
    end

lib/rb/spec/struct_spec.rb:128

  • SpecNamespace::Foo is a Thrift::Struct and expects a positional hash. These constructor calls currently pass keyword args, which will raise on Ruby 3+.
      expect(SpecNamespace::Foo.new(simple: 52).simple?).to be_truthy
      expect(SpecNamespace::Foo.new(my_bool: false).my_bool?).to be_truthy
      expect(SpecNamespace::Foo.new(my_bool: true).my_bool?).to be_truthy

lib/rb/spec/struct_spec.rb:134

  • SpecNamespace::StructWithSomeEnum is a Thrift::Struct and expects a positional hash. These .new(...) calls currently pass keyword args, which will raise on Ruby 3+.
    it "should be comparable" do
      s1 = SpecNamespace::StructWithSomeEnum.new(some_enum: SpecNamespace::SomeEnum::ONE)
      s2 = SpecNamespace::StructWithSomeEnum.new(some_enum: SpecNamespace::SomeEnum::TWO)

lib/rb/spec/struct_spec.rb:240

  • SpecNamespace::BoolStruct is a Thrift::Struct and expects a positional hash to initialize. BoolStruct.new(yesno: false) uses keyword args and will fail on Ruby 3+.
    it "should serialize false boolean fields correctly" do
      b = SpecNamespace::BoolStruct.new(yesno: false)
      prot = Thrift::BinaryProtocol.new(Thrift::MemoryBufferTransport.new)
      expect(prot).to receive(:write_bool).with(false)
      b.write(prot)
    end

lib/rb/spec/struct_spec.rb:318

  • SpecNamespace::Foo is a Thrift::Struct and expects a positional hash. These constructor calls currently pass keyword args, which will raise on Ruby 3+.
    it "should serialize subclasses of Set like Set" do
      set_subclass = Class.new(Set)
      regular = SpecNamespace::Foo.new(shorts: Set.new([5, 17, 239]))
      subclassed = SpecNamespace::Foo.new(shorts: set_subclass.new([5, 17, 239]))
      serializer = Thrift::Serializer.new(Thrift::BinaryProtocolFactory.new)

      expect(serializer.serialize(subclassed)).to eq(serializer.serialize(regular))
    end

lib/rb/spec/struct_spec.rb:333

  • Thrift::Struct#initialize(d = {}) doesn’t accept keyword args on Ruby 3+. These .new(greeting: 3) calls should pass a positional hash to keep the type-checking behavior testable on Ruby 3+.
    it "should support optional type-checking in Thrift::Struct.new" do
      Thrift.type_checking = true
      begin
        expect { SpecNamespace::Hello.new(greeting: 3) }.to raise_error(Thrift::TypeError, "Expected Types::STRING, received Integer for field greeting")
      ensure
        Thrift.type_checking = false
      end
      expect { SpecNamespace::Hello.new(greeting: 3) }.not_to raise_error

lib/rb/spec/struct_spec.rb:349

  • Thrift::Struct#initialize(d = {}) expects a positional hash. Hello.new(fish: ...) uses keyword args and will raise on Ruby 3+, so this test won’t exercise the intended unknown-key behavior.
    it "should raise an exception when unknown types are given to Thrift::Struct.new" do
      expect { SpecNamespace::Hello.new(fish: "salmon") }.to raise_error(Exception, "Unknown key given to SpecNamespace::Hello.new: fish")
    end

lib/rb/spec/serializer_spec.rb:159

  • SpecNamespace::Hello is a Thrift::Struct (initialize(d = {})). Hello.new(greeting: ...) passes keyword args and will raise on Ruby 3+. Pass a positional hash instead.
    it "should serialize structs to the given protocol" do
      transport = double("transport")
      protocol = Thrift::BaseProtocol.new(transport)
      expect(protocol).to receive(:write_struct_begin).with("SpecNamespace::Hello")
      expect(protocol).to receive(:write_field_begin).with("greeting", Thrift::Types::STRING, 1)
      expect(protocol).to receive(:write_string).with("Good day")
      expect(protocol).to receive(:write_field_end)
      expect(protocol).to receive(:write_field_stop)
      expect(protocol).to receive(:write_struct_end)
      expect(transport).to receive(:flush)
      protocol_factory = double("ProtocolFactory")
      allow(protocol_factory).to receive(:get_protocol).and_return(protocol)
      serializer = Thrift::Serializer.new(protocol_factory)
      serializer.serialize(SpecNamespace::Hello.new(greeting: "Good day"))
    end

lib/rb/spec/serializer_spec.rb:166

  • SpecNamespace::Hello is a Thrift::Struct (initialize(d = {})). Hello.new(greeting: ...) passes keyword args and will raise on Ruby 3+. Pass a positional hash instead.
      it "isolates JSON protocol state after a #{stage} write failure" do
        serializer = Thrift::Serializer.new(Thrift::JsonProtocolFactory.new)
        value = SpecNamespace::Hello.new(greeting: "Good day")
        expected = Thrift::Serializer.new(Thrift::JsonProtocolFactory.new).serialize(value)
        error = RuntimeError.new("failed at #{stage}")

lib/rb/spec/serializer_spec.rb:188

  • SpecNamespace::Hello is a Thrift::Struct (initialize(d = {})). Hello.new(greeting: ...) passes keyword args and will raise on Ruby 3+. Pass a positional hash instead.
    it "recovers after repeated JSON serialization failures" do
      serializer = Thrift::Serializer.new(Thrift::JsonProtocolFactory.new)
      value = SpecNamespace::Hello.new(greeting: "recovered")

lib/rb/spec/serializer_spec.rb:207

  • SpecNamespace::Hello is a Thrift::Struct (initialize(d = {})). This should pass a positional hash rather than keyword args for Ruby 3+ compatibility.
    it "keeps ordinary protocol output byte-for-byte stable" do
      value = SpecNamespace::Hello.new(greeting: "Good day")
      expected = {
        Thrift::BinaryProtocolFactory => "\v\x00\x01\x00\x00\x00\bGood day\x00".b,
        Thrift::CompactProtocolFactory => "\x18\bGood day\x00".b,
        Thrift::JsonProtocolFactory => "{\"1\":{\"str\":\"Good day\"}}"
      }

lib/rb/spec/serializer_spec.rb:219

  • SpecNamespace::Hello is a Thrift::Struct (initialize(d = {})). This should pass a positional hash rather than keyword args for Ruby 3+ compatibility.
    it "finalizes and round-trips framed transport output" do
      value = SpecNamespace::Hello.new(greeting: "Good day")
      factory = SerializerFixtures::FramedBinaryProtocolFactory.new

      data = Thrift::Serializer.new(factory).serialize(value)

lib/rb/spec/serializer_spec.rb:254

  • SpecNamespace::Hello is a Thrift::Struct (initialize(d = {})). Hello.new(greeting: ...) passes keyword args and will raise on Ruby 3+. Pass a positional hash instead.
    it "should deserialize structs from binary by default" do
      deserializer = Thrift::Deserializer.new
      data = "\x0B\x00\x01\x00\x00\x00\x0E'Ello guv'nor!\x00"
      expect(deserializer.deserialize(SpecNamespace::Hello.new, data)).to eq(SpecNamespace::Hello.new(greeting: "'Ello guv'nor!"))
    end

lib/rb/spec/serializer_spec.rb:268

  • SpecNamespace::Hello is a Thrift::Struct (initialize(d = {})). Hello.new(greeting: ...) passes keyword args and will raise on Ruby 3+. Pass a positional hash instead.
      expect(protocol).to receive(:read_field_end)
      expect(protocol).to receive(:read_struct_end)
      protocol_factory = double("ProtocolFactory")
      allow(protocol_factory).to receive(:get_protocol).and_return(protocol)
      deserializer = Thrift::Deserializer.new(protocol_factory)
      expect(deserializer.deserialize(SpecNamespace::Hello.new, "")).to eq(SpecNamespace::Hello.new(greeting: "Good day"))
    end

lib/rb/spec/serializer_spec.rb:313

  • SpecNamespace::Foo is a Thrift::Struct (initialize(d = {})). Foo.new(simple: ..., opt_string: ...) uses keyword args and will raise on Ruby 3+. Pass an explicit hash.
    it "does not retain previous struct state when reading fails" do
      target = SpecNamespace::Foo.new(simple: 99, opt_string: "old")
      payload = binary_payload(finish: false) do |protocol, transport|
        protocol.write_field_begin("opt_string", Thrift::Types::STRING, 7)
        transport.write([5].pack("N"))
      end

      expect {
        Thrift::Deserializer.new.deserialize(target, payload)
      }.to raise_error(EOFError)
      expect(target.simple).to eq(53)
      expect(target.opt_string).to be_nil
    end

lib/rb/spec/serializer_spec.rb:320

  • DeserializerResetFixtures::ResetFieldsStruct is a Thrift::Struct (initialize(d = {})). new(reset_fields: ...) uses keyword args and will raise on Ruby 3+. Pass an explicit hash.
    it "resets fields even when an accessor has the same name as the reset operation" do
      target = DeserializerResetFixtures::ResetFieldsStruct.new(reset_fields: "old")

      Thrift::Deserializer.new.deserialize(target, binary_payload)

      expect(target.reset_fields).to be_nil

lib/rb/spec/serializer_spec.rb:343

  • DeserializerResetFixtures::RequiredStruct is a Thrift::Struct (initialize(d = {})). new(required_value: ...) uses keyword args and will raise on Ruby 3+. Pass an explicit hash.
    it "does not satisfy required-field validation with a value from the previous read" do
      target = DeserializerResetFixtures::RequiredStruct.new(required_value: "old")

      expect {
        Thrift::Deserializer.new.deserialize(target, binary_payload)
      }.to raise_error(Thrift::ProtocolException, "Required field required_value is unset!")
      expect(target.required_value).to be_nil
    end

lib/rb/spec/processor_spec.rb:126

  • Sleep_args is a generated Thrift::Struct (initializer initialize(d = {})). new(seconds: 3.0) passes keyword args and will raise on Ruby 3+. Pass a positional hash instead.
    it "keeps generated reply behavior when a normal method envelope is ONEWAY" do
      handler = double("Handler")
      expect(handler).to receive(:sleep).with(3.0)
      processor = SpecNamespace::NonblockingService::Processor.new(handler)
      args = SpecNamespace::NonblockingService::Sleep_args.new(seconds: 3.0)
      input = input_protocol("sleep", Thrift::MessageTypes::ONEWAY, 14, args)

lib/rb/spec/nonblocking_server_spec.rb:186

  • SpecNamespace::Hello is a Thrift::Struct (initialize(d = {})). These expectations currently construct a struct via keyword args, which will raise on Ruby 3+. Pass an explicit hash.
    it "should handle basic message passing" do
      client = setup_client
      expect(client.greeting(true)).to eq(SpecNamespace::Hello.new)
      expect(client.greeting(false)).to eq(SpecNamespace::Hello.new(greeting: "Aloha!"))
      @server.shutdown
    end

lib/rb/spec/nonblocking_server_spec.rb:226

  • SpecNamespace::Hello is a Thrift::Struct (initialize(d = {})). This expectation currently constructs a struct via keyword args, which will raise on Ruby 3+. Pass an explicit hash.
      queues[2] << :hello
      expect(result.pop).to eq(SpecNamespace::Hello.new)
      expect(client.greeting(false)).to eq(SpecNamespace::Hello.new(greeting: "Aloha!"))
      7.times { queues.shift << :exit }

lib/rb/spec/compact_protocol_spec.rb:485

  • Thrift::Test::SingleMapTestStruct is a generated Thrift::Struct (initialize(d = {})). new(i32_map: {}) passes keyword args and will raise on Ruby 3+. Pass a positional hash instead.
  it "should deserialize an empty map to an empty hash" do
    struct = Thrift::Test::SingleMapTestStruct.new(i32_map: {})
    ser = Thrift::Serializer.new(Thrift::CompactProtocolFactory.new)
    bytes = ser.serialize(struct)

Comment thread test/rb/generation/test_struct.rb
Comment thread lib/rb/spec/union_spec.rb
Comment thread lib/rb/spec/struct_spec.rb
Comment thread lib/rb/spec/serializer_spec.rb
Comment thread lib/rb/spec/processor_spec.rb
Comment thread lib/rb/spec/nonblocking_server_spec.rb
Comment thread lib/rb/spec/compact_protocol_spec.rb
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