From 6c368a08d0ecf92441cb0ddf09646030161afaba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Guitaut?= Date: Thu, 22 Feb 2024 16:51:15 +0100 Subject: [PATCH] DEV: Fix new Rubocop offenses --- Gemfile | 5 +- Gemfile.lock | 46 +++++++++++++++---- .../list_controller_extension.rb | 6 +-- lib/discourse_assign/post_extension.rb | 6 +-- lib/discourse_assign/topic_extension.rb | 6 +-- lib/discourse_assign/web_hook_extension.rb | 13 ++++-- 6 files changed, 59 insertions(+), 23 deletions(-) diff --git a/Gemfile b/Gemfile index 31d8bf77..3ae194f6 100644 --- a/Gemfile +++ b/Gemfile @@ -3,6 +3,9 @@ source "https://rubygems.org" group :development do - gem "rubocop-discourse" + gem "rubocop-discourse", + require: false, + github: "discourse/rubocop-discourse", + branch: "loic-plugins-rules" gem "syntax_tree" end diff --git a/Gemfile.lock b/Gemfile.lock index 23ad67df..410e94de 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,11 +1,41 @@ +GIT + remote: https://github.com/discourse/rubocop-discourse.git + revision: dde0c0720b088e82398bc25dd3a8a31dab4bbc29 + branch: loic-plugins-rules + specs: + rubocop-discourse (3.6.0) + activesupport (>= 6.1) + rubocop (>= 1.59.0) + rubocop-rspec (>= 2.25.0) + GEM remote: https://rubygems.org/ specs: + activesupport (7.1.3.2) + base64 + bigdecimal + concurrent-ruby (~> 1.0, >= 1.0.2) + connection_pool (>= 2.2.5) + drb + i18n (>= 1.6, < 2) + minitest (>= 5.1) + mutex_m + tzinfo (~> 2.0) ast (2.4.2) + base64 (0.2.0) + bigdecimal (3.1.6) + concurrent-ruby (1.2.3) + connection_pool (2.4.1) + drb (2.2.0) + ruby2_keywords + i18n (1.14.1) + concurrent-ruby (~> 1.0) json (2.7.1) language_server-protocol (3.17.0.3) + minitest (5.22.2) + mutex_m (0.2.0) parallel (1.24.0) - parser (3.3.0.3) + parser (3.3.0.5) ast (~> 2.4.1) racc prettier_print (1.2.1) @@ -13,11 +43,11 @@ GEM rainbow (3.1.1) regexp_parser (2.9.0) rexml (3.2.6) - rubocop (1.59.0) + rubocop (1.60.2) json (~> 2.3) language_server-protocol (>= 3.17.0) parallel (~> 1.10) - parser (>= 3.2.2.4) + parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml (>= 3.2.5, < 4.0) @@ -28,9 +58,6 @@ GEM parser (>= 3.2.1.0) rubocop-capybara (2.20.0) rubocop (~> 1.41) - rubocop-discourse (3.6.0) - rubocop (>= 1.59.0) - rubocop-rspec (>= 2.25.0) rubocop-factory_bot (2.25.1) rubocop (~> 1.41) rubocop-rspec (2.26.1) @@ -38,16 +65,19 @@ GEM rubocop-capybara (~> 2.17) rubocop-factory_bot (~> 2.22) ruby-progressbar (1.13.0) + ruby2_keywords (0.0.5) syntax_tree (6.2.0) prettier_print (>= 1.2.0) + tzinfo (2.0.6) + concurrent-ruby (~> 1.0) unicode-display_width (2.5.0) PLATFORMS ruby DEPENDENCIES - rubocop-discourse + rubocop-discourse! syntax_tree BUNDLED WITH - 2.5.4 + 2.5.3 diff --git a/lib/discourse_assign/list_controller_extension.rb b/lib/discourse_assign/list_controller_extension.rb index 34b9c04e..88908aa8 100644 --- a/lib/discourse_assign/list_controller_extension.rb +++ b/lib/discourse_assign/list_controller_extension.rb @@ -2,8 +2,8 @@ module DiscourseAssign module ListControllerExtension - def self.prepended(base) - base.class_eval { ListController.generate_message_route(:private_messages_assigned) } - end + extend ActiveSupport::Concern + + prepended { generate_message_route(:private_messages_assigned) } end end diff --git a/lib/discourse_assign/post_extension.rb b/lib/discourse_assign/post_extension.rb index c6c8ab60..014b1a86 100644 --- a/lib/discourse_assign/post_extension.rb +++ b/lib/discourse_assign/post_extension.rb @@ -2,8 +2,8 @@ module DiscourseAssign module PostExtension - def self.prepended(base) - base.class_eval { has_one :assignment, as: :target, dependent: :destroy } - end + extend ActiveSupport::Concern + + prepended { has_one :assignment, as: :target, dependent: :destroy } end end diff --git a/lib/discourse_assign/topic_extension.rb b/lib/discourse_assign/topic_extension.rb index 5c6c60be..6221eeac 100644 --- a/lib/discourse_assign/topic_extension.rb +++ b/lib/discourse_assign/topic_extension.rb @@ -2,8 +2,8 @@ module DiscourseAssign module TopicExtension - def self.prepended(base) - base.class_eval { has_one :assignment, as: :target, dependent: :destroy } - end + extend ActiveSupport::Concern + + prepended { has_one :assignment, as: :target, dependent: :destroy } end end diff --git a/lib/discourse_assign/web_hook_extension.rb b/lib/discourse_assign/web_hook_extension.rb index b80f4cf1..e7dded62 100644 --- a/lib/discourse_assign/web_hook_extension.rb +++ b/lib/discourse_assign/web_hook_extension.rb @@ -2,11 +2,14 @@ module DiscourseAssign module WebHookExtension - def self.prepended(base) - base.class_eval do - def self.enqueue_assign_hooks(event, payload) - WebHook.enqueue_hooks(:assign, event, payload: payload) if active_web_hooks(event).exists? - end + extend ActiveSupport::Concern + + prepended {} + + class_methods do + def enqueue_assign_hooks(event, payload) + return unless active_web_hooks(event).exists? + enqueue_hooks(:assign, event, payload: payload) end end end