From 782937b1d940acd6e58405d3a68dfb2911e9e31d Mon Sep 17 00:00:00 2001 From: Chaitanya Date: Tue, 28 Mar 2017 14:42:21 +0530 Subject: [PATCH] Enable Style/ZeroLengthPredicate Rubocop cop This cop checks for numeric comparisons that can be replaced by a predicate method. It supports autocorrection, so all the offenses where automatically solved. Closes #1416 --- .rubocop.yml | 4 ++++ .rubocop_todo.yml | 5 ----- app/models/conference.rb | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index ca819d9d..bf158032 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -92,6 +92,10 @@ Style/TrailingBlankLines: Style/TrailingWhitespace: Enabled: true +#This cop checks for numeric comparisons that can be replaced by a predicate method. +Style/ZeroLengthPredicate: + Enabled: true + #################### Metrics ############################### # Avoid deep blocks nesting diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 47e50eb9..a0487443 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -680,8 +680,3 @@ Style/UnneededInterpolation: Style/WordArray: EnforcedStyle: percent MinSize: 3 - -# Offense count: 1 -Style/ZeroLengthPredicate: - Exclude: - - 'app/models/conference.rb' diff --git a/app/models/conference.rb b/app/models/conference.rb index 5b868ca9..1d549ec7 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -464,7 +464,7 @@ class Conference < ActiveRecord::Base result = Conference.where('start_date > ?', Time.now). select('id, short_title, color, start_date') - if result.length == 0 + if result.empty? result = Conference. select('id, short_title, color, start_date').limit(2). order(start_date: :desc)