Skip to content

Commit

Permalink
DEV: Add lib to autoload path (#605)
Browse files Browse the repository at this point in the history
Why manually require files when we can autoload? Also update
`discourse-rubocop` to 3.8.0.
  • Loading branch information
tgxworld authored Nov 14, 2024
1 parent 6101ecd commit 10fb723
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 55 deletions.
73 changes: 38 additions & 35 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,80 +1,83 @@
GEM
remote: https://rubygems.org/
specs:
activesupport (7.1.3.3)
activesupport (8.0.0)
base64
benchmark (>= 0.3)
bigdecimal
concurrent-ruby (~> 1.0, >= 1.0.2)
concurrent-ruby (~> 1.0, >= 1.3.1)
connection_pool (>= 2.2.5)
drb
i18n (>= 1.6, < 2)
logger (>= 1.4.2)
minitest (>= 5.1)
mutex_m
tzinfo (~> 2.0)
securerandom (>= 0.3)
tzinfo (~> 2.0, >= 2.0.5)
uri (>= 0.13.1)
ast (2.4.2)
base64 (0.2.0)
benchmark (0.4.0)
bigdecimal (3.1.8)
concurrent-ruby (1.2.3)
concurrent-ruby (1.3.4)
connection_pool (2.4.1)
drb (2.2.1)
i18n (1.14.5)
i18n (1.14.6)
concurrent-ruby (~> 1.0)
json (2.7.2)
json (2.8.2)
language_server-protocol (3.17.0.3)
minitest (5.23.1)
mutex_m (0.2.0)
parallel (1.24.0)
parser (3.3.1.0)
logger (1.6.1)
minitest (5.25.1)
parallel (1.26.3)
parser (3.3.6.0)
ast (~> 2.4.1)
racc
prettier_print (1.2.1)
racc (1.8.0)
rack (3.0.11)
racc (1.8.1)
rack (3.1.8)
rainbow (3.1.1)
regexp_parser (2.9.2)
rexml (3.3.9)
rubocop (1.64.0)
rubocop (1.68.0)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.31.1, < 2.0)
regexp_parser (>= 2.4, < 3.0)
rubocop-ast (>= 1.32.2, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.31.3)
rubocop-ast (1.36.1)
parser (>= 3.3.1.0)
rubocop-capybara (2.20.0)
rubocop-capybara (2.21.0)
rubocop (~> 1.41)
rubocop-discourse (3.8.0)
rubocop-discourse (3.8.6)
activesupport (>= 6.1)
rubocop (>= 1.59.0)
rubocop-capybara (>= 2.0.0)
rubocop-factory_bot (>= 2.0.0)
rubocop-rails (>= 2.25.0)
rubocop-rspec (>= 2.25.0)
rubocop-factory_bot (2.25.1)
rubocop (~> 1.41)
rubocop-rails (2.25.0)
rubocop-rspec (>= 3.0.1)
rubocop-rspec_rails (>= 2.30.0)
rubocop-factory_bot (2.26.1)
rubocop (~> 1.61)
rubocop-rails (2.27.0)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.33.0, < 2.0)
rubocop (>= 1.52.0, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
rubocop-rspec (2.29.2)
rubocop (~> 1.40)
rubocop-capybara (~> 2.17)
rubocop-factory_bot (~> 2.22)
rubocop-rspec_rails (~> 2.28)
rubocop-rspec_rails (2.28.3)
rubocop (~> 1.40)
rubocop-rspec (3.2.0)
rubocop (~> 1.61)
rubocop-rspec_rails (2.30.0)
rubocop (~> 1.61)
rubocop-rspec (~> 3, >= 3.0.1)
ruby-progressbar (1.13.0)
securerandom (0.3.2)
syntax_tree (6.2.0)
prettier_print (>= 1.2.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.5.0)
unicode-display_width (2.6.0)
uri (1.0.2)

PLATFORMS
ruby
Expand All @@ -84,4 +87,4 @@ DEPENDENCIES
syntax_tree

BUNDLED WITH
2.5.10
2.5.18
2 changes: 1 addition & 1 deletion app/jobs/scheduled/enqueue_reminders.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module Jobs
class EnqueueReminders < ::Jobs::Scheduled
REMINDER_BUFFER_MINUTES ||= 120
REMINDER_BUFFER_MINUTES = 120

every 1.day

Expand Down
2 changes: 1 addition & 1 deletion lib/discourse_assign/discourse_calendar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

module DiscourseAssign
module DiscourseCalendar
HOLIDAY_CUSTOM_FIELD ||= "on_holiday"
HOLIDAY_CUSTOM_FIELD = "on_holiday"
end
end
1 change: 1 addition & 0 deletions lib/discourse_assign/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ module ::DiscourseAssign
class Engine < ::Rails::Engine
engine_name PLUGIN_NAME
isolate_namespace DiscourseAssign
config.autoload_paths << File.join(config.root, "lib")
end
end
18 changes: 0 additions & 18 deletions plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,6 @@ module ::DiscourseAssign
require_relative "lib/validators/assign_statuses_validator"

after_initialize do
require_relative "app/jobs/regular/assign_notification"
require_relative "app/jobs/regular/remind_user"
require_relative "app/jobs/regular/unassign_notification"
require_relative "app/jobs/scheduled/enqueue_reminders"
require_relative "lib/assigner"
require_relative "lib/discourse_assign/create_notification"
require_relative "lib/discourse_assign/discourse_calendar"
require_relative "lib/discourse_assign/group_extension"
require_relative "lib/discourse_assign/helpers"
require_relative "lib/discourse_assign/list_controller_extension"
require_relative "lib/discourse_assign/notification_extension"
require_relative "lib/discourse_assign/post_extension"
require_relative "lib/discourse_assign/topic_extension"
require_relative "lib/discourse_assign/web_hook_extension"
require_relative "lib/pending_assigns_reminder"
require_relative "lib/random_assign_utils"
require_relative "lib/topic_assigner"

reloadable_patch do |plugin|
Group.prepend(DiscourseAssign::GroupExtension)
ListController.prepend(DiscourseAssign::ListControllerExtension)
Expand Down

4 comments on commit 10fb723

@martin-brennan
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tgxworld this change is causing a lot of local development log spam:

 -    REMINDER_BUFFER_MINUTES ||= 120
 +    REMINDER_BUFFER_MINUTES = 120

The classic "already defined const" message:

/home/mb/repos/discourse-assign/app/jobs/scheduled/enqueue_reminders.rb:5: warning: already initialized constant Jobs::EnqueueReminders::REMINDER_BUFFER_MINUTES
/home/mb/repos/discourse-assign/app/jobs/scheduled/enqueue_reminders.rb:5: warning: previous definition of REMINDER_BUFFER_MINUTES was here

So I think the ||= is needed, or some other change to this plugin

@tgxworld
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where are you seeing the warning being printed from?

So I think the ||= is needed, or some other change to this plugin

Note that it is always going to be some other change. ||= is never needed when defining a constant.

@martin-brennan
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tgxworld it happens with bin/ember-cli -u locally, when I have discourse-assign installed.

Done in 5.7s
Ember CLI running on PID: 23278
I, [2024-11-25T10:30:56.227991 #23306]  INFO -- : Refreshing Gem list
Starting CSS change watcher
[ember-cli] Proxying to http://127.0.0.1:3000
[ember-cli] building...
[ember-cli] ...[ConfigLoader]
[ember-cli] ...[Babel: discourse-widget-hbs > applyPatches]
[ember-cli] ...[Babel: @embroider/macros > applyPatches]
[ember-cli] ...[Babel: ember-tracked-storage-polyfill > applyPatches]
[ember-cli] ...[Babel: pretty-text > applyPatches]
[ember-cli] ...[Babel: discourse-common > applyPatches]
[ember-cli] ...[Babel: @glimmer/component > applyPatches]
[ember-cli] ...[Babel: dialog-holder > applyPatches]
[ember-cli] ...[Babel: ember-cache-primitive-polyfill > applyPatches]
[ember-cli] ...[Babel: float-kit > applyPatches]
[ember-cli] ...[embroider-template-compile-stage1 > applyPatches]
[ember-cli] ...[Babel: select-kit > applyPatches]
I, [2024-11-25T10:31:02.643533 #23306]  INFO -- : listening on addr=127.0.0.1:3000 fd=32
[ember-cli] ...[@embroider/compat/app]
[ember-cli] ...[@embroider/webpack]
I, [2024-11-25T10:31:04.848517 #23306]  INFO -- : starting 1 supervised sidekiqs
I, [2024-11-25T10:31:05.189149 #23306]  INFO -- : master process ready
I, [2024-11-25T10:31:05.344707 #23684]  INFO -- : Loading Sidekiq in process id 23684
I, [2024-11-25T10:31:05.344754 #23685]  INFO -- : worker=0 ready
I, [2024-11-25T10:31:05.373113 #23689]  INFO -- : worker=2 ready
I, [2024-11-25T10:31:05.399416 #23686]  INFO -- : worker=1 ready
[ember-cli] ...[@embroider/webpack]
[ember-cli] ...[@embroider/webpack]
[ember-cli] ...[SourceMapConcat]
[ember-cli] ...[TemplateCompiler > applyPatches]
[ember-cli] ...[Babel: admin > applyPatches]
[ember-cli] ...[SourceMapConcat]
[ember-cli] ...[Babel: discourse > applyPatches]
[ember-cli] ...[TemplateCompiler > applyPatches]
[ember-cli] ...[Babel: discourse-plugins > applyPatches]
[ember-cli] ...[SourceMapConcat]
[ember-cli] ...[Babel: discourse-plugins > applyPatches]
[ember-cli] ...[TemplateCompiler > applyPatches]
[ember-cli] ...[Babel: discourse-plugins > applyPatches]
[ember-cli] ...[TemplateCompiler > applyPatches]
[ember-cli] ...[Babel: discourse-plugins > applyPatches]
[ember-cli] ...[TemplateCompiler > applyPatches]
[ember-cli] ...[Babel: discourse-plugins > applyPatches]
[ember-cli]
[ember-cli] WARNING: 325 deprecations encountered while compiling scss. (we cannot correct these until the Ruby SCSS pipeline is updated)
[ember-cli]
[ember-cli] Build successful (30883ms) – Serving on http://localhost:4200/
[ember-cli]
[ember-cli] Slowest Nodes (totalTime >= 5%) | Total (avg)
[ember-cli] -+-
[ember-cli] @embroider/webpack (1) | 18678ms
[ember-cli] Babel: discourse-plugins (53) | 2924ms (55 ms)
[ember-cli]
/home/mb/repos/discourse-assign/app/jobs/scheduled/enqueue_reminders.rb:5: warning: already initialized constant Jobs::EnqueueReminders::REMINDER_BUFFER_MINUTES
/home/mb/repos/discourse-assign/app/jobs/scheduled/enqueue_reminders.rb:5: warning: previous definition of REMINDER_BUFFER_MINUTES was here
/home/mb/repos/discourse-assign/app/jobs/scheduled/enqueue_reminders.rb:5: warning: already initialized constant Jobs::EnqueueReminders::REMINDER_BUFFER_MINUTES
/home/mb/repos/discourse-assign/app/jobs/scheduled/enqueue_reminders.rb:5: warning: previous definition of REMINDER_BUFFER_MINUTES was here
/home/mb/repos/discourse-assign/app/jobs/scheduled/enqueue_reminders.rb:5: warning: already initialized constant Jobs::EnqueueReminders::REMINDER_BUFFER_MINUTES
/home/mb/repos/discourse-assign/app/jobs/scheduled/enqueue_reminders.rb:5: warning: previous definition of REMINDER_BUFFER_MINUTES was here

@tgxworld
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have any special envs locally? I can't seem to reproduce this locally

tgxworld ~/work/discourse [main] $ UNICORN_SIDEKIQS=1 bin/ember-cli -u
Scope: all 19 workspace projects
Lockfile is up to date, resolution step is skipped
Already up to date
Done in 785ms
Ember CLI running on PID: 35227
I, [2024-12-02T07:54:12.219522 #35352]  INFO -- : Refreshing Gem list
Starting CSS change watcher
I, [2024-12-02T07:54:13.810971 #35352]  INFO -- : listening on addr=127.0.0.1:3000 fd=18
[ember-cli] Proxying to http://127.0.0.1:3000
I, [2024-12-02T07:54:14.656339 #35352]  INFO -- : starting 1 supervised sidekiqs
[ember-cli] building...
I, [2024-12-02T07:54:14.778041 #35352]  INFO -- : master process ready
I, [2024-12-02T07:54:14.792219 #35424]  INFO -- : Loading Sidekiq in process id 35424
I, [2024-12-02T07:54:14.794604 #35425]  INFO -- : worker=0 ready
[ember-cli] ...[ConfigLoader]
[ember-cli] ...[Babel: discourse-widget-hbs > applyPatches]
[ember-cli] ...[Babel: @glimmer/component > applyPatches]
[ember-cli] ...[Babel: dialog-holder > applyPatches]
[ember-cli] ...[Babel: float-kit > applyPatches]
[ember-cli] ...[embroider-template-compile-stage1 > applyPatches]
[ember-cli] ...[@embroider/compat/app]
[ember-cli] ...[@embroider/webpack]
[ember-cli] ...[@embroider/webpack]
[ember-cli] ...[SourceMapConcat]
[ember-cli] ...[TemplateCompiler > applyPatches]
[ember-cli] ...[Babel: admin > applyPatches]
[ember-cli] ...[SourceMapConcat]
[ember-cli] ...[TemplateCompiler > applyPatches]
[ember-cli] ...[Babel: discourse-plugins > applyPatches]
[ember-cli] ...[SourceMapConcat]
[ember-cli] ...[TemplateCompiler > applyPatches]
[ember-cli] ...[Babel: discourse-plugins > applyPatches]
[ember-cli] ...[SourceMapConcat]
[ember-cli] ...[Babel: discourse-plugins > applyPatches]
[ember-cli] ...[TemplateCompiler > applyPatches]
[ember-cli] ...[Babel: discourse-plugins > applyPatches]
[ember-cli] ...[SourceMapConcat]
[ember-cli]
[ember-cli] WARNING: 325 deprecations encountered while compiling scss. (we cannot correct these until the Ruby SCSS pipeline is updated)
[ember-cli]
[ember-cli] Build successful (18317ms) – Serving on http://localhost:4200/
[ember-cli]
[ember-cli] Slowest Nodes (totalTime >= 5%) | Total (avg)
[ember-cli] -+-
[ember-cli] @embroider/webpack (1) | 10268ms
[ember-cli] Babel: discourse-plugins (24) | 1308ms (54 ms)
[ember-cli] Funnel (403) | 1172ms (2 ms)
[ember-cli]

Please sign in to comment.