From 1f9c90d803311864454692a1494cd5844db59d9d Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Mon, 10 Nov 2025 10:23:57 -0500 Subject: [PATCH] rubocop and combine remove condition --- lib/addresses.rb | 5 +++-- lib/oob.rb | 2 +- sgx_endstream.rb | 27 +++++++++++++++------------ 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/lib/addresses.rb b/lib/addresses.rb index 034c87a8fb6e4323436ae611c09305be2348685b..95e59f6e92707b84da6addf8858cdaa61077777f 100644 --- a/lib/addresses.rb +++ b/lib/addresses.rb @@ -2,10 +2,11 @@ class Addresses < Blather::XMPPNode include Enumerable + register :addresses, "http://jabber.org/protocol/address" def self.new(addresses) - new_node = super :addresses + new_node = super(:addresses) if addresses.is_a?(Array) addresses.each do |address| @@ -38,7 +39,7 @@ class Addresses < Blather::XMPPNode register :address, "http://jabber.org/protocol/address" def self.new(*, type: nil, jid: nil, uri: nil, delivered: nil) - new_node = super :address + new_node = super(:address) new_node["type"] = type new_node["jid"] = jid if jid new_node["uri"] = uri if uri diff --git a/lib/oob.rb b/lib/oob.rb index 1cdb40a39efee5fa0870d2add5dccf7706c1d908..3bf2a3bd722f3c29a30f913ee204261be3ab1cf8 100644 --- a/lib/oob.rb +++ b/lib/oob.rb @@ -6,7 +6,7 @@ class OOB < Blather::XMPPNode register :oob, "jabber:x:oob" def self.new(url=nil, desc: nil) - new_node = super :x + new_node = super(:x) case url when Nokogiri::XML::Node diff --git a/sgx_endstream.rb b/sgx_endstream.rb index 39f4531b72d672ce1e306742df8deec38f83c321..a687836d87352ed4eb71d2738e260715b53acb7c 100755 --- a/sgx_endstream.rb +++ b/sgx_endstream.rb @@ -21,6 +21,7 @@ require_relative "lib/registration_repo" singleton_class.class_eval do include Blather::DSL + Blather::DSL.append_features(self) end @@ -55,7 +56,7 @@ def panic(e, hub=nil) "Error raised during event loop: #{e.class}", e ) - if e.is_a?(::Exception) + if e.is_a?(Exception) (hub || Sentry).capture_exception(e, hint: { background: false }) else (hub || Sentry).capture_message(e.to_s, hint: { background: false }) @@ -123,18 +124,20 @@ ibr type: :get do |iq| end ibr type: :set do |iq| - if !iq.remove? || iq.phone.to_s !~ /\A\+?1\d{10}\Z/ - self << iq.as_error("bad-request", :modify, "Invalid phone number") - next - end + unless iq.remove? + if iq.phone.to_s !~ /\A\+?1\d{10}\Z/ + self << iq.as_error("bad-request", :modify, "Invalid phone number") + next + end - if (iq.username.to_s.empty? || iq.password.to_s.empty?) && !iq.remove? - self << iq.as_error( - "bad-request", - :modify, - "Username and password are required" - ) - next + if iq.username.to_s.empty? || iq.password.to_s.empty? + self << iq.as_error( + "bad-request", + :modify, + "Username and password are required" + ) + next + end end REGISTRATION_REPO.delete(iq.from).then { |status|