From 3f91e920f652f40337d8d3bb1d8f9b8a04bccf10 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Sat, 10 Feb 2018 21:26:02 +0100 Subject: [PATCH] Enable rubocop Performance/RedundantMatch cop & fix issues Some cop offenses have been stashed into rubocop_todo.yml for now --- .rubocop.yml | 3 +++ .rubocop_todo.yml | 9 ++++++++- app/helpers/embed_videos_helper.rb | 4 ++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 00acb14ea..0cf7bafb6 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -85,6 +85,9 @@ Performance/RangeInclude: Performance/RedundantBlockCall: Enabled: true +Performance/RedundantMatch: + Enabled: true + Performance/RedundantMerge: Enabled: true diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index f291eb538..f3a40d8ab 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2018-02-10 21:08:01 +0100 using RuboCop version 0.52.1. +# on 2018-02-10 21:25:09 +0100 using RuboCop version 0.52.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -23,6 +23,13 @@ Layout/IndentationConsistency: Metrics/LineLength: Max: 248 +# Offense count: 4 +# Cop supports --auto-correct. +Performance/RedundantMatch: + Exclude: + - 'app/controllers/valuation/budget_investments_controller.rb' + - 'app/controllers/valuation/spending_proposals_controller.rb' + # Offense count: 11 RSpec/DescribeClass: Exclude: diff --git a/app/helpers/embed_videos_helper.rb b/app/helpers/embed_videos_helper.rb index f1750bf8b..823659cca 100644 --- a/app/helpers/embed_videos_helper.rb +++ b/app/helpers/embed_videos_helper.rb @@ -6,9 +6,9 @@ module EmbedVideosHelper def embedded_video_code link = @proposal.video_url title = t('proposals.show.embed_video_title', proposal: @proposal.title) - if link.match(/vimeo.*/) + if link =~ /vimeo.*/ server = "Vimeo" - elsif link.match(/youtu*.*/) + elsif link =~ /youtu*.*/ server = "YouTube" end