From af7d6e59af48bc66ead7d3c04f935d7c8cabef7b Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Fri, 3 Jan 2025 16:52:16 -0500 Subject: [PATCH] Replace deprecated `STATS_DIRECTORIES` with `Rails::CodeStatistics.register_directory` approach (#33445) --- config/initializers/statistics.rb | 13 +++++++++++++ lib/tasks/statistics.rake | 21 --------------------- 2 files changed, 13 insertions(+), 21 deletions(-) create mode 100644 config/initializers/statistics.rb delete mode 100644 lib/tasks/statistics.rake diff --git a/config/initializers/statistics.rb b/config/initializers/statistics.rb new file mode 100644 index 0000000000..a266607445 --- /dev/null +++ b/config/initializers/statistics.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +[ + %w(AppLibs app/lib), + %w(Policies app/policies), + %w(Presenters app/presenters), + %w(Serializers app/serializers), + %w(Services app/services), + %w(Validators app/validators), + %w(Workers app/workers), +].each do |name, directory| + Rails::CodeStatistics.register_directory(name.titleize, directory) +end diff --git a/lib/tasks/statistics.rake b/lib/tasks/statistics.rake deleted file mode 100644 index 82840f4fdc..0000000000 --- a/lib/tasks/statistics.rake +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -task stats: 'mastodon:stats' - -namespace :mastodon do - desc 'Report code statistics (KLOCs, etc)' - task :stats do - require 'rails/code_statistics' - [ - ['App Libraries', 'app/lib'], - %w(Presenters app/presenters), - %w(Policies app/policies), - %w(Serializers app/serializers), - %w(Services app/services), - %w(Validators app/validators), - %w(Workers app/workers), - ].each do |name, dir| - STATS_DIRECTORIES << [name, dir] - end - end -end