Skip to content

Fix Violations of and Reenable Rails/Blank - #48015

Merged
Hamms merged 2 commits into
stagingfrom
fix-Rails/Blank
Sep 9, 2022
Merged

Fix Violations of and Reenable Rails/Blank#48015
Hamms merged 2 commits into
stagingfrom
fix-Rails/Blank

Conversation

@Hamms

@Hamms Hamms commented Sep 8, 2022

Copy link
Copy Markdown
Contributor

Quoting from the documentation (docs.rubocop.org, rubydoc.info):

Checks for code that can be written with simpler conditionals using Object#blank? defined by Active Support.

There is certainly an argument to be made that there are situations in which !foo.present? and something unless foo.present? can be more readable than foo.blank? and something if foo.blank?, depending on the specific variable names involved, but I think they're rare enough that the consistency we gain by enabling this rule is worth it.

PR Checklist:

  • Tests provide adequate coverage
  • Privacy and Security impacts have been assessed
  • Code is well-commented
  • New features are translatable or updates will not break translations
  • Relevant documentation has been added or updated
  • User impact is well-understood and desirable
  • Pull Request is labeled appropriately
  • Follow-up work items (including potential tech debt) are tracked and linked

Quoting from the documentation ([docs.rubocop.org](https://docs.rubocop.org/rubocop-rails/cops_rails.html#railsblank), [rubydoc.info](https://www.rubydoc.info/gems/rubocop-rails/RuboCop/Cop/Rails/Blank)):

> Checks for code that can be written with simpler conditionals using `Object#blank?` defined by Active Support.

There is certainly an argument to be made that there are situations in which `!foo.present?` and `something unless foo.present?` can be more readable than `foo.blank?` and `something if foo.blank?`, depending on the specific variable names involved, but I think they're rare enough that the consistency we gain by enabling this rule is worth it.
@Hamms
Hamms requested review from a team September 8, 2022 20:16
@Hamms
Hamms merged commit 4e9dbed into staging Sep 9, 2022
@Hamms
Hamms deleted the fix-Rails/Blank branch September 9, 2022 22:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants