From c36fafbcf204b26e202d7caac21e3c5600be743d Mon Sep 17 00:00:00 2001 From: Douglas Eichelberger Date: Sun, 26 Nov 2023 10:10:43 -0800 Subject: [PATCH] Style fixes --- Library/.rubocop.yml | 3 +++ Library/Homebrew/extend/blank.rb | 10 +++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Library/.rubocop.yml b/Library/.rubocop.yml index 6d47f3fad6..815fe39c7d 100644 --- a/Library/.rubocop.yml +++ b/Library/.rubocop.yml @@ -232,6 +232,9 @@ Rails/Presence: Enabled: true Rails/Present: Enabled: true + Exclude: + # `present?` is defined as `!blank?` wihin this file + - "Homebrew/extend/blank.rb" Rails/RelativeDateConstant: Enabled: true Rails/SafeNavigation: diff --git a/Library/Homebrew/extend/blank.rb b/Library/Homebrew/extend/blank.rb index f9c9a2b2dc..735af26276 100644 --- a/Library/Homebrew/extend/blank.rb +++ b/Library/Homebrew/extend/blank.rb @@ -95,7 +95,7 @@ class Array # [1,2,3].blank? # => false # # @return [true, false] - alias_method :blank?, :empty? + alias blank? empty? sig { returns(T::Boolean) } def present? # :nodoc: @@ -110,7 +110,7 @@ class Hash # { key: 'value' }.blank? # => false # # @return [true, false] - alias_method :blank?, :empty? + alias blank? empty? sig { returns(T::Boolean) } def present? # :nodoc: @@ -123,7 +123,7 @@ class Symbol # # :''.blank? # => true # :symbol.blank? # => false - alias_method :blank?, :empty? + alias blank? empty? sig { returns(T::Boolean) } def present? # :nodoc: @@ -132,7 +132,7 @@ class Symbol end class String - BLANK_RE = /\A[[:space:]]*\z/ + BLANK_RE = /\A[[:space:]]*\z/.freeze # A string is blank if it's empty or contains whitespaces only: # @@ -153,7 +153,7 @@ class String begin BLANK_RE.match?(self) rescue Encoding::CompatibilityError - Regexp.new(BLANK_RE.source.encode(self.encoding), BLANK_RE.options | Regexp::FIXEDENCODING).match?(self) + Regexp.new(BLANK_RE.source.encode(encoding), BLANK_RE.options | Regexp::FIXEDENCODING).match?(self) end end