diff --git a/.rubocop.yml b/.rubocop.yml index 2007b91dc..ca3696b9b 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -354,6 +354,14 @@ Naming/BlockForwarding: - "app/controllers/management/base_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: Enabled: true @@ -725,9 +733,15 @@ Style/ClassVars: Style/CollectionMethods: Enabled: true +Style/ComparableBetween: + Enabled: true + Style/DigChain: Enabled: true +Style/EmptyStringInsideInterpolation: + Enabled: true + Style/FileRead: Enabled: true @@ -811,6 +825,9 @@ Style/RaiseArgs: Style/RedundantArgument: Enabled: true +Style/RedundantArrayFlatten: + Enabled: true + Style/RedundantBegin: Enabled: true diff --git a/Gemfile b/Gemfile index c4a829ae6..405321d49 100644 --- a/Gemfile +++ b/Gemfile @@ -100,7 +100,7 @@ group :development do gem "pronto-eslint", "~> 0.11.1", require: false gem "pronto-rubocop", "~> 0.11.6", require: false gem "pronto-stylelint", "~> 0.11.1", require: false - gem "rubocop", "~> 1.71.2", require: false + gem "rubocop", "~> 1.76.1", require: false gem "rubocop-capybara", "~> 2.21.0", require: false gem "rubocop-factory_bot", "~> 2.26.1", require: false gem "rubocop-performance", "~> 1.23.1", require: false diff --git a/Gemfile.lock b/Gemfile.lock index 3c3294158..6dbad9f61 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -337,7 +337,7 @@ GEM rexml kramdown-parser-gfm (1.1.0) kramdown (~> 2.0) - language_server-protocol (3.17.0.4) + language_server-protocol (3.17.0.5) launchy (3.1.1) addressable (~> 2.8) childprocess (~> 5.0) @@ -349,6 +349,7 @@ GEM letter_opener (~> 1.9) railties (>= 6.1) rexml + lint_roller (1.1.0) logger (1.7.0) loofah (2.24.0) crass (~> 1.0.2) @@ -444,7 +445,7 @@ GEM rack orm_adapter (0.5.0) ostruct (0.6.1) - parallel (1.26.3) + parallel (1.27.0) paranoia (3.0.1) activerecord (>= 6, < 8.1) parser (3.3.8.0) @@ -460,6 +461,7 @@ GEM pg_search (2.3.7) activerecord (>= 6.1) activesupport (>= 6.1) + prism (1.4.0) pronto (0.11.4) gitlab (>= 4.4.0, < 5.0) httparty (>= 0.13.7, < 1.0) @@ -574,18 +576,20 @@ GEM rspec-mocks (~> 3.13) rspec-support (~> 3.13) rspec-support (3.13.2) - rubocop (1.71.2) + rubocop (1.76.1) json (~> 2.3) - language_server-protocol (>= 3.17.0) + language_server-protocol (~> 3.17.0.2) + lint_roller (~> 1.1.0) parallel (~> 1.10) parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 2.9.3, < 3.0) - rubocop-ast (>= 1.38.0, < 2.0) + rubocop-ast (>= 1.45.0, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 4.0) - rubocop-ast (1.38.1) - parser (>= 3.3.1.0) + rubocop-ast (1.45.1) + parser (>= 3.3.7.2) + prism (~> 1.4) rubocop-capybara (2.21.0) rubocop (~> 1.41) rubocop-factory_bot (2.26.1) @@ -811,7 +815,7 @@ DEPENDENCIES rinku (~> 2.0.6) ros-apartment (~> 3.2.0) rspec-rails (~> 7.1.1) - rubocop (~> 1.71.2) + rubocop (~> 1.76.1) rubocop-capybara (~> 2.21.0) rubocop-factory_bot (~> 2.26.1) rubocop-performance (~> 1.23.1) diff --git a/app/components/admin/poll/shifts/form_component.rb b/app/components/admin/poll/shifts/form_component.rb index 5a0c626ba..8bdcf7bf2 100644 --- a/app/components/admin/poll/shifts/form_component.rb +++ b/app/components/admin/poll/shifts/form_component.rb @@ -20,7 +20,7 @@ class Admin::Poll::Shifts::FormComponent < ApplicationComponent def shift_vote_collection_dates return [] if voting_polls.blank? - date_options((voting_start_date..voting_end_date), Poll::Shift.tasks[:vote_collection]) + date_options(voting_start_date..voting_end_date, Poll::Shift.tasks[:vote_collection]) end def shift_recount_scrutiny_dates diff --git a/app/components/budgets/groups_and_headings_component.html.erb b/app/components/budgets/groups_and_headings_component.html.erb index 6f44960dd..a10282aa7 100644 --- a/app/components/budgets/groups_and_headings_component.html.erb +++ b/app/components/budgets/groups_and_headings_component.html.erb @@ -5,7 +5,7 @@ <% group.headings.sort_by_name.each do |heading| %>
<%= t("sdg.goals.help.description") %>
<%= sanitize t("sdg.goals.goal_#{goal.code}.description") %>
<%= render SDG::Goals::TargetsComponent.new(goal) %> diff --git a/app/components/sdg/goals/help_page_component.rb b/app/components/sdg/goals/help_page_component.rb index 470bdf5e6..8f9cd2c9c 100644 --- a/app/components/sdg/goals/help_page_component.rb +++ b/app/components/sdg/goals/help_page_component.rb @@ -11,7 +11,7 @@ class SDG::Goals::HelpPageComponent < ApplicationComponent private - def is_active?(goal) + def active_class(goal) "is-active" if goal.code == 1 end end diff --git a/app/components/shared/vote_button_component.rb b/app/components/shared/vote_button_component.rb index 1907c1d6d..a52396a9a 100644 --- a/app/components/shared/vote_button_component.rb +++ b/app/components/shared/vote_button_component.rb @@ -35,14 +35,14 @@ class Shared::VoteButtonComponent < ApplicationComponent end 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 def already_voted? vote.persisted? end - def parsed_value + def in_favor? value == "yes" end end diff --git a/app/controllers/users/confirmations_controller.rb b/app/controllers/users/confirmations_controller.rb index 80b0c49ff..2a7897f70 100644 --- a/app/controllers/users/confirmations_controller.rb +++ b/app/controllers/users/confirmations_controller.rb @@ -79,6 +79,6 @@ class Users::ConfirmationsController < Devise::ConfirmationsController private def set_official_position - resource.add_official_position! (Setting["official_level_1_name"]), 1 + resource.add_official_position!(Setting["official_level_1_name"], 1) end end diff --git a/app/helpers/proposals_dashboard_helper.rb b/app/helpers/proposals_dashboard_helper.rb index 3b069cd02..f7144320a 100644 --- a/app/helpers/proposals_dashboard_helper.rb +++ b/app/helpers/proposals_dashboard_helper.rb @@ -52,7 +52,7 @@ module ProposalsDashboardHelper dashboard_action&.proposed_action? end - def is_request_active(id) + def request_active?(id) controller_name == "dashboard" && action_name == "new_request" && dashboard_action&.id == id end diff --git a/app/lib/manager_authenticator.rb b/app/lib/manager_authenticator.rb index d0521aa96..ae1a4e1ea 100644 --- a/app/lib/manager_authenticator.rb +++ b/app/lib/manager_authenticator.rb @@ -22,7 +22,7 @@ class ManagerAuthenticator message: { ub: { user_key: @manager[:user_key], date: @manager[:date] }} ).body - parsed_response = parser.parse((response[:get_status_user_data_response][:get_status_user_data_return])) + parsed_response = parser.parse(response[:get_status_user_data_response][:get_status_user_data_return]) @manager[:login] == parsed_response["USUARIO"]["LOGIN"] rescue false diff --git a/app/models/poll.rb b/app/models/poll.rb index 8b6ec8624..68c15face 100644 --- a/app/models/poll.rb +++ b/app/models/poll.rb @@ -116,7 +116,7 @@ class Poll < ApplicationRecord end def current?(timestamp = Time.current) - starts_at <= timestamp && timestamp <= ends_at + timestamp.between?(starts_at, ends_at) end def expired?(timestamp = Time.current) diff --git a/app/models/poll/question/option.rb b/app/models/poll/question/option.rb index 299e764bb..9de143c06 100644 --- a/app/models/poll/question/option.rb +++ b/app/models/poll/question/option.rb @@ -30,7 +30,7 @@ class Poll::Question::Option < ApplicationRecord def self.order_options(ordered_array) ordered_array.each_with_index do |option_id, order| - find(option_id).update_column(:given_order, (order + 1)) + find(option_id).update_column(:given_order, order + 1) end end diff --git a/app/models/user.rb b/app/models/user.rb index 4f71af75a..970cc8312 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -325,7 +325,7 @@ class User < ApplicationRecord end def show_welcome_screen? - verification = Setting["feature.user.skip_verification"].present? ? true : unverified? + verification = Setting["feature.user.skip_verification"].present? || unverified? sign_in_count == 1 && verification && !organization && !administrator? end diff --git a/app/views/dashboard/_menu.html.erb b/app/views/dashboard/_menu.html.erb index f43835c5a..e4b555861 100644 --- a/app/views/dashboard/_menu.html.erb +++ b/app/views/dashboard/_menu.html.erb @@ -72,7 +72,7 @@ <% resources.each do |resource| %>