From 469b39ffa37d2068bc7b7b2eba8ac4c5894f686e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Mon, 9 Aug 2021 19:26:32 +0200 Subject: [PATCH] Add and apply Style/RedundantInterpolation rule Somehow I thought we already had this rule; must have forgotten to actually add it. --- .rubocop.yml | 3 +++ app/helpers/milestones_helper.rb | 2 +- config/initializers/i18n_pluralize.rb | 2 +- spec/mailers/dashboard/mailer_spec.rb | 12 ++++++------ spec/shared/system/relationable.rb | 4 ++-- spec/system/admin/poll/polls_spec.rb | 2 +- spec/system/admin/users_spec.rb | 4 ++-- spec/system/budget_polls/ballot_sheets_spec.rb | 8 ++++---- spec/system/legislation/processes_spec.rb | 2 +- 9 files changed, 21 insertions(+), 18 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 2a0845b42..26a1f499a 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -464,6 +464,9 @@ Style/RedundantFileExtensionInRequire: Style/RedundantFreeze: Enabled: true +Style/RedundantInterpolation: + Enabled: true + Style/RedundantReturn: Enabled: true diff --git a/app/helpers/milestones_helper.rb b/app/helpers/milestones_helper.rb index aa4883a7f..888955e4e 100644 --- a/app/helpers/milestones_helper.rb +++ b/app/helpers/milestones_helper.rb @@ -4,7 +4,7 @@ module MilestonesHelper tag.div class: "progress", role: "progressbar", - "aria-valuenow": "#{progress_bar.percentage}", + "aria-valuenow": progress_bar.percentage, "aria-valuetext": "#{progress_bar.percentage}%", "aria-valuemax": ProgressBar::RANGE.max, "aria-valuemin": "0", diff --git a/config/initializers/i18n_pluralize.rb b/config/initializers/i18n_pluralize.rb index 240310a2c..71415d49e 100644 --- a/config/initializers/i18n_pluralize.rb +++ b/config/initializers/i18n_pluralize.rb @@ -9,7 +9,7 @@ module I18n return entry unless entry.is_a?(Hash) && count key = pluralization_key(entry, count) - return "#{count}" unless entry.has_key?(key) + return count.to_s unless entry.has_key?(key) entry[key] end diff --git a/spec/mailers/dashboard/mailer_spec.rb b/spec/mailers/dashboard/mailer_spec.rb index 5c9315b6a..7a2d2a3b2 100644 --- a/spec/mailers/dashboard/mailer_spec.rb +++ b/spec/mailers/dashboard/mailer_spec.rb @@ -90,10 +90,10 @@ describe Dashboard::Mailer do expect(email).to have_body_text("And to accompany you in this challenge, "\ "here are the news...") expect(email).to have_body_text("NEW UNLOCKED RESOURCE") - expect(email).to have_body_text("#{resource.title}") + expect(email).to have_body_text(resource.title) expect(email).to have_body_text("Take a look at this NEW recommended ACTION:") - expect(email).to have_body_text("#{action.title}") - expect(email).to have_body_text("#{action.description}") + expect(email).to have_body_text(action.title) + expect(email).to have_body_text(action.description) expect(email).to have_body_text("As always, enter the Proposals Panel and we will tell "\ "you in detail how to use these resources and how to get "\ "the most out of it.") @@ -128,7 +128,7 @@ describe Dashboard::Mailer do expect(email).to have_body_text("And so, you have a new resource available to help "\ "you keep moving forward.") expect(email).to have_body_text("NEW UNLOCKED RESOURCE") - expect(email).to have_body_text("#{resource.title}") + expect(email).to have_body_text(resource.title) months_to_archive_proposals = Setting["months_to_archive_proposals"].to_i.months limit_to_archive_proposal = proposal.created_at.to_date + months_to_archive_proposals @@ -139,8 +139,8 @@ describe Dashboard::Mailer do "supports and goes to referendum. Cheer up and keep "\ "spreading. Are you short of ideas?") expect(email).to have_body_text("NEW RECOMMENDED DIFFUSION ACTION") - expect(email).to have_body_text("#{action.title}") - expect(email).to have_body_text("#{action.description}") + expect(email).to have_body_text(action.title) + expect(email).to have_body_text(action.description) expect(email).to have_body_text("As always, enter the Proposals Panel and we will tell "\ "you in detail how to use these resources and how to get "\ "the most out of it.") diff --git a/spec/shared/system/relationable.rb b/spec/shared/system/relationable.rb index f2a07da85..7932f46bb 100644 --- a/spec/shared/system/relationable.rb +++ b/spec/shared/system/relationable.rb @@ -36,7 +36,7 @@ shared_examples "relationable" do |relationable_model_name| expect(page).to have_css ".add-related-content[aria-expanded='true']" within("#related_content") do - fill_in "Link to related content", with: "#{url + related1.url}" + fill_in "Link to related content", with: "#{url}#{related1.url}" click_button "Add" end @@ -53,7 +53,7 @@ shared_examples "relationable" do |relationable_model_name| click_button "Add related content" within("#related_content") do - fill_in "Link to related content", with: "#{url + related2.url}" + fill_in "Link to related content", with: "#{url}#{related2.url}" click_button "Add" end diff --git a/spec/system/admin/poll/polls_spec.rb b/spec/system/admin/poll/polls_spec.rb index 2e0ad9f77..cc762e41a 100644 --- a/spec/system/admin/poll/polls_spec.rb +++ b/spec/system/admin/poll/polls_spec.rb @@ -293,7 +293,7 @@ describe "Admin polls", :admin do within("#totals") do within("#total_final") do - expect(page).to have_content("#{55555 + 63}") + expect(page).to have_content(55555 + 63) end within("#total_system") do diff --git a/spec/system/admin/users_spec.rb b/spec/system/admin/users_spec.rb index a63b8fda0..22fd13272 100644 --- a/spec/system/admin/users_spec.rb +++ b/spec/system/admin/users_spec.rb @@ -29,13 +29,13 @@ describe "Admin users" do visit admin_users_path - expect(page).not_to have_link("#{erased_user.id}", href: user_path(erased_user)) + expect(page).not_to have_link(erased_user.id.to_s, href: user_path(erased_user)) expect(page).to have_link("Erased") click_link "Erased" expect(page).to have_link("Active") - expect(page).to have_link("#{erased_user.id}", href: user_path(erased_user)) + expect(page).to have_link(erased_user.id.to_s, href: user_path(erased_user)) expect(page).to have_content "I don't like this site." expect(page).to have_content("Erased") diff --git a/spec/system/budget_polls/ballot_sheets_spec.rb b/spec/system/budget_polls/ballot_sheets_spec.rb index 3526b4adc..91c6aab56 100644 --- a/spec/system/budget_polls/ballot_sheets_spec.rb +++ b/spec/system/budget_polls/ballot_sheets_spec.rb @@ -26,7 +26,7 @@ describe "Poll budget ballot sheets" do end within("#poll_#{poll.id}") do - expect(page).to have_content("#{poll.name}") + expect(page).to have_content(poll.name) expect(page).to have_content("See ballot sheets list") expect(page).to have_content("Add results") end @@ -51,7 +51,7 @@ describe "Poll budget ballot sheets" do visit officing_poll_ballot_sheets_path(poll) - expect(page).to have_content "#{poll.name}" + expect(page).to have_content poll.name end scenario "Access ballot sheets officing with multiple booth assignments", :with_frozen_time do @@ -103,7 +103,7 @@ describe "Poll budget ballot sheets" do scenario "Ballot sheet is saved" do visit new_officing_poll_ballot_sheet_path(poll) - select "#{booth.name}", from: "officer_assignment_id" + select booth.name, from: "officer_assignment_id" fill_in "data", with: "1234;5678" click_button "Save" @@ -119,7 +119,7 @@ describe "Poll budget ballot sheets" do scenario "Ballot sheet is not saved" do visit new_officing_poll_ballot_sheet_path(poll) - select "#{booth.name}", from: "officer_assignment_id" + select booth.name, from: "officer_assignment_id" click_button "Save" expect(page).to have_content("CSV data can't be blank") diff --git a/spec/system/legislation/processes_spec.rb b/spec/system/legislation/processes_spec.rb index acef919fd..5eccacfa5 100644 --- a/spec/system/legislation/processes_spec.rb +++ b/spec/system/legislation/processes_spec.rb @@ -155,7 +155,7 @@ describe "Legislation" do phases.each do |phase| within(".legislation-process-list") do - find("li", text: "#{phase}").click_link + find("li", text: phase).click_link end expect(page).to have_content(document.title)