Style fixes

This commit is contained in:
Douglas Eichelberger 2023-11-26 10:10:43 -08:00
parent c7c539efa5
commit c36fafbcf2
2 changed files with 8 additions and 5 deletions

View File

@ -232,6 +232,9 @@ Rails/Presence:
Enabled: true Enabled: true
Rails/Present: Rails/Present:
Enabled: true Enabled: true
Exclude:
# `present?` is defined as `!blank?` wihin this file
- "Homebrew/extend/blank.rb"
Rails/RelativeDateConstant: Rails/RelativeDateConstant:
Enabled: true Enabled: true
Rails/SafeNavigation: Rails/SafeNavigation:

View File

@ -95,7 +95,7 @@ class Array
# [1,2,3].blank? # => false # [1,2,3].blank? # => false
# #
# @return [true, false] # @return [true, false]
alias_method :blank?, :empty? alias blank? empty?
sig { returns(T::Boolean) } sig { returns(T::Boolean) }
def present? # :nodoc: def present? # :nodoc:
@ -110,7 +110,7 @@ class Hash
# { key: 'value' }.blank? # => false # { key: 'value' }.blank? # => false
# #
# @return [true, false] # @return [true, false]
alias_method :blank?, :empty? alias blank? empty?
sig { returns(T::Boolean) } sig { returns(T::Boolean) }
def present? # :nodoc: def present? # :nodoc:
@ -123,7 +123,7 @@ class Symbol
# #
# :''.blank? # => true # :''.blank? # => true
# :symbol.blank? # => false # :symbol.blank? # => false
alias_method :blank?, :empty? alias blank? empty?
sig { returns(T::Boolean) } sig { returns(T::Boolean) }
def present? # :nodoc: def present? # :nodoc:
@ -132,7 +132,7 @@ class Symbol
end end
class String 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: # A string is blank if it's empty or contains whitespaces only:
# #
@ -153,7 +153,7 @@ class String
begin begin
BLANK_RE.match?(self) BLANK_RE.match?(self)
rescue Encoding::CompatibilityError 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
end end