Add and apply Naming/PredicateMethod RuboCop 1.76 rule
This rule was introduced in RuboCop 1.76.0 to ensure methods ending in '?' return boolean. This commit applies suggested renames and code cleanup: - Renames 'is_active?' to 'active_class' since it returns a string - Renames 'parsed_value' to 'in_favor?' and 'is_request_active' to end with '?' for boolean semantics - Skips false positives like 'save', 'auto_labels' or 'save_requiring_finish_signup', which are not predicate methods.
This commit is contained in:
@@ -354,6 +354,14 @@ Naming/BlockForwarding:
|
|||||||
- "app/controllers/management/base_controller.rb"
|
- "app/controllers/management/base_controller.rb"
|
||||||
- "app/controllers/subscriptions_controller.rb"
|
- "app/controllers/subscriptions_controller.rb"
|
||||||
|
|
||||||
|
Naming/PredicateMethod:
|
||||||
|
Enabled: true
|
||||||
|
Exclude:
|
||||||
|
- "app/models/local_census_records/import.rb"
|
||||||
|
- "app/models/user.rb"
|
||||||
|
- "app/models/verification/management/email.rb"
|
||||||
|
- "config/initializers/foundation_form_builder.rb"
|
||||||
|
|
||||||
Naming/RescuedExceptionsVariableName:
|
Naming/RescuedExceptionsVariableName:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
<p><%= t("sdg.goals.help.description") %></p>
|
<p><%= t("sdg.goals.help.description") %></p>
|
||||||
<ul class="tabs" id="help_tabs" data-deep-link="true" data-tabs>
|
<ul class="tabs" id="help_tabs" data-deep-link="true" data-tabs>
|
||||||
<% goals.each do |goal| %>
|
<% goals.each do |goal| %>
|
||||||
<li class="tabs-title <%= is_active?(goal) %>">
|
<li class="tabs-title <%= active_class(goal) %>">
|
||||||
<%= link_to "#goal_#{goal.code}_tab" do %>
|
<%= link_to "#goal_#{goal.code}_tab" do %>
|
||||||
<% render SDG::Goals::IconComponent.new(goal) %>
|
<% render SDG::Goals::IconComponent.new(goal) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
<div class="tabs-content" data-tabs-content="help_tabs">
|
<div class="tabs-content" data-tabs-content="help_tabs">
|
||||||
<% goals.each do |goal| %>
|
<% goals.each do |goal| %>
|
||||||
<div id="goal_<%= goal.code %>_tab" class="tabs-panel <%= is_active?(goal) %>">
|
<div id="goal_<%= goal.code %>_tab" class="tabs-panel <%= active_class(goal) %>">
|
||||||
<h2><%= goal.code_and_title %></h2>
|
<h2><%= goal.code_and_title %></h2>
|
||||||
<p><%= sanitize t("sdg.goals.goal_#{goal.code}.description") %></p>
|
<p><%= sanitize t("sdg.goals.goal_#{goal.code}.description") %></p>
|
||||||
<%= render SDG::Goals::TargetsComponent.new(goal) %>
|
<%= render SDG::Goals::TargetsComponent.new(goal) %>
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ class SDG::Goals::HelpPageComponent < ApplicationComponent
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def is_active?(goal)
|
def active_class(goal)
|
||||||
"is-active" if goal.code == 1
|
"is-active" if goal.code == 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -35,14 +35,14 @@ class Shared::VoteButtonComponent < ApplicationComponent
|
|||||||
end
|
end
|
||||||
|
|
||||||
def vote
|
def vote
|
||||||
@vote ||= Vote.find_or_initialize_by(votable: votable, voter: current_user, vote_flag: parsed_value)
|
@vote ||= Vote.find_or_initialize_by(votable: votable, voter: current_user, vote_flag: in_favor?)
|
||||||
end
|
end
|
||||||
|
|
||||||
def already_voted?
|
def already_voted?
|
||||||
vote.persisted?
|
vote.persisted?
|
||||||
end
|
end
|
||||||
|
|
||||||
def parsed_value
|
def in_favor?
|
||||||
value == "yes"
|
value == "yes"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ module ProposalsDashboardHelper
|
|||||||
dashboard_action&.proposed_action?
|
dashboard_action&.proposed_action?
|
||||||
end
|
end
|
||||||
|
|
||||||
def is_request_active(id)
|
def request_active?(id)
|
||||||
controller_name == "dashboard" && action_name == "new_request" && dashboard_action&.id == id
|
controller_name == "dashboard" && action_name == "new_request" && dashboard_action&.id == id
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -72,7 +72,7 @@
|
|||||||
<% resources.each do |resource| %>
|
<% resources.each do |resource| %>
|
||||||
<li>
|
<li>
|
||||||
<%= link_to new_request_proposal_dashboard_action_path(proposal, resource),
|
<%= link_to new_request_proposal_dashboard_action_path(proposal, resource),
|
||||||
class: ("submenu-active" if is_request_active(resource.id)) do %>
|
class: ("submenu-active" if request_active?(resource.id)) do %>
|
||||||
<span data-tooltip title="<%= resource.short_description %>">
|
<span data-tooltip title="<%= resource.short_description %>">
|
||||||
<%= resource.title %>
|
<%= resource.title %>
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
Reference in New Issue
Block a user