Skip to content

Latest commit

 

History

History
53 lines (38 loc) · 989 Bytes

Rails-Present.md

File metadata and controls

53 lines (38 loc) · 989 Bytes

Pattern: Missing use of present?

Issue: -

Description

This rule checks for code that can be changed to present?.

Settings: NotNilAndNotEmpty: Convert checks for not nil and not empty? to present? NotBlank: Convert usages of not blank? to present? UnlessBlank: Convert usages of unless blank? to if present?

Examples

# NotNilAndNotEmpty: true
  # bad
  !foo.nil? && !foo.empty?
  foo != nil && !foo.empty?
  !foo.blank?

  # good
  foo.present?

# NotBlank: true
  # bad
  !foo.blank?
  not foo.blank?

  # good
  foo.present?

# UnlessBlank: true
  # bad
  something unless foo.blank?

  # good
  something if  foo.present?

Default configuration

Attribute Value
NotNilAndNotEmpty true
NotBlank true
UnlessBlank true

Further Reading