From 0be6eb9512c995fe42698763926fb08d59d359fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Wed, 11 Aug 2021 15:06:25 +0200 Subject: [PATCH] Add and apply Style/RedundantParentheses rule Parentheses make the code harder to read in these cases. --- .rubocop.yml | 3 +++ app/controllers/legislation/processes_controller.rb | 4 ++-- app/helpers/users_helper.rb | 2 +- app/models/concerns/measurable.rb | 4 ++-- app/views/layouts/application.html.erb | 4 ++-- app/views/legislation/processes/_help_gif.html.erb | 2 +- app/views/pages/help/_menu.html.erb | 12 +++++------- 7 files changed, 16 insertions(+), 15 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index a25d82f05..499ba7224 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -493,6 +493,9 @@ Style/RedundantFreeze: Style/RedundantInterpolation: Enabled: true +Style/RedundantParentheses: + Enabled: true + Style/RedundantReturn: Enabled: true diff --git a/app/controllers/legislation/processes_controller.rb b/app/controllers/legislation/processes_controller.rb index 98354db49..9de10b5bc 100644 --- a/app/controllers/legislation/processes_controller.rb +++ b/app/controllers/legislation/processes_controller.rb @@ -35,7 +35,7 @@ class Legislation::ProcessesController < Legislation::BaseController set_process @phase = :debate_phase - if @process.debate_phase.started? || (current_user&.administrator?) + if @process.debate_phase.started? || current_user&.administrator? render :debate else render :phase_not_open @@ -123,7 +123,7 @@ class Legislation::ProcessesController < Legislation::BaseController @proposals = @proposals.send(@current_filter).page(params[:page]) end - if @process.proposals_phase.started? || (current_user&.administrator?) + if @process.proposals_phase.started? || current_user&.administrator? legislation_proposal_votes(@proposals) render :proposals else diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index 29e91cc6e..90bcc7f30 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -62,7 +62,7 @@ module UsersHelper def show_admin_menu?(user = nil) unless namespace == "officing" current_administrator? || current_moderator? || current_valuator? || current_manager? || - (user&.administrator?) || current_poll_officer? || current_sdg_manager? + user&.administrator? || current_poll_officer? || current_sdg_manager? end end diff --git a/app/models/concerns/measurable.rb b/app/models/concerns/measurable.rb index f3b83c536..c3791fbae 100644 --- a/app/models/concerns/measurable.rb +++ b/app/models/concerns/measurable.rb @@ -3,11 +3,11 @@ module Measurable class_methods do def title_max_length - @title_max_length ||= (columns.find { |c| c.name == "title" }&.limit) || 80 + @title_max_length ||= columns.find { |c| c.name == "title" }&.limit || 80 end def responsible_name_max_length - @responsible_name_max_length ||= (columns.find { |c| c.name == "responsible_name" }&.limit) || 60 + @responsible_name_max_length ||= columns.find { |c| c.name == "responsible_name" }&.limit || 60 end def question_max_length diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 18bc7f78c..6cc32f447 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -13,10 +13,10 @@ <%= raw setting["html.per_page_code_head"] %> - + <%= raw setting["html.per_page_code_body"] %> -
+
<%= render "layouts/header", with_subnavigation: true %> <% if request.headers["User-Agent"] =~ /MSIE/ && cookies["ie_alert_closed"] != "true" %> diff --git a/app/views/legislation/processes/_help_gif.html.erb b/app/views/legislation/processes/_help_gif.html.erb index 4481623d5..d8419b8bf 100644 --- a/app/views/legislation/processes/_help_gif.html.erb +++ b/app/views/legislation/processes/_help_gif.html.erb @@ -16,7 +16,7 @@

<% end %> - <%= image_tag ("annotator_help.gif"), alt: t("annotator.help.alt") %> + <%= image_tag "annotator_help.gif", alt: t("annotator.help.alt") %>
diff --git a/app/views/pages/help/_menu.html.erb b/app/views/pages/help/_menu.html.erb index c56a2eb42..5391b3c82 100644 --- a/app/views/pages/help/_menu.html.erb +++ b/app/views/pages/help/_menu.html.erb @@ -29,13 +29,11 @@ class: "button hollow expanded" ] if feature?(:polls) ), - ( - [ - t("pages.help.menu.processes"), - "#processes", - class: "button hollow expanded" - ] - ), + [ + t("pages.help.menu.processes"), + "#processes", + class: "button hollow expanded" + ], [ t("pages.help.menu.other"), "#other",