context'the same object uses exists? and present?'do
it'flags it as an offense'do
expect_offense<<~SOURCE
return unless @users.exists?
show @users if @users.present?
^^^^^^^^^^^^^^^ Avoid `@users.present?`, because it will generate database query 'Select TABLE.*' which is expensive. Suggest to use `@users.any?` to replace `@users.present?`
context'the same object uses exists? and blank?'do
it'flags it as an offense'do
expect_offense<<~SOURCE
return unless @users.exists?
show @users if @users.blank?
^^^^^^^^^^^^^ Avoid `@users.blank?`, because it will generate database query 'Select TABLE.*' which is expensive. Suggest to use `@users.empty?` to replace `@users.blank?`
context'the same object uses exists?, blank? and present?'do
it'flags it as an offense'do
expect_offense<<~SOURCE
return unless @users.exists?
show @users if @users.blank?
^^^^^^^^^^^^^ Avoid `@users.blank?`, because it will generate database query 'Select TABLE.*' which is expensive. Suggest to use `@users.empty?` to replace `@users.blank?`
show @users if @users.present?
^^^^^^^^^^^^^^^ Avoid `@users.present?`, because it will generate database query 'Select TABLE.*' which is expensive. Suggest to use `@users.any?` to replace `@users.present?`