From 9fd82df823ee0a5ea1c468fdb252f378945c43fc Mon Sep 17 00:00:00 2001 From: Simone Carletti Date: Wed, 8 Nov 2023 11:13:49 +0100 Subject: [PATCH] Fix rubocop offenses --- bin/whoisrb | 2 +- lib/whois.rb | 8 ++++---- lib/whois/record/part.rb | 2 +- lib/whois/server/adapters/arin.rb | 2 +- spec/whois/record_spec.rb | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/bin/whoisrb b/bin/whoisrb index 9dd7f7bc1..76351776d 100755 --- a/bin/whoisrb +++ b/bin/whoisrb @@ -47,7 +47,7 @@ OptionParser.new do |opts| exit 1 end - if ARGV.size.zero? + if ARGV.empty? puts opts exit 1 end diff --git a/lib/whois.rb b/lib/whois.rb index 63336f0bc..d578e0dc5 100644 --- a/lib/whois.rb +++ b/lib/whois.rb @@ -44,7 +44,7 @@ def lookup(object) def available?(object) unless defined? Whois::Parser warn("Whois.available? requires the gem `whois-parser`") - return + return false end deprecate(%{Whois.available? is deprecated. Call Whois.whois("#{object}").parser.available?}) @@ -61,7 +61,7 @@ def available?(object) def registered?(object) unless defined? Whois::Parser warn("Whois.registered? requires the gem `whois-parser`") - return + return false end deprecate(%{Whois.registered? is deprecated. Call Whois.whois("#{object}").parser.registered?}) @@ -90,8 +90,8 @@ def deprecate(message = nil, callstack = caller) # @private def bug!(error, message) raise error, message.dup << - " Please report the issue at" \ - " http://github.com/weppos/whois/issues" + " Please report the issue at " \ + "http://github.com/weppos/whois/issues" end diff --git a/lib/whois/record/part.rb b/lib/whois/record/part.rb index 339159d4c..68b7568b7 100644 --- a/lib/whois/record/part.rb +++ b/lib/whois/record/part.rb @@ -26,7 +26,7 @@ class Record def initialize(*args) if args.first.is_a? Hash initialize_with_hash(args.first) - elsif args.size.zero? + elsif args.empty? super else raise ArgumentError diff --git a/lib/whois/server/adapters/arin.rb b/lib/whois/server/adapters/arin.rb index 59107e747..58c2e8324 100644 --- a/lib/whois/server/adapters/arin.rb +++ b/lib/whois/server/adapters/arin.rb @@ -44,7 +44,7 @@ def extract_referral(response) { host: Regexp.last_match(1), - port: Regexp.last_match(2) ? Regexp.last_match(2).to_i : nil, + port: Regexp.last_match(2)&.to_i, } end diff --git a/spec/whois/record_spec.rb b/spec/whois/record_spec.rb index 21defdba2..6e4b44d14 100644 --- a/spec/whois/record_spec.rb +++ b/spec/whois/record_spec.rb @@ -138,8 +138,8 @@ describe "#match?" do it "calls match and checks for match" do - expect(subject.match?(/record/)).to eq(true) - expect(subject.match?(/nomatch/)).to eq(false) + expect(subject.match?(/record/)).to be(true) + expect(subject.match?(/nomatch/)).to be(false) end end