diff --git a/.rubocop.yml b/.rubocop.yml index 9f3c016..717c0e3 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,5 +1,5 @@ AllCops: - TargetRubyVersion: 2.4 + TargetRubyVersion: 2.6 DisplayCopNames: true Layout/HashAlignment: @@ -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 bca3ee6..a232626 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 cd05d76..59a9603 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 47fddf0..8388ea6 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/readme.md b/readme.md index 1c52891..95e877d 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 diff --git a/spec/nio/selectables/tcp_socket_spec.rb b/spec/nio/selectables/tcp_socket_spec.rb index 1d93b20..8b41c6a 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