From b837a5c23b338bb6a647e5e35658e6ffa12b08b1 Mon Sep 17 00:00:00 2001 From: David English Date: Fri, 30 Jan 2026 17:58:53 -0500 Subject: [PATCH 1/2] Match ruby version in gemspec --- .rubocop.yml | 2 +- readme.md | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 9f3c0163..2b1b5b11 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,5 +1,5 @@ AllCops: - TargetRubyVersion: 2.4 + TargetRubyVersion: 2.6 DisplayCopNames: true Layout/HashAlignment: diff --git a/readme.md b/readme.md index 1c528919..95e877d7 100644 --- a/readme.md +++ b/readme.md @@ -27,7 +27,6 @@ writing. ## Supported platforms - - Ruby 2.5 - Ruby 2.6 - Ruby 2.7 - Ruby 3.0 From 4ce0bc3a780d21767631b6c2757e86b5290c8ddd Mon Sep 17 00:00:00 2001 From: David English Date: Fri, 30 Jan 2026 18:39:38 -0500 Subject: [PATCH 2/2] Fix infractions and clean up rubocop configuration --- .rubocop.yml | 19 +++++++++++------ lib/nio.rb | 4 ++-- nio4r.gemspec | 12 ++++++----- rakelib/extension.rake | 2 +- spec/nio/selectables/tcp_socket_spec.rb | 28 ++++++++++++------------- 5 files changed, 36 insertions(+), 29 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 2b1b5b11..717c0e3b 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -24,9 +24,6 @@ Style/UnpackFirst: # Lint # -Lint/SuppressedException: - Enabled: false - Lint/Loop: Enabled: false @@ -35,6 +32,13 @@ Lint/RaiseException: Lint/StructNewOverride: Enabled: false + +Lint/SuppressedException: + Enabled: false + +Lint/UselessAssignment: + Enabled: false + # # Metrics # @@ -49,13 +53,13 @@ Metrics/BlockLength: Metrics/ClassLength: Max: 128 +Metrics/CyclomaticComplexity: + Max: 15 + Metrics/MethodLength: CountComments: false Max: 50 -Metrics/CyclomaticComplexity: - Max: 15 - Metrics/PerceivedComplexity: Max: 15 @@ -63,6 +67,9 @@ Metrics/PerceivedComplexity: # Style # +Style/AsciiComments: + Enabled: false + Style/ExponentialNotation: Enabled: false diff --git a/lib/nio.rb b/lib/nio.rb index bca3ee6b..a2326268 100644 --- a/lib/nio.rb +++ b/lib/nio.rb @@ -29,7 +29,7 @@ def self.pure?(env = ENV) end # Native Ruby on Windows is not supported: - if (Gem.win_platform? && !defined?(JRUBY_VERSION)) + if Gem.win_platform? && !defined?(JRUBY_VERSION) return true end @@ -38,7 +38,7 @@ def self.pure?(env = ENV) # return true # end - return false + false end end diff --git a/nio4r.gemspec b/nio4r.gemspec index cd05d76b..59a9603d 100644 --- a/nio4r.gemspec +++ b/nio4r.gemspec @@ -7,12 +7,14 @@ Gem::Specification.new do |spec| spec.version = NIO::VERSION spec.summary = "New IO for Ruby" + # rubocop:disable Layout/LineLength spec.authors = ["Tony Arcieri", "Samuel Williams", "Olle Jonsson", "Gregory Longtin", "Tiago Cardoso", "Joao Fernandes", "Thomas Dziedzic", "Boaz Segev", "Logan Bowers", "Pedro Paiva", "Jun Aruga", "Omer Katz", "Upekshe Jayasekera", "Tim Carey-Smith", "Benoit Daloze", "Sergey Avseyev", "Tomoya Ishida", "Usaku Nakamura", "Cédric Boutillier", "Daniel Berger", "Dirkjan Bussink", "Hiroshi Shibata", "Jesús Burgos Maciá", "Luis Lavena", "Pavel Rosický", "Sadayuki Furuhashi", "Stephen von Takach", "Vladimir Kochnev", "Vít Ondruch", "Anatol Pomozov", "Bernd Ahlers", "Charles Oliver Nutter", "Denis Washington", "Elad Eyal", "Jean byroot Boussier", "Jeffrey Martin", "John Thornton", "Jun Jiang", "Lars Kanis", "Marek Kowalcze", "Maxime Demolin", "Orien Madgwick", "Pavel Lobashov", "Per Lundberg", "Phillip Aldridge", "Ravil Bayramgalin", "Shannon Skipper", "Tao Luo", "Thomas Kuntz", "Tsimnuj Hawj", "Zhang Kang"] + # rubocop:enable Layout/LineLength spec.licenses = ["MIT", "BSD-2-Clause"] unless defined? JRUBY_VERSION - spec.cert_chain = ['release.cert'] - spec.signing_key = File.expand_path('~/.gem/release.pem') + spec.cert_chain = ["release.cert"] + spec.signing_key = File.expand_path("~/.gem/release.pem") end spec.homepage = "https://github.com/socketry/nio4r" @@ -23,11 +25,11 @@ Gem::Specification.new do |spec| "documentation_uri" => "https://www.rubydoc.info/gems/nio4r", "funding_uri" => "https://github.com/sponsors/ioquatix/", "source_code_uri" => "https://github.com/socketry/nio4r.git", - "wiki_uri" => "https://github.com/socketry/nio4r/wiki", + "wiki_uri" => "https://github.com/socketry/nio4r/wiki" } - spec.files = Dir.glob(['{ext,lib}/**/*', '*.md'], File::FNM_DOTMATCH, base: __dir__) - spec.require_paths = ['lib'] + spec.files = Dir.glob(["{ext,lib}/**/*", "*.md"], File::FNM_DOTMATCH, base: __dir__) + spec.require_paths = ["lib"] spec.required_ruby_version = ">= 2.6" diff --git a/rakelib/extension.rake b/rakelib/extension.rake index 47fddf05..8388ea6b 100644 --- a/rakelib/extension.rake +++ b/rakelib/extension.rake @@ -4,7 +4,7 @@ if defined? JRUBY_VERSION require "rake/javaextensiontask" Rake::JavaExtensionTask.new("nio4r_ext") do |ext| ext.ext_dir = "ext/nio4r" - ext.release = '8' + ext.release = "8" end else require "rake/extensiontask" diff --git a/spec/nio/selectables/tcp_socket_spec.rb b/spec/nio/selectables/tcp_socket_spec.rb index 1d93b201..8b41c6a8 100644 --- a/spec/nio/selectables/tcp_socket_spec.rb +++ b/spec/nio/selectables/tcp_socket_spec.rb @@ -84,25 +84,23 @@ include_context NIO::Selector it "selects writable when connected" do - begin - server = TCPServer.new(addr, 0) + server = TCPServer.new(addr, 0) - client = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0) - monitor = selector.register(client, :w) + client = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0) + monitor = selector.register(client, :w) - expect do - client.connect_nonblock server.local_address - end.to raise_exception Errno::EINPROGRESS + expect do + client.connect_nonblock server.local_address + end.to raise_exception Errno::EINPROGRESS - ready = selector.select(1) + ready = selector.select(1) - expect(ready).to include monitor - result = client.getsockopt(::Socket::SOL_SOCKET, ::Socket::SO_ERROR) - expect(result.unpack("i").first).to be_zero - ensure - server.close rescue nil - selector.close rescue nil - end + expect(ready).to include monitor + result = client.getsockopt(::Socket::SOL_SOCKET, ::Socket::SO_ERROR) + expect(result.unpack("i").first).to be_zero + ensure + server.close rescue nil + selector.close rescue nil end end end