Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply Rubocop rules in ERB files #4102

Merged
merged 16 commits into from
Feb 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 15 additions & 26 deletions .erb-lint.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
---
linters:
ClosingErbTagIndent:
enabled: true
ErbSafety:
enabled: true
ExtraNewline:
enabled: true
FinalNewline:
enabled: true
NoJavascriptTagHelper:
enabled: true
SelfClosingTag:
enabled: false
SpaceAroundErbTag:
Expand All @@ -18,29 +22,14 @@ linters:
enabled: true
Rubocop:
enabled: true
only:
- Layout/EndOfLine
- Layout/SpaceAfterColon
- Layout/SpaceAfterComma
- Layout/SpaceAfterMethodName
- Layout/SpaceAfterNot
- Layout/SpaceAfterSemicolon
- Layout/SpaceAroundBlockParameters
- Layout/SpaceAroundOperators
- Layout/SpaceBeforeBlockBraces
- Layout/SpaceBeforeComma
- Layout/SpaceBeforeComment
- Layout/SpaceBeforeFirstArg
- Layout/SpaceBeforeSemicolon
- Layout/SpaceInsideArrayLiteralBrackets
- Layout/SpaceInsideArrayPercentLiteral
- Layout/SpaceInsideBlockBraces
- Layout/SpaceInsideHashLiteralBraces
- Layout/SpaceInsideParens
- Layout/SpaceInsidePercentLiteralDelimiters
- Layout/SpaceInsideRangeLiteral
- Layout/SpaceInsideReferenceBrackets
- Layout/SpaceInsideStringInterpolation
- Layout/Tab
- Lint/LiteralAsCondition
- Style/PercentLiteralDelimiters
rubocop_config:
inherit_from:
- .rubocop.yml
Layout/LineLength:
Enabled: false
Layout/TrailingEmptyLines:
Enabled: false
Lint/UselessAssignment:
Enabled: false
Rails/OutputSafety:
Enabled: false
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ group :development do
gem "capistrano-rails", "~> 1.6.1", require: false
gem "capistrano3-delayed-job", "~> 1.7.6"
gem "capistrano3-puma", "~> 4.0.0"
gem "erb_lint", require: false
gem "erb_lint", "~> 0.0.35", require: false
gem "github_changelog_generator", "~> 1.15.2"
gem "mdl", "~> 0.11.0", require: false
gem "rubocop", "~> 0.91.0", require: false
Expand Down
11 changes: 6 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ GEM
babel-source (>= 4.0, < 6)
execjs (~> 2.0)
bcrypt (3.1.16)
better_html (1.0.13)
better_html (1.0.15)
actionview (>= 4.0)
activesupport (>= 4.0)
ast (~> 2.0)
Expand Down Expand Up @@ -208,12 +208,13 @@ GEM
htmlentities (~> 4.3.3)
launchy (~> 2.1)
mail (~> 2.7)
erb_lint (0.0.28)
erb_lint (0.0.35)
activesupport
better_html (~> 1.0.7)
html_tokenizer
parser (>= 2.7.1.4)
rainbow
rubocop (~> 0.51)
rubocop (~> 0.79)
smart_properties
errbase (0.0.3)
erubi (1.9.0)
Expand Down Expand Up @@ -555,7 +556,7 @@ GEM
simplecov-html (0.10.2)
sitemap_generator (6.1.2)
builder (~> 3.0)
smart_properties (1.13.1)
smart_properties (1.15.0)
social-share-button (1.1.0)
coffee-rails
socksify (1.7.1)
Expand Down Expand Up @@ -670,7 +671,7 @@ DEPENDENCIES
devise-async (~> 1.0.0)
devise-security (~> 0.11.1)
email_spec (~> 2.2.0)
erb_lint
erb_lint (~> 0.0.35)
factory_bot_rails (~> 4.8.2)
faker (~> 1.8.7)
font-awesome-sass (~> 5.15.1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def edit_heading_content_block
if @content_block.is_a? Budget::ContentBlock
@selected_content_block = "hcb_#{@content_block.heading_id}"
else
@selected_content_block = @content_block.heading.name
@selected_content_block = @content_block.name
end
@is_heading_content_block = true
render :edit
Expand Down
1 change: 1 addition & 0 deletions app/models/budget/content_block.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ class ContentBlock < ApplicationRecord
validates :heading, presence: true, uniqueness: { scope: :locale }

belongs_to :heading
delegate :name, to: :heading, allow_nil: true
end
end
2 changes: 1 addition & 1 deletion app/views/admin/budget_investments/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@

<div class="small-12 medium-6">
<%= f.select(:administrator_id,
@admins.collect { |a| [a.description_or_name_and_email, a.id] },
@admins.map { |a| [a.description_or_name_and_email, a.id] },
{ include_blank: t("admin.budget_investments.edit.undefined") }) %>
</div>
</div>
Expand Down
6 changes: 3 additions & 3 deletions app/views/admin/budget_investments/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<h2 id="classification"><%= t("admin.budget_investments.show.classification") %></h2>

<p><strong><%= t("admin.budget_investments.show.assigned_admin") %>:</strong>
<%= @investment.administrator.try(:name_and_email) || t("admin.budget_investments.show.undefined") %>
<%= @investment.administrator&.name_and_email || t("admin.budget_investments.show.undefined") %>
</p>

<p id="tags">
Expand All @@ -37,7 +37,7 @@
<p id="assigned_valuator_groups">
<strong><%= t("admin.budget_investments.show.valuator_groups") %>:</strong>
<% if @investment.valuator_groups.any? %>
<%= @investment.valuator_groups.collect(&:name).join(", ") %>
<%= @investment.valuator_groups.map(&:name).join(", ") %>
<% else %>
<%= t("admin.budget_investments.show.undefined") %>
<% end %>
Expand All @@ -46,7 +46,7 @@
<p id="assigned_valuators">
<strong><%= t("admin.budget_investments.show.assigned_valuators") %>:</strong>
<% if @investment.valuators.any? %>
<%= @investment.valuators.collect(&:name_and_email).join(", ") %>
<%= @investment.valuators.map(&:name_and_email).join(", ") %>
<% else %>
<%= t("admin.budget_investments.show.undefined") %>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/hidden_users/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@
<% end %>
</table>

<%= paginate [@debates, @comments].sort_by { |x| x.size }.last %>
<%= paginate [@debates, @comments].sort_by(&:size).last %>
2 changes: 1 addition & 1 deletion app/views/admin/milestones/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<div class="row">
<div class="small-12 medium-6 margin-bottom column">
<%= f.select :status_id,
@statuses.collect { |s| [s.name, s.id] },
@statuses.map { |s| [s.name, s.id] },
{ include_blank: @statuses.any? ? "" : t("admin.milestones.form.no_statuses_defined") },
{ disabled: @statuses.blank? } %>
<%= link_to t("admin.milestones.form.admin_statuses"),
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/organizations/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</thead>
<tbody>
<% @organizations.each do |organization| %>
<% hidden += 1 and next if organization.user.nil? || organization.user.hidden? %>
<% hidden += 1 and next if organization.user.nil? %>
<tr id="<%= dom_id(organization) %>">
<td><%= organization.name %></td>
<td><%= organization.email %></td>
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/settings/_featured_settings_table.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<% if feature.enabled? %>
<span class="enabled">
<strong>
<%= t ("admin.settings.index.features.enabled") %>
<%= t("admin.settings.index.features.enabled") %>
</strong>
</span>
<% else %>
Expand Down
6 changes: 3 additions & 3 deletions app/views/admin/settings/_map_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@

<%= form_tag admin_update_map_path, method: :put, id: "map-form" do |f| %>

<%= hidden_field_tag :latitude, Setting["map.latitude"] %>
<%= hidden_field_tag :longitude, Setting["map.longitude"] %>
<%= hidden_field_tag :zoom, Setting["map.zoom"] %>
<%= hidden_field_tag :latitude, Setting["map.latitude"] %>
<%= hidden_field_tag :longitude, Setting["map.longitude"] %>
<%= hidden_field_tag :zoom, Setting["map.zoom"] %>

<div class="small-12 medium-6 large-4 margin-top">
<%= submit_tag t("admin.settings.index.map.form.submit"),
Expand Down
3 changes: 1 addition & 2 deletions app/views/admin/shared/_budget_investment_search.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
<%= select_tag :heading_id,
options_for_select(budget_heading_select_options(@budget),
params[:heading_id]),
include_blank: true
%>
include_blank: true %>
</div>
</div>
<div class="row">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<% provide :title do %>
<%= t("admin.header.title") %> - <%= t("admin.menu.site_customization.content_blocks") %> - <%= @content_block.try(:name) || @content_block.heading.try(:name) %> (<%= @content_block.locale %>)
<%= t("admin.header.title") %> - <%= t("admin.menu.site_customization.content_blocks") %> - <%= @content_block.name %> (<%= @content_block.locale %>)
<% end %>

<%= back_link_to admin_site_customization_content_blocks_path %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<% end %>
<% @headings_content_blocks.each do |content_block| %>
<tr id="<%= dom_id(content_block) %>">
<td><%= link_to "#{content_block.heading.name} (#{content_block.locale})", admin_site_customization_edit_heading_content_block_path(content_block) %></td>
<td><%= link_to "#{content_block.name} (#{content_block.locale})", admin_site_customization_edit_heading_content_block_path(content_block) %></td>
<td><%= raw content_block.body %></td>
<td>
<%= render Admin::TableActionsComponent.new(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<% information_texts_tabs.each do |tab| %>
<li class="tabs-title">
<% if tab.to_s == @tab %>
<%= link_to t("admin.menu.site_customization.information_texts_menu.#{tab}"), admin_site_customization_information_texts_path(tab: tab), :class => "is-active" %>
<%= link_to t("admin.menu.site_customization.information_texts_menu.#{tab}"), admin_site_customization_information_texts_path(tab: tab), class: "is-active" %>
<% else %>
<%= link_to t("admin.menu.site_customization.information_texts_menu.#{tab}"), admin_site_customization_information_texts_path(tab: tab) %>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/valuators/_valuator_row.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</td>
<td>
<% if valuator.valuator_group.present? %>
<%= valuator.valuator_group.try(:name) %>
<%= valuator.valuator_group&.name %>
<% else %>
<%= t("admin.valuators.index.no_group") %>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/budgets/investments/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<div class="row column">
<div class="small-12 medium-8 column">
<%= f.select :heading_id, budget_heading_select_options(@budget), { include_blank: true, } %>
<%= f.select :heading_id, budget_heading_select_options(@budget), { include_blank: true } %>
</div>
<div class="row">
<div class="small-12 column">
Expand Down
6 changes: 2 additions & 4 deletions app/views/budgets/investments/_investment.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@
<%= render "/budgets/investments/votes",
investment: investment,
investment_votes: investment_votes,
vote_url: namespaced_budget_investment_vote_path(investment, value: "yes")
%>
vote_url: namespaced_budget_investment_vote_path(investment, value: "yes") %>
</div>
<% elsif investment.should_show_vote_count? %>
<div id="<%= dom_id(investment) %>_votes"
Expand All @@ -84,8 +83,7 @@
<%= render "/budgets/investments/ballot",
investment: investment,
investment_ids: investment_ids,
ballot: ballot
%>
ballot: ballot %>
</div>
<% elsif investment.should_show_price? %>
<div id="<%= dom_id(investment) %>_price"
Expand Down
3 changes: 1 addition & 2 deletions app/views/budgets/investments/_investment_show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@
<%= render "/budgets/investments/votes",
investment: investment,
investment_votes: investment_votes,
vote_url: vote_budget_investment_path(investment.budget, investment, value: "yes")
%>
vote_url: vote_budget_investment_path(investment.budget, investment, value: "yes") %>
</div>
</div>
<% elsif investment.should_show_vote_count? %>
Expand Down
3 changes: 1 addition & 2 deletions app/views/budgets/investments/_votes.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@
image_url: image_absolute_url(investment.image, :thumb),
url: budget_investment_url(investment.budget, investment),
description: investment.title,
mobile: investment.title
%>
mobile: investment.title %>
</div>
<% end %>
</div>
3 changes: 1 addition & 2 deletions app/views/budgets/investments/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
investment: @investment,
investment_ids: @investment_ids,
investment_votes: @investment_votes,
ballot: @ballot
%>
ballot: @ballot %>

<div class="row">
<div class="small-12 column">
Expand Down
3 changes: 1 addition & 2 deletions app/views/debates/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@
title: @debate.title,
url: debate_url(@debate),
description: @debate.title,
mobile: @debate.title
%>
mobile: @debate.title %>
</aside>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/views/devise/password_expired/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<h2><%= t("devise.password_expired.expire_password") %></h2>

<%= form_for(resource, :as => resource_name, :url => [resource_name, :password_expired], :html => { :method => :put }) do |f| %>
<%= form_for(resource, as: resource_name, url: [resource_name, :password_expired], html: { method: :put }) do |f| %>

<%= f.password_field :current_password %></p>
<%= f.password_field :password, label: t("devise.password_expired.new_password") %></p>
Expand Down
2 changes: 1 addition & 1 deletion app/views/kaminari/_first_page.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<li>
<%= link_to t("views.pagination.first"), url, :remote => remote %>
<%= link_to t("views.pagination.first"), url, remote: remote %>
</li>
2 changes: 1 addition & 1 deletion app/views/kaminari/_last_page.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<li>
<%= link_to t("views.pagination.last"), url, :remote => remote %>
<%= link_to t("views.pagination.last"), url, remote: remote %>
</li>
2 changes: 1 addition & 1 deletion app/views/kaminari/_next_page.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<li class="pagination-next">
<%= link_to t("views.pagination.next"), url, :rel => "next", :remote => remote %>
<%= link_to t("views.pagination.next"), url, rel: "next", remote: remote %>
</li>
2 changes: 1 addition & 1 deletion app/views/kaminari/_page.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
</li>
<% else %>
<li>
<%= link_to page, url, { :remote => remote, :rel => page.next? ? "next" : page.prev? ? "prev" : nil } %>
<%= link_to page, url, { remote: remote, rel: page.next? ? "next" : page.prev? ? "prev" : nil } %>
</li>
<% end %>
2 changes: 1 addition & 1 deletion app/views/kaminari/_prev_page.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<li class="pagination-previous">
<%= link_to t("views.pagination.previous"), url, :rel => "prev", :remote => remote %>
<%= link_to t("views.pagination.previous"), url, rel: "prev", remote: remote %>
</li>
1 change: 0 additions & 1 deletion app/views/layouts/_common_head.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@
<%= javascript_include_tag "application", "data-turbolinks-track" => "reload" %>
<%= csrf_meta_tags %>
<%= favicon_link_tag "favicon.ico" %>
<%= render "layouts/disable_animations_in_tests" if Rails.env.test? %>
8 changes: 0 additions & 8 deletions app/views/layouts/_disable_animations_in_tests.html.erb

This file was deleted.

2 changes: 1 addition & 1 deletion app/views/layouts/_officing_booth.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<% if current_user.poll_officer? %>
<div id="officing-booth" class="callout info">
<%= t("admin.officing_booth.title", booth: try(:current_booth).try(:location)) %>
<%= t("admin.officing_booth.title", booth: try(:current_booth)&.location) %>
</div>
<% end %>
2 changes: 1 addition & 1 deletion app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="<%= I18n.locale %>" data-current-user-id="<%= current_user.try(:id) %>">
<html lang="<%= I18n.locale %>" data-current-user-id="<%= current_user&.id %>">
<head>
<%= render "layouts/common_head", default_title: setting["org_name"] %>
<%= render "layouts/tracking_data" %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/dashboard.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="<%= I18n.locale %>" data-current-user-id="<%= current_user.try(:id) %>">
<html lang="<%= I18n.locale %>" data-current-user-id="<%= current_user&.id %>">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
<h2><%= t("legislation.shared.share") %></h2>
<%= render "/shared/social_share",
title: t("legislation.shared.share_comment", version_name: @draft_version.title.downcase, process_name: @process.title),
url: legislation_process_draft_version_path(process, draft_version)
%>
url: legislation_process_draft_version_path(process, draft_version) %>
</aside>
</div>
Loading