From 65f3f696a43140f64be5ca59d208bb2fb8fd6600 Mon Sep 17 00:00:00 2001 From: Matthew Hirst Date: Tue, 17 Jun 2025 14:42:14 +0400 Subject: [PATCH 1/2] Bump gems and fix ruby 3.4 warnings by marking mutable strings. --- Gemfile | 6 +- Gemfile.lock | 246 ++++++++++++------ cassandra-driver.gemspec | 7 +- .../cluster/schema/cql_type_parser.rb | 6 +- .../cluster/schema/fqcn_type_parser.rb | 6 +- lib/cassandra/errors.rb | 2 +- lib/cassandra/uuid.rb | 4 +- spec/cassandra/protocol/coder_spec.rb | 4 +- .../protocol/cql_byte_buffer_spec.rb | 14 +- .../protocol/cql_protocol_handler_spec.rb | 2 +- .../requests/credentials_request_spec.rb | 2 +- .../protocol/requests/startup_request_spec.rb | 2 +- .../responses/rows_result_response_spec.rb | 2 +- .../responses/supported_response_spec.rb | 2 +- spec/cassandra/session_spec.rb | 2 +- spec/spec_helper.rb | 1 + 16 files changed, 195 insertions(+), 113 deletions(-) diff --git a/Gemfile b/Gemfile index 8af924584..1b0ec75e6 100644 --- a/Gemfile +++ b/Gemfile @@ -2,16 +2,18 @@ source 'https://rubygems.org/' gemspec +gem 'debug', group: [:development, :test] gem 'cliver', group: [:development, :test] gem 'lz4-ruby', group: [:development, :test] gem 'rake-compiler', group: [:development, :test] gem 'snappy', group: [:development, :test] +gem 'ione', github: "hornet-network/ione", branch: "main" group :development do platforms :mri_19 do gem 'perftools.rb' end - gem 'rubocop', '~> 0.51', require: false + gem 'rubocop' end group :test do @@ -19,7 +21,7 @@ group :test do gem 'aruba' gem 'cucumber' gem 'delorean' - gem 'minitest', '< 5.0.0' + gem 'minitest' gem 'os' gem 'rspec' gem 'rspec-collection_matchers' diff --git a/Gemfile.lock b/Gemfile.lock index 62622f396..14944100f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,127 +1,205 @@ +GIT + remote: https://github.com/hornet-network/ione.git + revision: e665ea33e98003ca029cdeafb37116dc0a5dae85 + branch: main + specs: + ione (1.3.1) + PATH remote: . specs: cassandra-driver (3.2.5) - ione (~> 1.2) + ione + sorted_set GEM remote: https://rubygems.org/ specs: ansi (1.5.0) - aruba (0.13.0) - childprocess (~> 0.5.6) - contracts (~> 0.9) - cucumber (>= 1.3.19) - ffi (~> 1.9.10) - rspec-expectations (>= 2.99) - thor (~> 0.19) - ast (2.3.0) - builder (3.2.2) - childprocess (0.5.9) - ffi (~> 1.0, >= 1.0.11) + aruba (2.3.1) + bundler (>= 1.17, < 3.0) + contracts (>= 0.16.0, < 0.18.0) + cucumber (>= 8.0, < 11.0) + rspec-expectations (~> 3.4) + thor (~> 1.0) + ast (2.4.3) + base64 (0.3.0) + bigdecimal (3.2.2) + builder (3.3.0) chronic (0.10.2) cliver (0.3.2) - contracts (0.13.0) - cucumber (2.3.2) - builder (>= 2.1.2) - cucumber-core (~> 1.4.0) - cucumber-wire (~> 0.0.1) - diff-lcs (>= 1.1.3) - gherkin (~> 3.2.0) - multi_json (>= 1.7.5, < 2.0) - multi_test (>= 0.1.2) - cucumber-core (1.4.0) - gherkin (~> 3.2.0) - cucumber-wire (0.0.1) + contracts (0.17.2) + cucumber (10.0.0) + base64 (~> 0.2) + builder (~> 3.2) + cucumber-ci-environment (> 9, < 11) + cucumber-core (> 15, < 17) + cucumber-cucumber-expressions (> 17, < 19) + cucumber-html-formatter (> 20.3, < 22) + diff-lcs (~> 1.5) + logger (~> 1.6) + mini_mime (~> 1.1) + multi_test (~> 1.1) + sys-uname (~> 1.3) + cucumber-ci-environment (10.0.1) + cucumber-core (15.1.0) + cucumber-gherkin (> 27, < 31) + cucumber-messages (> 26, < 29) + cucumber-tag-expressions (> 5, < 7) + cucumber-cucumber-expressions (18.0.1) + bigdecimal + cucumber-gherkin (30.0.4) + cucumber-messages (> 25, < 28) + cucumber-html-formatter (21.10.1) + cucumber-messages (> 19, < 28) + cucumber-messages (27.2.0) + cucumber-tag-expressions (6.1.2) + date (3.4.1) + debug (1.10.0) + irb (~> 1.10) + reline (>= 0.3.8) delorean (2.1.0) chronic - diff-lcs (1.2.5) - docile (1.1.5) - ffi (1.9.25) - ffi (1.9.25-java) - gherkin (3.2.0) - ione (1.2.4) - json (1.8.6) - json (1.8.6-java) + diff-lcs (1.6.2) + docile (1.4.1) + erb (5.0.1) + ffi (1.17.2) + ffi (1.17.2-aarch64-linux-gnu) + ffi (1.17.2-aarch64-linux-musl) + ffi (1.17.2-arm-linux-gnu) + ffi (1.17.2-arm-linux-musl) + ffi (1.17.2-arm64-darwin) + ffi (1.17.2-x86-linux-gnu) + ffi (1.17.2-x86-linux-musl) + ffi (1.17.2-x86_64-darwin) + ffi (1.17.2-x86_64-linux-gnu) + ffi (1.17.2-x86_64-linux-musl) + io-console (0.8.0) + irb (1.15.2) + pp (>= 0.6.0) + rdoc (>= 4.0.0) + reline (>= 0.4.2) + json (2.12.2) + language_server-protocol (3.17.0.5) + lint_roller (1.1.0) + logger (1.7.0) lz4-ruby (0.3.3) - lz4-ruby (0.3.3-java) - minitest (4.7.5) - multi_json (1.11.2) - multi_test (0.1.2) - os (0.9.6) - parallel (1.12.0) - parser (2.4.0.2) - ast (~> 2.3) - perftools.rb (2.0.4) - powerpack (0.1.1) - rainbow (2.2.2) - rake - rake (13.0.1) - rake-compiler (0.9.5) + mini_mime (1.1.5) + minitest (5.25.5) + multi_test (1.1.0) + os (1.1.4) + parallel (1.27.0) + parser (3.3.8.0) + ast (~> 2.4.1) + racc + perftools.rb (2.0.5) + pp (0.6.2) + prettyprint + prettyprint (0.2.0) + prism (1.4.0) + psych (5.2.6) + date + stringio + racc (1.8.1) + rainbow (3.1.1) + rake (13.3.0) + rake-compiler (1.3.0) rake - rspec (3.9.0) - rspec-core (~> 3.9.0) - rspec-expectations (~> 3.9.0) - rspec-mocks (~> 3.9.0) - rspec-collection_matchers (1.2.0) + rbtree (0.4.6) + rdoc (6.14.0) + erb + psych (>= 4.0.0) + regexp_parser (2.10.0) + reline (0.6.1) + io-console (~> 0.5) + rspec (3.13.1) + rspec-core (~> 3.13.0) + rspec-expectations (~> 3.13.0) + rspec-mocks (~> 3.13.0) + rspec-collection_matchers (1.2.1) rspec-expectations (>= 2.99.0.beta1) - rspec-core (3.9.1) - rspec-support (~> 3.9.1) - rspec-expectations (3.9.1) + rspec-core (3.13.4) + rspec-support (~> 3.13.0) + rspec-expectations (3.13.5) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.9.0) - rspec-mocks (3.9.1) + rspec-support (~> 3.13.0) + rspec-mocks (3.13.5) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.9.0) - rspec-support (3.9.2) - rspec-wait (0.0.9) - rspec (>= 3, < 4) - rubocop (0.51.0) + rspec-support (~> 3.13.0) + rspec-support (3.13.4) + rspec-wait (1.0.1) + rspec (>= 3.4) + rubocop (1.76.2) + json (~> 2.3) + language_server-protocol (~> 3.17.0.2) + lint_roller (~> 1.1.0) parallel (~> 1.10) - parser (>= 2.3.3.1, < 3.0) - powerpack (~> 0.1) - rainbow (>= 2.2.2, < 3.0) + parser (>= 3.3.0.2) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 2.9.3, < 3.0) + rubocop-ast (>= 1.45.1, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (~> 1.0, >= 1.0.1) - ruby-progressbar (1.9.0) - simplecov (0.11.2) - docile (~> 1.1.0) - json (~> 1.8) - simplecov-html (~> 0.10.0) - simplecov-html (0.10.0) - snappy (0.0.14) - snappy (0.0.14-java) - snappy-jars (~> 1.1.0) - snappy-jars (1.1.0.1.2-java) - thor (0.19.1) - unicode-display_width (1.3.0) - yard (0.9.20) + unicode-display_width (>= 2.4.0, < 4.0) + rubocop-ast (1.45.1) + parser (>= 3.3.7.2) + prism (~> 1.4) + ruby-progressbar (1.13.0) + set (1.1.2) + simplecov (0.22.0) + docile (~> 1.1) + simplecov-html (~> 0.11) + simplecov_json_formatter (~> 0.1) + simplecov-html (0.13.1) + simplecov_json_formatter (0.1.4) + snappy (0.4.0) + sorted_set (1.0.3) + rbtree + set (~> 1.0) + stringio (3.1.7) + sys-uname (1.3.1) + ffi (~> 1.1) + thor (1.3.2) + unicode-display_width (3.1.4) + unicode-emoji (~> 4.0, >= 4.0.4) + unicode-emoji (4.0.4) + yard (0.9.37) PLATFORMS - java + aarch64-linux-gnu + aarch64-linux-musl + arm-linux-gnu + arm-linux-musl + arm64-darwin ruby + x86-linux-gnu + x86-linux-musl + x86_64-darwin + x86_64-linux-gnu + x86_64-linux-musl DEPENDENCIES ansi aruba - bundler (~> 1.6) + bundler cassandra-driver! cliver cucumber + debug delorean + ione! lz4-ruby - minitest (< 5.0.0) + minitest os perftools.rb - rake (~> 13.0) + rake rake-compiler rspec rspec-collection_matchers rspec-wait - rubocop (~> 0.51) + rubocop simplecov snappy yard BUNDLED WITH - 1.17.3 + 2.6.9 diff --git a/cassandra-driver.gemspec b/cassandra-driver.gemspec index bd2624b50..0eda62aca 100644 --- a/cassandra-driver.gemspec +++ b/cassandra-driver.gemspec @@ -30,8 +30,9 @@ Gem::Specification.new do |s| s.files << 'ext/cassandra_murmur3/cassandra_murmur3.c' end - s.add_runtime_dependency 'ione', '~> 1.2' + s.add_runtime_dependency 'ione' + s.add_runtime_dependency 'sorted_set' - s.add_development_dependency 'bundler', '~> 1.6' - s.add_development_dependency 'rake', '~> 13.0' + s.add_development_dependency 'bundler' + s.add_development_dependency 'rake' end diff --git a/lib/cassandra/cluster/schema/cql_type_parser.rb b/lib/cassandra/cluster/schema/cql_type_parser.rb index a10f08af4..b096ff534 100644 --- a/lib/cassandra/cluster/schema/cql_type_parser.rb +++ b/lib/cassandra/cluster/schema/cql_type_parser.rb @@ -85,16 +85,16 @@ def lookup_type(node, types) end def parse_node(string) - root = node = Node.new(nil, '', []) + root = node = Node.new(nil, +'', []) string.each_char do |char| case char when '<' # starting type params - child = Node.new(node, '', []) + child = Node.new(node, +'', []) node.children << child node = child when ',' - child = Node.new(node.parent, '', []) + child = Node.new(node.parent, +'', []) node.parent.children << child node = child when '>' diff --git a/lib/cassandra/cluster/schema/fqcn_type_parser.rb b/lib/cassandra/cluster/schema/fqcn_type_parser.rb index ea21d3c89..0512da499 100644 --- a/lib/cassandra/cluster/schema/fqcn_type_parser.rb +++ b/lib/cassandra/cluster/schema/fqcn_type_parser.rb @@ -140,16 +140,16 @@ def lookup_type(node) end def parse_node(string) - root = node = Node.new(nil, '', []) + root = node = Node.new(nil, +'', []) string.each_char do |char| case char when '(' # starting type params - child = Node.new(node, '', []) + child = Node.new(node, +'', []) node.children << child node = child when ',' - child = Node.new(node.parent, '', []) + child = Node.new(node.parent, +'', []) node.parent.children << child node = child when ')' diff --git a/lib/cassandra/errors.rb b/lib/cassandra/errors.rb index f64a0ea9e..60bc7efff 100644 --- a/lib/cassandra/errors.rb +++ b/lib/cassandra/errors.rb @@ -761,7 +761,7 @@ class NoHostsAvailable < ::StandardError def initialize(errors = nil) if errors first = true - message = 'All attempted hosts failed' + message = +'All attempted hosts failed' errors.each do |(host, error)| if first first = false diff --git a/lib/cassandra/uuid.rb b/lib/cassandra/uuid.rb index 7f184adec..570a440b4 100644 --- a/lib/cassandra/uuid.rb +++ b/lib/cassandra/uuid.rb @@ -26,9 +26,9 @@ module Cassandra # class Uuid # @private - RAW_FORMAT = '%032x'.force_encoding(Encoding::ASCII).freeze + RAW_FORMAT = String.new('%032x').force_encoding(Encoding::ASCII).freeze # @private - HYPHEN = '-'.force_encoding(Encoding::ASCII).freeze + HYPHEN = String.new('-').force_encoding(Encoding::ASCII).freeze # @private EMPTY_STRING = ''.freeze diff --git a/spec/cassandra/protocol/coder_spec.rb b/spec/cassandra/protocol/coder_spec.rb index c6c7e17f2..bc85fc2e8 100644 --- a/spec/cassandra/protocol/coder_spec.rb +++ b/spec/cassandra/protocol/coder_spec.rb @@ -38,8 +38,8 @@ module Protocol describe('RUBY-128') do it 'reads very large short strings and string' do - column_specs = ::YAML::load(::File.open(::File.dirname(__FILE__) + "/cols.yml")) - buffer = ::YAML::load(::File.open(::File.dirname(__FILE__) + "/buffer.yml")) + column_specs = ::YAML::unsafe_load(::File.open(::File.dirname(__FILE__) + "/cols.yml")) + buffer = ::YAML::unsafe_load(::File.open(::File.dirname(__FILE__) + "/buffer.yml")) Coder.read_values_v1(buffer, column_specs) end diff --git a/spec/cassandra/protocol/cql_byte_buffer_spec.rb b/spec/cassandra/protocol/cql_byte_buffer_spec.rb index 16c50509e..ebe124556 100644 --- a/spec/cassandra/protocol/cql_byte_buffer_spec.rb +++ b/spec/cassandra/protocol/cql_byte_buffer_spec.rb @@ -310,7 +310,7 @@ module Protocol end it 'decodes a string' do - buffer.read_string.should == 'hej och hå'.force_encoding(::Encoding::UTF_8) + buffer.read_string.should == +'hej och hå'.force_encoding(::Encoding::UTF_8) end it 'decodes a string as UTF-8' do @@ -336,7 +336,7 @@ module Protocol describe '#read_long_string' do let :buffer do - described_class.new("\x00\x01\x00\00" << ('x' * 0x10000)) + described_class.new(+"\x00\x01\x00\00" << ('x' * 0x10000)) end it 'decodes a string' do @@ -415,11 +415,11 @@ module Protocol describe '#read_bytes' do let :buffer do - described_class.new("\x00\x01\x00\x00" << ("\x42" * 0x10000)) + described_class.new(+"\x00\x01\x00\x00" << ("\x42" * 0x10000)) end it 'decodes a byte array' do - buffer.read_bytes.should eql_bytes("\x42" * 0x10000) + buffer.read_bytes.should eql_bytes(+"\x42" * 0x10000) end it 'decodes an empty byte array' do @@ -446,11 +446,11 @@ module Protocol describe '#read_short_bytes' do let :buffer do - described_class.new("\x01\x00" << ("\x42" * 0x100)) + described_class.new(+"\x01\x00" << ("\x42" * 0x100)) end it 'decodes a byte array' do - buffer.read_short_bytes.should eql_bytes("\x42" * 0x100) + buffer.read_short_bytes.should eql_bytes(+"\x42" * 0x100) end it 'decodes an empty byte array' do @@ -769,7 +769,7 @@ module Protocol describe '#append_bytes' do it 'encodes a byte array' do buffer.append_bytes("\xaa" * 2000) - buffer.should eql_bytes("\x00\x00\x07\xd0" << ("\xaa" * 2000)) + buffer.should eql_bytes(+"\x00\x00\x07\xd0" << ("\xaa" * 2000)) end it 'encodes a string with multibyte characters' do diff --git a/spec/cassandra/protocol/cql_protocol_handler_spec.rb b/spec/cassandra/protocol/cql_protocol_handler_spec.rb index 2a24474bc..670c0179d 100644 --- a/spec/cassandra/protocol/cql_protocol_handler_spec.rb +++ b/spec/cassandra/protocol/cql_protocol_handler_spec.rb @@ -209,7 +209,7 @@ module Protocol end it 'decompresses response frames' do - id = "\xCAH\x7F\x1Ez\x82\xD2 'bar', 'hello' => 'world') - request.to_s.should == 'CREDENTIALS {"foo"=>"bar", "hello"=>"world"}' + request.to_s.gsub(" => ", "=>").should == 'CREDENTIALS {"foo"=>"bar", "hello"=>"world"}' end end diff --git a/spec/cassandra/protocol/requests/startup_request_spec.rb b/spec/cassandra/protocol/requests/startup_request_spec.rb index ec457c85a..3b1a54711 100644 --- a/spec/cassandra/protocol/requests/startup_request_spec.rb +++ b/spec/cassandra/protocol/requests/startup_request_spec.rb @@ -51,7 +51,7 @@ module Protocol describe '#to_s' do it 'returns a pretty string' do request = StartupRequest.new('3.0.0') - request.to_s.should == 'STARTUP {"CQL_VERSION"=>"3.0.0"}' + request.to_s.gsub(" => ", "=>").should == 'STARTUP {"CQL_VERSION"=>"3.0.0"}' end end end diff --git a/spec/cassandra/protocol/responses/rows_result_response_spec.rb b/spec/cassandra/protocol/responses/rows_result_response_spec.rb index 326cbf315..130250fbd 100644 --- a/spec/cassandra/protocol/responses/rows_result_response_spec.rb +++ b/spec/cassandra/protocol/responses/rows_result_response_spec.rb @@ -32,7 +32,7 @@ module Protocol describe '#to_s' do it 'returns a string with metadata and rows' do response = RowsResultResponse.new(nil, nil, [{'col' => 'foo'}], [['ks', 'tbl', 'col', :varchar]], nil, nil) - response.to_s.should == 'RESULT ROWS [["ks", "tbl", "col", :varchar]] [{"col"=>"foo"}]' + response.to_s.gsub(" => ", "=>").should == 'RESULT ROWS [["ks", "tbl", "col", :varchar]] [{"col"=>"foo"}]' end end end diff --git a/spec/cassandra/protocol/responses/supported_response_spec.rb b/spec/cassandra/protocol/responses/supported_response_spec.rb index 7781baa6e..526ff5b6e 100644 --- a/spec/cassandra/protocol/responses/supported_response_spec.rb +++ b/spec/cassandra/protocol/responses/supported_response_spec.rb @@ -25,7 +25,7 @@ module Protocol describe '#to_s' do it 'returns a string with the options' do response = described_class.new('CQL_VERSION' => ['3.0.0'], 'COMPRESSION' => []) - response.to_s.should == 'SUPPORTED {"CQL_VERSION"=>["3.0.0"], "COMPRESSION"=>[]}' + response.to_s.gsub(" => ", "=>").should == 'SUPPORTED {"CQL_VERSION"=>["3.0.0"], "COMPRESSION"=>[]}' end end end diff --git a/spec/cassandra/session_spec.rb b/spec/cassandra/session_spec.rb index 321979bb9..070d5d5e1 100644 --- a/spec/cassandra/session_spec.rb +++ b/spec/cassandra/session_spec.rb @@ -143,7 +143,7 @@ module Cassandra bound_statement = double('bound statement') options = double('options') - expect(session_options).to receive(:override).once.with(nil, arguments: [1, 2, 3, 4, 5]).and_return(options) + expect(session_options).to receive(:override).once.with(nil, {arguments: [1, 2, 3, 4, 5]}).and_return(options) allow(options).to receive(:arguments).and_return([1, 2, 3, 4, 5]) expect(statement).to receive(:bind).with([1, 2, 3, 4, 5]).and_return(bound_statement) expect(client).to receive(:execute).once.with(bound_statement, options).and_return(promise) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 64a93d261..d5f525839 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -16,6 +16,7 @@ # limitations under the License. #++ +Warning[:deprecated] = true # Enable ruby deprecation warnings ENV['CASSANDRA_HOST'] ||= '127.0.0.1' require 'bundler/setup' From 40d03186eac918ef99d84d73681c471ccdfb726e Mon Sep 17 00:00:00 2001 From: Matthew Hirst Date: Tue, 17 Jun 2025 14:45:23 +0400 Subject: [PATCH 2/2] Fix contribution readme. --- CONTRIBUTING.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ac9ba1b26..1f092b36b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -12,7 +12,8 @@ Try to write a test case and include it in your report (have a look at the [regression test suite](spec/regressions) if you need inspiration). 1. Bundle with `bundle install` -1. Run the unit test suite with `rake rspec` +2. Compile native extension with `rake compile` +3. Run the unit test suite with `rake rspec` * Using this rake task will install necessary ruby extensions as a prerequisite * For `bundle exec rspec` to be successful, run `bundle exec rake compile` once, beforehand