From 250b19b0d38cfcdb73d5f705aefc091ce45c938e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Tue, 18 Dec 2018 20:34:29 +0100 Subject: [PATCH 1/2] Remove literal used in condition The right syntax would have been: `after_save :recalculate_heading_winners, if: :incompatible_changed?` However, since the method `recalculate_heading_winners` already executes the `if incompatible_changed?` condition, removing it keeps the intended behaviour. --- app/models/budget/investment.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/budget/investment.rb b/app/models/budget/investment.rb index f4ea4b090f3..0b4a9ddbacf 100644 --- a/app/models/budget/investment.rb +++ b/app/models/budget/investment.rb @@ -95,7 +95,7 @@ class Investment < ActiveRecord::Base scope :for_render, -> { includes(:heading) } before_save :calculate_confidence_score - after_save :recalculate_heading_winners if :incompatible_changed? + after_save :recalculate_heading_winners before_validation :set_responsible_name before_validation :set_denormalized_ids From e11b9ddccd6adaf25a1dbcb380105f02b72479f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Tue, 18 Dec 2018 20:38:36 +0100 Subject: [PATCH 2/2] Enable literal as condition rule in rubocop This way deverlopers who don't run the ruby syntax check locally with warnings enabled will be informed by HoundCI. --- .rubocop_basic.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.rubocop_basic.yml b/.rubocop_basic.yml index 522fec8285d..97a02fd21a5 100644 --- a/.rubocop_basic.yml +++ b/.rubocop_basic.yml @@ -30,6 +30,9 @@ Layout/TrailingBlankLines: Layout/TrailingWhitespace: Enabled: true +Lint/LiteralAsCondition: + Enabled: true + Lint/UselessAssignment: Enabled: true