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
Rails/Present:
Enabled: true
Exclude:
# `present?` is defined as `!blank?` wihin this file
- "Homebrew/extend/blank.rb"
Rails/RelativeDateConstant:
Enabled: true
Rails/SafeNavigation:

View File

@ -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