From 9bc7c7cd062842a1016d7d535115c9a39b8ff8d6 Mon Sep 17 00:00:00 2001 From: Tim Riley Date: Sat, 25 May 2024 17:20:35 +1000 Subject: [PATCH] Update for new Rubocop 1.64.0 cops --- lib/hanami/utils/kernel.rb | 10 +++++----- spec/unit/hanami/utils/string_spec.rb | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/hanami/utils/kernel.rb b/lib/hanami/utils/kernel.rb index 3f82272f..e1c551e0 100644 --- a/lib/hanami/utils/kernel.rb +++ b/lib/hanami/utils/kernel.rb @@ -93,7 +93,7 @@ module Kernel # rubocop:disable Metrics/ModuleLength # response = Response.new(200, {}, 'hello') # Hanami::Utils::Kernel.Array(response) # => [200, {}, "hello"] def self.Array(arg) - super(arg).dup.tap do |a| + super.dup.tap do |a| a.flatten! a.compact! a.uniq! @@ -215,7 +215,7 @@ def self.Hash(arg) if arg.respond_to?(:to_h) arg.to_h else - super(arg) + super end rescue NoMethodError raise TypeError.new "can't convert #{inspect_type_error(arg)}into Hash" @@ -329,7 +329,7 @@ def self.Hash(arg) # input = Complex(2, 3) # Hanami::Utils::Kernel.Integer(input) # => TypeError def self.Integer(arg) - super(arg) + super rescue ArgumentError, TypeError, NoMethodError begin case arg @@ -549,7 +549,7 @@ def self.BigDecimal(arg, precision = ::Float::DIG) # input = Complex(2, 3) # Hanami::Utils::Kernel.Float(input) # => TypeError def self.Float(arg) - super(arg) + super rescue ArgumentError, TypeError begin case arg @@ -654,7 +654,7 @@ def self.Float(arg) # Hanami::Utils::Kernel.String(input) # => TypeError def self.String(arg) arg = arg.to_str if arg.respond_to?(:to_str) - super(arg) + super rescue NoMethodError raise TypeError.new "can't convert #{inspect_type_error(arg)}into String" end diff --git a/spec/unit/hanami/utils/string_spec.rb b/spec/unit/hanami/utils/string_spec.rb index 3f4b3f7c..f1cd5db0 100644 --- a/spec/unit/hanami/utils/string_spec.rb +++ b/spec/unit/hanami/utils/string_spec.rb @@ -24,7 +24,7 @@ it "applies transformations from proc" do input = "Hanami" - actual = Hanami::Utils::String.transform(input, ->(i) { i.upcase }) + actual = Hanami::Utils::String.transform(input, ->(i) { i.upcase }) # rubocop:disable Style/SymbolProc expect(input).to eq("Hanami") expect(actual).to eq("HANAMI")