Add and apply ShadowingOuterLocalVariable rule

Naming two variables the same way is confusing at the very least, and
can lead to hard to debug errors. That's why the Ruby interpreter issues
a warning when we do so.
This commit is contained in:
Javi Martín
2019-09-28 21:09:56 +02:00
parent 70a07c095f
commit d6eb9f8fb6
4 changed files with 15 additions and 13 deletions

View File

@@ -120,6 +120,9 @@ Layout/TrailingWhitespace:
Lint/LiteralAsCondition:
Enabled: true
Lint/ShadowingOuterLocalVariable:
Enabled: true
Lint/UselessAssignment:
Enabled: true

View File

@@ -58,14 +58,13 @@ class Tracking::BudgetInvestmentsController < Tracking::BaseController
}
]
filters = investment_headings.inject(all_headings_filter) do |filters, heading|
investment_headings.inject(all_headings_filter) do |filters, heading|
filters << {
name: heading.name,
id: heading.id,
count: investments.select { |i| i.heading_id == heading.id }.size
}
end
filters.uniq
end.uniq
end
def restrict_access_to_assigned_items

View File

@@ -222,10 +222,10 @@ section "Creating Poll Questions from Proposals" do
poll = Poll.current.first
question = Poll::Question.new(poll: poll)
question.copy_attributes_from_proposal(proposal)
title = question.title
question_title = question.title
I18n.available_locales.map do |locale|
Globalize.with_locale(locale) do
question.title = "#{title} (#{locale})"
question.title = "#{question_title} (#{locale})"
end
end
question.save!
@@ -252,10 +252,10 @@ section "Creating Successful Proposals" do
poll = Poll.current.first
question = Poll::Question.new(poll: poll)
question.copy_attributes_from_proposal(proposal)
title = question.title
question_title = question.title
I18n.available_locales.map do |locale|
Globalize.with_locale(locale) do
question.title = "#{title} (#{locale})"
question.title = "#{question_title} (#{locale})"
end
end
question.save!

View File

@@ -1773,8 +1773,8 @@ describe "Admin budget investments" do
visit admin_budget_budget_investments_path(budget)
cookies = page.driver.browser.manage.all_cookies
cookie = cookies.find { |cookie| cookie[:name] == "investments-columns" }
cookie_value = cookie[:value]
columns_cookie = cookies.find { |cookie| cookie[:name] == "investments-columns" }
cookie_value = columns_cookie[:value]
expect(cookie_value).to eq("id,title,supports,admin,valuator,geozone," +
"feasibility,price,valuation_finished,visible_to_valuators,selected,incompatible")
@@ -1827,8 +1827,8 @@ describe "Admin budget investments" do
end
cookies = page.driver.browser.manage.all_cookies
cookie = cookies.find { |cookie| cookie[:name] == "investments-columns" }
cookie_value = cookie[:value]
columns_cookie = cookies.find { |cookie| cookie[:name] == "investments-columns" }
cookie_value = columns_cookie[:value]
expect(cookie_value).to eq("id,supports,admin,geozone," +
"feasibility,valuation_finished,visible_to_valuators,selected,incompatible,author")
@@ -1836,8 +1836,8 @@ describe "Admin budget investments" do
visit admin_budget_budget_investments_path(budget)
cookies = page.driver.browser.manage.all_cookies
cookie = cookies.find { |cookie| cookie[:name] == "investments-columns" }
cookie_value = cookie[:value]
columns_cookie = cookies.find { |cookie| cookie[:name] == "investments-columns" }
cookie_value = columns_cookie[:value]
expect(cookie_value).to eq("id,supports,admin,geozone,feasibility,valuation_finished," +
"visible_to_valuators,selected,incompatible,author")