diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000000..3bc0a982fc --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,10 @@ +AllCops: + Exclude: + - lib/templates/**/* +# Omakase Ruby styling for Rails +inherit_gem: { rubocop-rails-omakase: rubocop.yml } +# Overwrite or add rules to create your own house style +# +# # Use `[a, [b, c]]` not `[ a, [ b, c ] ]` +Layout/SpaceInsideArrayLiteralBrackets: + Enabled: false diff --git a/.standard.yml b/.standard.yml deleted file mode 100644 index 69a1d0cbea..0000000000 --- a/.standard.yml +++ /dev/null @@ -1,6 +0,0 @@ -ignore: - - tmp/**/* - - test/fixture/**/* - - lib/templates/**/* - - plugins/**/* - - test/lib/markdown_test.rb \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 3b6e2ce8ff..58420cac89 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -42,10 +42,5 @@ "i18n-ally.sourceLanguage": "zh-CN", "i18n-ally.translate.engines": ["opencc", "google"], "prettier.singleQuote": false, - "ruby.format": "standard", - "ruby.lint": { - "standard": { - "useBundler": true - } - } + "ruby.format": "rubocop" } diff --git a/Gemfile b/Gemfile index a02353a2cc..7d6176f693 100644 --- a/Gemfile +++ b/Gemfile @@ -1,11 +1,9 @@ -# frozen_string_literal: true - source "https://rubygems.org" git_source(:github) { |repo_name| "https://github.com/#{repo_name}.git" } gem "jbuilder" -gem "rails", "~> 7.1.3" +gem "rails", "~> 8.0.0.beta1" gem "rails_autolink" gem "sass-rails" gem "shakapacker", "~> 7.2.1" @@ -65,7 +63,6 @@ gem "pghero" # Cache gem "connection_pool" gem "redis" -gem "second_level_cache" # Setting gem "rails-settings-cached" @@ -109,5 +106,5 @@ group :development, :test do gem "minitest-spec-rails" gem "mocha" - gem "standard" + gem "rubocop-rails-omakase", require: false end diff --git a/Gemfile.lock b/Gemfile.lock index 9e3bc3bc17..45f68f1f01 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -3,99 +3,97 @@ GEM specs: action-store (1.1.3) rails (>= 5.2) - actioncable (7.1.3.4) - actionpack (= 7.1.3.4) - activesupport (= 7.1.3.4) + actioncable (8.0.0.rc1) + actionpack (= 8.0.0.rc1) + activesupport (= 8.0.0.rc1) nio4r (~> 2.0) websocket-driver (>= 0.6.1) zeitwerk (~> 2.6) - actionmailbox (7.1.3.4) - actionpack (= 7.1.3.4) - activejob (= 7.1.3.4) - activerecord (= 7.1.3.4) - activestorage (= 7.1.3.4) - activesupport (= 7.1.3.4) - mail (>= 2.7.1) - net-imap - net-pop - net-smtp - actionmailer (7.1.3.4) - actionpack (= 7.1.3.4) - actionview (= 7.1.3.4) - activejob (= 7.1.3.4) - activesupport (= 7.1.3.4) - mail (~> 2.5, >= 2.5.4) - net-imap - net-pop - net-smtp + actionmailbox (8.0.0.rc1) + actionpack (= 8.0.0.rc1) + activejob (= 8.0.0.rc1) + activerecord (= 8.0.0.rc1) + activestorage (= 8.0.0.rc1) + activesupport (= 8.0.0.rc1) + mail (>= 2.8.0) + actionmailer (8.0.0.rc1) + actionpack (= 8.0.0.rc1) + actionview (= 8.0.0.rc1) + activejob (= 8.0.0.rc1) + activesupport (= 8.0.0.rc1) + mail (>= 2.8.0) rails-dom-testing (~> 2.2) - actionpack (7.1.3.4) - actionview (= 7.1.3.4) - activesupport (= 7.1.3.4) + actionpack (8.0.0.rc1) + actionview (= 8.0.0.rc1) + activesupport (= 8.0.0.rc1) nokogiri (>= 1.8.5) - racc rack (>= 2.2.4) rack-session (>= 1.0.1) rack-test (>= 0.6.3) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - actiontext (7.1.3.4) - actionpack (= 7.1.3.4) - activerecord (= 7.1.3.4) - activestorage (= 7.1.3.4) - activesupport (= 7.1.3.4) + useragent (~> 0.16) + actiontext (8.0.0.rc1) + actionpack (= 8.0.0.rc1) + activerecord (= 8.0.0.rc1) + activestorage (= 8.0.0.rc1) + activesupport (= 8.0.0.rc1) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.1.3.4) - activesupport (= 7.1.3.4) + actionview (8.0.0.rc1) + activesupport (= 8.0.0.rc1) builder (~> 3.1) erubi (~> 1.11) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - activejob (7.1.3.4) - activesupport (= 7.1.3.4) + activejob (8.0.0.rc1) + activesupport (= 8.0.0.rc1) globalid (>= 0.3.6) - activemodel (7.1.3.4) - activesupport (= 7.1.3.4) - activerecord (7.1.3.4) - activemodel (= 7.1.3.4) - activesupport (= 7.1.3.4) + activemodel (8.0.0.rc1) + activesupport (= 8.0.0.rc1) + activerecord (8.0.0.rc1) + activemodel (= 8.0.0.rc1) + activesupport (= 8.0.0.rc1) timeout (>= 0.4.0) - activestorage (7.1.3.4) - actionpack (= 7.1.3.4) - activejob (= 7.1.3.4) - activerecord (= 7.1.3.4) - activesupport (= 7.1.3.4) + activestorage (8.0.0.rc1) + actionpack (= 8.0.0.rc1) + activejob (= 8.0.0.rc1) + activerecord (= 8.0.0.rc1) + activesupport (= 8.0.0.rc1) marcel (~> 1.0) - activesupport (7.1.3.4) + activesupport (8.0.0.rc1) 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) - addressable (2.8.6) - public_suffix (>= 2.0.2, < 6.0) + securerandom (>= 0.3) + tzinfo (~> 2.0, >= 2.0.5) + uri (>= 0.13.1) + addressable (2.8.7) + public_suffix (>= 2.0.2, < 7.0) aliyun-sdk (0.8.0) nokogiri (~> 1.6) rest-client (~> 2.0) ast (2.4.2) - autocorrect-rb (2.9.4-arm64-darwin) + autocorrect-rb (2.13.0-arm64-darwin) rb_sys (>= 0.9.54) - autocorrect-rb (2.9.4-x86_64-linux) + autocorrect-rb (2.13.0-x86_64-linux) rb_sys (>= 0.9.54) - autocorrect-rb (2.9.4-x86_64-linux-musl) + autocorrect-rb (2.13.0-x86_64-linux-musl) rb_sys (>= 0.9.54) base64 (0.2.0) bcrypt (3.1.20) - benchmark-ips (2.13.0) + benchmark (0.3.0) + benchmark-ips (2.14.0) bigdecimal (3.1.8) - bootsnap (1.18.3) + bootsnap (1.18.4) msgpack (~> 1.2) - builder (3.2.4) + builder (3.3.0) byebug (11.1.3) cancancan (3.6.1) carrierwave (2.2.6) @@ -115,7 +113,8 @@ GEM carrierwave-upyun (2.0.0) carrierwave (>= 1.0.0) faraday (>= 2.0) - childprocess (5.0.0) + childprocess (5.1.0) + logger (~> 1.5) coffee-rails (5.0.0) coffee-script (>= 2.2.0) railties (>= 5.2.0) @@ -123,22 +122,27 @@ GEM coffee-script-source execjs coffee-script-source (1.12.2) - concurrent-ruby (1.3.1) + concurrent-ruby (1.3.4) connection_pool (2.4.1) crass (1.0.6) date (3.3.4) - dead_end (4.0.0) - derailed_benchmarks (2.1.2) + derailed_benchmarks (2.2.1) + base64 benchmark-ips (~> 2) - dead_end - get_process_mem (~> 0) + bigdecimal + drb + get_process_mem heapy (~> 0) + logger memory_profiler (>= 0, < 2) mini_histogram (>= 0.3.0) + mutex_m + ostruct rack (>= 1) rack-test rake (> 10, < 14) - ruby-statistics (>= 2.1) + ruby-statistics (>= 4.0.1) + ruby2_keywords thor (>= 0.19, < 2) devise (4.9.4) bcrypt (~> 3.0) @@ -149,32 +153,34 @@ GEM devise-encryptable (0.2.0) devise (>= 2.1.0) domain_name (0.6.20240107) - doorkeeper (5.7.0) + doorkeeper (5.7.1) railties (>= 5) doorkeeper-i18n (5.2.7) doorkeeper (>= 5.2) - dotenv (3.1.2) - dotenv-rails (3.1.2) - dotenv (= 3.1.2) + dotenv (3.1.4) + dotenv-rails (3.1.4) + dotenv (= 3.1.4) railties (>= 6.1) drb (2.2.1) enumize (0.2.1) rails (>= 5.0.0) - erubi (1.12.0) + erubi (1.13.0) et-orbi (1.2.11) tzinfo exception-track (1.3.0) kaminari (>= 0.15) rails (>= 5.2) - execjs (2.9.1) - factory_bot (6.4.6) + execjs (2.10.0) + factory_bot (6.5.0) activesupport (>= 5.0.0) - factory_bot_rails (6.4.3) - factory_bot (~> 6.4) + factory_bot_rails (6.4.4) + factory_bot (~> 6.5) railties (>= 5.0.0) - faraday (2.9.0) - faraday-net_http (>= 2.0, < 3.2) - faraday-net_http (3.1.0) + faraday (2.12.0) + faraday-net_http (>= 2.0, < 3.4) + json + logger + faraday-net_http (3.3.0) net-http faraday-rack (2.0.0) faraday (~> 2.0) @@ -183,10 +189,11 @@ GEM ffi (1.17.0-x86_64-linux-musl) form-select (0.3.2) rails (>= 4.2) - fugit (1.11.0) + fugit (1.11.1) et-orbi (~> 1, >= 1.2.11) raabro (~> 1.4) - get_process_mem (0.2.7) + get_process_mem (1.0.0) + bigdecimal (>= 2.0) ffi (~> 1.0) globalid (1.2.1) activesupport (>= 6.1) @@ -200,24 +207,24 @@ GEM autocorrect-rb (>= 2.1.2) html-pipeline (>= 2.0) http-accept (1.7.0) - http-cookie (1.0.6) + http-cookie (1.0.7) domain_name (~> 0.5) http_accept_language (2.1.1) - i18n (1.14.5) + i18n (1.14.6) concurrent-ruby (~> 1.0) - image_processing (1.12.2) + image_processing (1.13.0) mini_magick (>= 4.9.5, < 5) ruby-vips (>= 2.0.17, < 3) io-console (0.7.2) - irb (1.13.1) + irb (1.14.1) rdoc (>= 4.0.0) reline (>= 0.4.2) - jbuilder (2.12.0) + jbuilder (2.13.0) actionview (>= 5.0.0) activesupport (>= 5.0.0) jieba-rb (5.0.0) - json (2.7.2) - jwt (2.8.1) + json (2.7.4) + jwt (2.9.3) base64 kaminari (1.2.2) activesupport (>= 4.1.0) @@ -237,11 +244,11 @@ GEM childprocess (~> 5.0) letter_opener (1.10.0) launchy (>= 2.2, < 4) - lint_roller (1.1.0) listen (3.9.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) - loofah (2.22.0) + logger (1.6.1) + loofah (2.23.1) crass (~> 1.0.2) nokogiri (>= 1.12.0) mail (2.8.1) @@ -250,27 +257,28 @@ GEM net-pop net-smtp marcel (1.0.4) - memory_profiler (1.0.1) + memory_profiler (1.1.0) method_source (1.1.0) - mime-types (3.5.2) + mime-types (3.6.0) + logger mime-types-data (~> 3.2015) - mime-types-data (3.2024.0507) + mime-types-data (3.2024.1001) mini_histogram (0.3.1) - mini_magick (4.12.0) + mini_magick (4.13.2) mini_mime (1.1.5) - minitest (5.23.1) - minitest-spec-rails (7.2.0) + minitest (5.25.1) + minitest-spec-rails (7.3.0) minitest (>= 5.0) railties (>= 4.1) - mocha (2.3.0) + mocha (2.5.0) ruby2_keywords (>= 0.0.5) - msgpack (1.7.2) + msgpack (1.7.3) multi_xml (0.7.1) bigdecimal (~> 3.1) mutex_m (0.2.0) net-http (0.4.1) uri - net-imap (0.4.12) + net-imap (0.5.0) date net-protocol net-pop (0.1.2) @@ -280,10 +288,10 @@ GEM net-smtp (0.5.0) net-protocol netrc (0.11.0) - nio4r (2.7.3) - nokogiri (1.16.5-arm64-darwin) + nio4r (2.7.4) + nokogiri (1.16.7-arm64-darwin) racc (~> 1.4) - nokogiri (1.16.5-x86_64-linux) + nokogiri (1.16.7-x86_64-linux) racc (~> 1.4) notifications (1.1.0) kaminari (>= 0.15) @@ -308,9 +316,10 @@ GEM omniauth-github (2.0.1) omniauth (~> 2.0) omniauth-oauth2 (~> 1.8) - omniauth-oauth (1.2.0) + omniauth-oauth (1.2.1) oauth omniauth (>= 1.0, < 3) + rack (>= 1.6.2, < 4) omniauth-oauth2 (1.8.0) oauth2 (>= 1.4, < 3) omniauth (~> 2.0) @@ -323,34 +332,36 @@ GEM omniauth-wechat-oauth2 (0.2.3) omniauth-oauth2 (>= 1.7.3) orm_adapter (0.5.0) + ostruct (0.6.0) package_json (0.1.0) - parallel (1.24.0) - parser (3.3.2.0) + parallel (1.26.3) + parser (3.3.5.0) ast (~> 2.4.1) racc - pg (1.5.6) - pghero (3.5.0) - activerecord (>= 6) - postmark (1.25.0) + pg (1.5.9) + pghero (3.6.1) + activerecord (>= 6.1) + postmark (1.25.1) json postmark-rails (0.22.1) actionmailer (>= 3.0.0) postmark (>= 1.21.3, < 2.0) psych (5.1.2) stringio - public_suffix (5.0.5) - puma (6.4.2) + public_suffix (6.0.1) + puma (6.4.3) nio4r (~> 2.0) - puma_worker_killer (0.3.1) - get_process_mem (~> 0.2) + puma_worker_killer (1.0.0) + bigdecimal (>= 2.0) + get_process_mem (>= 0.2) puma (>= 2.7) qiniu (6.9.1) mime-types (~> 3.1) rest-client (~> 2.0) rexml (~> 3.2) raabro (1.4.0) - racc (1.8.0) - rack (3.0.11) + racc (1.8.1) + rack (3.1.8) rack-attack (6.7.0) rack (>= 1.0, < 4) rack-cors (2.0.2) @@ -367,20 +378,20 @@ GEM rackup (2.1.0) rack (>= 3) webrick (~> 1.8) - rails (7.1.3.4) - actioncable (= 7.1.3.4) - actionmailbox (= 7.1.3.4) - actionmailer (= 7.1.3.4) - actionpack (= 7.1.3.4) - actiontext (= 7.1.3.4) - actionview (= 7.1.3.4) - activejob (= 7.1.3.4) - activemodel (= 7.1.3.4) - activerecord (= 7.1.3.4) - activestorage (= 7.1.3.4) - activesupport (= 7.1.3.4) + rails (8.0.0.rc1) + actioncable (= 8.0.0.rc1) + actionmailbox (= 8.0.0.rc1) + actionmailer (= 8.0.0.rc1) + actionpack (= 8.0.0.rc1) + actiontext (= 8.0.0.rc1) + actionview (= 8.0.0.rc1) + activejob (= 8.0.0.rc1) + activemodel (= 8.0.0.rc1) + activerecord (= 8.0.0.rc1) + activestorage (= 8.0.0.rc1) + activesupport (= 8.0.0.rc1) bundler (>= 1.15.0) - railties (= 7.1.3.4) + railties (= 8.0.0.rc1) rails-dom-testing (2.2.0) activesupport (>= 5.0.0) minitest @@ -388,20 +399,20 @@ GEM rails-html-sanitizer (1.6.0) loofah (~> 2.21) nokogiri (~> 1.14) - rails-i18n (7.0.9) + rails-i18n (7.0.10) i18n (>= 0.7, < 2) railties (>= 6.0.0, < 8) - rails-settings-cached (2.9.4) + rails-settings-cached (2.9.5) activerecord (>= 5.0.0) railties (>= 5.0.0) rails_autolink (1.1.8) actionview (> 3.1) activesupport (> 3.1) railties (> 3.1) - railties (7.1.3.4) - actionpack (= 7.1.3.4) - activesupport (= 7.1.3.4) - irb + railties (8.0.0.rc1) + actionpack (= 8.0.0.rc1) + activesupport (= 8.0.0.rc1) + irb (~> 1.13) rackup (>= 1.0.0) rake (>= 12.2) thor (~> 1.0, >= 1.2.2) @@ -411,17 +422,17 @@ GEM rb-fsevent (0.11.2) rb-inotify (0.11.1) ffi (~> 1.0) - rb_sys (0.9.97) + rb_sys (0.9.102) rdoc (6.7.0) psych (>= 4.0.0) - recaptcha (5.16.0) + recaptcha (5.17.0) redcarpet (3.6.0) - redis (5.2.0) + redis (5.3.0) redis-client (>= 0.22.0) redis-client (0.22.2) connection_pool regexp_parser (2.9.2) - reline (0.5.8) + reline (0.5.10) io-console (~> 0.5) responders (3.1.1) actionpack (>= 5.2) @@ -431,31 +442,43 @@ GEM http-cookie (>= 1.0.2, < 2.0) mime-types (>= 1.16, < 4.0) netrc (~> 0.8) - rexml (3.2.8) - strscan (>= 3.0.9) - rouge (4.2.1) - rubocop (1.63.5) + rexml (3.3.9) + rouge (4.4.0) + rubocop (1.67.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.32.3) parser (>= 3.3.1.0) - rubocop-performance (1.21.0) + rubocop-minitest (0.36.0) + rubocop (>= 1.61, < 2.0) + rubocop-ast (>= 1.31.1, < 2.0) + rubocop-performance (1.22.1) rubocop (>= 1.48.1, < 2.0) rubocop-ast (>= 1.31.1, < 2.0) + rubocop-rails (2.27.0) + activesupport (>= 4.2.0) + rack (>= 1.1) + rubocop (>= 1.52.0, < 2.0) + rubocop-ast (>= 1.31.1, < 2.0) + rubocop-rails-omakase (1.0.0) + rubocop + rubocop-minitest + rubocop-performance + rubocop-rails ruby-progressbar (1.13.0) ruby-push-notifications (1.3.0) builder (~> 3.0) - ruby-statistics (3.0.2) - ruby-vips (2.2.1) + ruby-statistics (4.0.1) + ruby-vips (2.2.2) ffi (~> 1.12) + logger ruby2_keywords (0.0.5) rucaptcha (3.2.3-arm64-darwin) railties (>= 3.2) @@ -476,9 +499,7 @@ GEM sprockets (> 3.0) sprockets-rails tilt - second_level_cache (2.7.1) - activerecord (>= 6.0) - activesupport (>= 6.0) + securerandom (0.3.1) semantic_range (3.0.0) shakapacker (7.2.3) activesupport (>= 5.2) @@ -486,11 +507,11 @@ GEM rack-proxy (>= 0.6.1) railties (>= 5.2) semantic_range (>= 2.3.0) - sidekiq (7.2.4) - concurrent-ruby (< 2) + sidekiq (7.3.4) connection_pool (>= 2.3.0) + logger rack (>= 2.2.4) - redis-client (>= 0.19.0) + redis-client (>= 0.22.2) sidekiq-cron (1.12.0) fugit (~> 1.8) globalid (>= 1.0.1) @@ -504,27 +525,14 @@ GEM sprockets (4.2.1) concurrent-ruby (~> 1.0) rack (>= 2.2.4, < 4) - sprockets-rails (3.4.2) - actionpack (>= 5.2) - activesupport (>= 5.2) + sprockets-rails (3.5.2) + actionpack (>= 6.1) + activesupport (>= 6.1) sprockets (>= 3.0.0) ssrf_filter (1.1.2) - standard (1.36.0) - language_server-protocol (~> 3.17.0.2) - lint_roller (~> 1.0) - rubocop (~> 1.63.0) - standard-custom (~> 1.0.0) - standard-performance (~> 1.4) - standard-custom (1.0.2) - lint_roller (~> 1.0) - rubocop (~> 1.50) - standard-performance (1.4.0) - lint_roller (~> 1.1) - rubocop-performance (~> 1.21.0) - stringio (3.1.0) - strscan (3.1.0) - thor (1.3.1) - tilt (2.3.0) + stringio (3.1.1) + thor (1.3.2) + tilt (2.4.0) timeout (0.4.1) turbolinks (5.2.1) turbolinks-source (~> 5.2) @@ -533,10 +541,11 @@ GEM nokogiri (~> 1.6) tzinfo (2.0.6) concurrent-ruby (~> 1.0) - uglifier (4.2.0) + uglifier (4.2.1) execjs (>= 0.3.0, < 3) - unicode-display_width (2.5.0) - uri (0.13.0) + unicode-display_width (2.6.0) + uri (0.13.1) + useragent (0.16.10) version_gem (1.1.4) view_component (2.83.0) activesupport (>= 5.2.0, < 8.0) @@ -544,11 +553,11 @@ GEM method_source (~> 1.0) warden (1.2.9) rack (>= 2.0.9) - webrick (1.8.1) + webrick (1.8.2) websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) - zeitwerk (2.6.15) + zeitwerk (2.7.1) PLATFORMS arm64-darwin-21 @@ -605,7 +614,7 @@ DEPENDENCIES qiniu rack-attack rack-cors - rails (~> 7.1.3) + rails (~> 8.0.0.beta1) rails-i18n rails-settings-cached rails_autolink @@ -613,20 +622,19 @@ DEPENDENCIES redcarpet redis rouge + rubocop-rails-omakase ruby-push-notifications rucaptcha sass-rails - second_level_cache shakapacker (~> 7.2.1) sidekiq (< 8) sidekiq-cron social-share-button spring - standard turbolinks twemoji uglifier view_component (~> 2.83) BUNDLED WITH - 2.5.10 + 2.5.3 diff --git a/Rakefile b/Rakefile index d47ddc9ef1..6c29723c5b 100755 --- a/Rakefile +++ b/Rakefile @@ -1,6 +1,4 @@ #!/usr/bin/env rake -# frozen_string_literal: true - # Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. diff --git a/app/channels/application_cable/channel.rb b/app/channels/application_cable/channel.rb index 9aec230539..d672697283 100644 --- a/app/channels/application_cable/channel.rb +++ b/app/channels/application_cable/channel.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - module ApplicationCable class Channel < ActionCable::Channel::Base end diff --git a/app/channels/application_cable/connection.rb b/app/channels/application_cable/connection.rb index f353f04b3d..2841d5b290 100644 --- a/app/channels/application_cable/connection.rb +++ b/app/channels/application_cable/connection.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - module ApplicationCable class Connection < ActionCable::Connection::Base identified_by :current_user_id diff --git a/app/channels/notifications_channel.rb b/app/channels/notifications_channel.rb index 7f40457f2d..21a89980fb 100644 --- a/app/channels/notifications_channel.rb +++ b/app/channels/notifications_channel.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class NotificationsChannel < ApplicationCable::Channel def subscribed stream_from "notifications_count/#{current_user_id}" diff --git a/app/channels/replies_channel.rb b/app/channels/replies_channel.rb index 18122f3e2e..85066cee22 100644 --- a/app/channels/replies_channel.rb +++ b/app/channels/replies_channel.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class RepliesChannel < ApplicationCable::Channel def subscribed stream_from "topics/#{params[:topic_id]}/replies" diff --git a/app/components/alert_component.rb b/app/components/alert_component.rb index 0329026897..8b5cb7b98d 100644 --- a/app/components/alert_component.rb +++ b/app/components/alert_component.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class AlertComponent < ApplicationComponent def render? !!flash.any? diff --git a/app/components/application_component.rb b/app/components/application_component.rb index 8765b44056..8ce7ca097b 100644 --- a/app/components/application_component.rb +++ b/app/components/application_component.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class ApplicationComponent < ViewComponent::Base delegate :user_avatar_tag, :user_name_tag, :icon_tag, :icon_bold_tag, :owner?, :main_app, to: :helpers end diff --git a/app/components/profile_card_component.rb b/app/components/profile_card_component.rb index 6f3b3e3856..4bd6f64252 100644 --- a/app/components/profile_card_component.rb +++ b/app/components/profile_card_component.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class ProfileCardComponent < ApplicationComponent delegate :follow_user_tag, to: :helpers diff --git a/app/components/reply_component.rb b/app/components/reply_component.rb index 50bb27336f..dcbad796ac 100644 --- a/app/components/reply_component.rb +++ b/app/components/reply_component.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class ReplyComponent < ApplicationComponent attr_reader :reply diff --git a/app/components/reply_to_component.rb b/app/components/reply_to_component.rb index e3c6ab57e5..4e017972f4 100644 --- a/app/components/reply_to_component.rb +++ b/app/components/reply_to_component.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class ReplyToComponent < ApplicationComponent attr_reader :reply, :show_body diff --git a/app/components/topic_component.rb b/app/components/topic_component.rb index d6bc4db06d..bf5bbed001 100644 --- a/app/components/topic_component.rb +++ b/app/components/topic_component.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class TopicComponent < ApplicationComponent attr_reader :topic, :type diff --git a/app/controllers/admin/application_controller.rb b/app/controllers/admin/application_controller.rb index a68ee67679..d11f2bed3d 100644 --- a/app/controllers/admin/application_controller.rb +++ b/app/controllers/admin/application_controller.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - module Admin class ApplicationController < ::ApplicationController layout "admin" diff --git a/app/controllers/admin/applications_controller.rb b/app/controllers/admin/applications_controller.rb index 6ce3386bcf..7dc1df3fec 100644 --- a/app/controllers/admin/applications_controller.rb +++ b/app/controllers/admin/applications_controller.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - module Admin class ApplicationsController < Admin::ApplicationController before_action :set_application, only: %i[show edit update destroy] diff --git a/app/controllers/admin/comments_controller.rb b/app/controllers/admin/comments_controller.rb index 7dbdf3bcea..fd1fd46c0a 100644 --- a/app/controllers/admin/comments_controller.rb +++ b/app/controllers/admin/comments_controller.rb @@ -1,8 +1,6 @@ -# frozen_string_literal: true - module Admin class CommentsController < Admin::ApplicationController - before_action :set_comment, only: %i[show edit update destroy] + before_action :set_comment, only: %i[edit update destroy] respond_to :js, :html, only: [:destroy] def index diff --git a/app/controllers/admin/dashboards_controller.rb b/app/controllers/admin/dashboards_controller.rb index e0ef6445d1..68883dbe1a 100644 --- a/app/controllers/admin/dashboards_controller.rb +++ b/app/controllers/admin/dashboards_controller.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - module Admin class DashboardsController < Admin::ApplicationController def index diff --git a/app/controllers/admin/locations_controller.rb b/app/controllers/admin/locations_controller.rb index 36a17094e0..fc7ae76186 100644 --- a/app/controllers/admin/locations_controller.rb +++ b/app/controllers/admin/locations_controller.rb @@ -1,8 +1,6 @@ -# frozen_string_literal: true - module Admin class LocationsController < Admin::ApplicationController - before_action :set_location, only: %i[show edit update destroy] + before_action :set_location, only: %i[edit update] def index @locations = Location.hot.page(params[:page]) diff --git a/app/controllers/admin/nodes_controller.rb b/app/controllers/admin/nodes_controller.rb index 937eb10fa1..f473cfa4cf 100644 --- a/app/controllers/admin/nodes_controller.rb +++ b/app/controllers/admin/nodes_controller.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - module Admin class NodesController < Admin::ApplicationController before_action :set_node, only: %i[show edit update destroy] diff --git a/app/controllers/admin/photos_controller.rb b/app/controllers/admin/photos_controller.rb index 477bae1070..376435f22d 100644 --- a/app/controllers/admin/photos_controller.rb +++ b/app/controllers/admin/photos_controller.rb @@ -1,8 +1,6 @@ -# frozen_string_literal: true - module Admin class PhotosController < Admin::ApplicationController - before_action :set_photo, only: %i[show destroy] + before_action :set_photo, only: %i[destroy] def index @photos = Photo.recent.includes(:user) diff --git a/app/controllers/admin/plugins_controller.rb b/app/controllers/admin/plugins_controller.rb index 8ce5361207..35c01af75e 100644 --- a/app/controllers/admin/plugins_controller.rb +++ b/app/controllers/admin/plugins_controller.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - module Admin class PluginsController < Admin::ApplicationController before_action :set_plugin, only: %i[show destroy] diff --git a/app/controllers/admin/replies_controller.rb b/app/controllers/admin/replies_controller.rb index 6c305b1e0c..53fd7e028f 100644 --- a/app/controllers/admin/replies_controller.rb +++ b/app/controllers/admin/replies_controller.rb @@ -1,8 +1,6 @@ -# frozen_string_literal: true - module Admin class RepliesController < Admin::ApplicationController - before_action :set_reply, only: %i[show edit update destroy revert] + before_action :set_reply, only: %i[show edit destroy revert] def index @replies = Reply.unscoped diff --git a/app/controllers/admin/site_configs_controller.rb b/app/controllers/admin/site_configs_controller.rb index a74e64d47d..ee0c79df79 100644 --- a/app/controllers/admin/site_configs_controller.rb +++ b/app/controllers/admin/site_configs_controller.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - module Admin class SiteConfigsController < Admin::ApplicationController before_action :set_setting, only: %i[edit update] diff --git a/app/controllers/admin/stats_controller.rb b/app/controllers/admin/stats_controller.rb index 785a06f3ed..7a296303ae 100644 --- a/app/controllers/admin/stats_controller.rb +++ b/app/controllers/admin/stats_controller.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - module Admin class StatsController < Admin::ApplicationController # GET /stats @@ -7,7 +5,7 @@ class StatsController < Admin::ApplicationController # model - Model 名称 # by - day, week, month def index - result = {model: params[:model]} + result = { model: params[:model] } result[:count] = klass.unscoped.count result[:week_count] = klass.unscoped.where("created_at >= ?", Date.today.beginning_of_week).count result[:month_count] = klass.unscoped.where("created_at >= ?", Date.today.beginning_of_month).count diff --git a/app/controllers/admin/topics_controller.rb b/app/controllers/admin/topics_controller.rb index 0dcb3cd891..35699641d5 100644 --- a/app/controllers/admin/topics_controller.rb +++ b/app/controllers/admin/topics_controller.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - module Admin class TopicsController < Admin::ApplicationController before_action :set_topic, only: %i[show edit update destroy revert suggest unsuggest] diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index d4070d23d2..5657266878 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - module Admin class UsersController < Admin::ApplicationController def index diff --git a/app/controllers/api/v3/application_controller.rb b/app/controllers/api/v3/application_controller.rb index 716d9b8deb..39ed26b0cb 100644 --- a/app/controllers/api/v3/application_controller.rb +++ b/app/controllers/api/v3/application_controller.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - module Api module V3 # @abstract @@ -42,16 +40,16 @@ class AccessDenied < StandardError; end class PageNotFound < StandardError; end rescue_from(ActionController::ParameterMissing) do |err| - render json: {error: "ParameterInvalid", message: err}, status: 400 + render json: { error: "ParameterInvalid", message: err }, status: 400 end rescue_from(ActiveRecord::RecordInvalid) do |err| - render json: {error: "RecordInvalid", message: err}, status: 400 + render json: { error: "RecordInvalid", message: err }, status: 400 end rescue_from(AccessDenied) do |err| - render json: {error: "AccessDenied", message: err}, status: 403 + render json: { error: "AccessDenied", message: err }, status: 403 end rescue_from(ActiveRecord::RecordNotFound) do - render json: {error: "ResourceNotFound"}, status: 404 + render json: { error: "ResourceNotFound" }, status: 404 end def requires!(name, opts = {}) @@ -79,7 +77,7 @@ def error!(data, status_code = 400) end def error_404! - error!({"error" => "Page not found"}, 404) + error!({ "error" => "Page not found" }, 404) end def current_user diff --git a/app/controllers/api/v3/devices_controller.rb b/app/controllers/api/v3/devices_controller.rb index 9d59667893..7fcbb59ff5 100644 --- a/app/controllers/api/v3/devices_controller.rb +++ b/app/controllers/api/v3/devices_controller.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - module Api module V3 class DevicesController < Api::V3::ApplicationController @@ -28,7 +26,7 @@ def create @device.last_actived_at = Time.now @device.save! - render json: {ok: 1} + render json: { ok: 1 } end # 删除 Device 信息,请注意在用户登出或删除应用的时候调用,以便能确保清理掉 @@ -40,7 +38,7 @@ def destroy requires! :platform, type: String, values: %w[ios android] requires! :token, type: String current_user.devices.where(platform: params[:platform].downcase, token: params[:token]).delete_all - render json: {ok: 1} + render json: { ok: 1 } end end end diff --git a/app/controllers/api/v3/likes_controller.rb b/app/controllers/api/v3/likes_controller.rb index 8621820034..aeae50ac59 100644 --- a/app/controllers/api/v3/likes_controller.rb +++ b/app/controllers/api/v3/likes_controller.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - module Api module V3 class LikesController < Api::V3::ApplicationController @@ -22,7 +20,7 @@ class LikesController < Api::V3::ApplicationController def create current_user.like(likeable) likeable.reload - data = {obj_type: params[:obj_type], obj_id: likeable.id, count: likeable.likes_count} + data = { obj_type: params[:obj_type], obj_id: likeable.id, count: likeable.likes_count } render json: data end @@ -35,7 +33,7 @@ def create def destroy current_user.unlike(likeable) likeable.reload - data = {obj_type: params[:obj_type], obj_id: likeable.id, count: likeable.likes_count} + data = { obj_type: params[:obj_type], obj_id: likeable.id, count: likeable.likes_count } render json: data end diff --git a/app/controllers/api/v3/nodes_controller.rb b/app/controllers/api/v3/nodes_controller.rb index 632da29fd7..840beb7c16 100644 --- a/app/controllers/api/v3/nodes_controller.rb +++ b/app/controllers/api/v3/nodes_controller.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - module Api module V3 class NodesController < Api::V3::ApplicationController @@ -9,7 +7,7 @@ class NodesController < Api::V3::ApplicationController # @return [Array] def index @nodes = Node.sorted.all - @meta = {total: Node.count} + @meta = { total: Node.count } end ## diff --git a/app/controllers/api/v3/notifications_controller.rb b/app/controllers/api/v3/notifications_controller.rb index df81c1f949..6b3fa06ed8 100644 --- a/app/controllers/api/v3/notifications_controller.rb +++ b/app/controllers/api/v3/notifications_controller.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - module Api module V3 class NotificationsController < Api::V3::ApplicationController @@ -31,7 +29,7 @@ def read ids = current_user.notifications.where(id: params[:ids]).pluck(:id) Notification.read!(current_user, ids) - render json: {ok: 1} + render json: { ok: 1 } end # 删除当前用户的所有通知 @@ -39,7 +37,7 @@ def read # DELETE /api/v3/notifications/all def all current_user.notifications.delete_all - render json: {ok: 1} + render json: { ok: 1 } end # 获得未读通知数量 @@ -48,7 +46,7 @@ def all # == returns # - count [Integer] 消息数量 def unread_count - render json: {count: Notification.unread_count(current_user)} + render json: { count: Notification.unread_count(current_user) } end # 删除当前用户的某个通知 @@ -57,7 +55,7 @@ def unread_count def destroy @notification = current_user.notifications.find(params[:id]) @notification.destroy - render json: {ok: 1} + render json: { ok: 1 } end end end diff --git a/app/controllers/api/v3/photos_controller.rb b/app/controllers/api/v3/photos_controller.rb index 3248062175..6bd40b977e 100644 --- a/app/controllers/api/v3/photos_controller.rb +++ b/app/controllers/api/v3/photos_controller.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - module Api module V3 class PhotosController < Api::V3::ApplicationController diff --git a/app/controllers/api/v3/replies_controller.rb b/app/controllers/api/v3/replies_controller.rb index 2b9d4b0476..9d80d236ac 100644 --- a/app/controllers/api/v3/replies_controller.rb +++ b/app/controllers/api/v3/replies_controller.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - module Api module V3 class RepliesController < Api::V3::ApplicationController @@ -36,7 +34,7 @@ def destroy raise AccessDenied unless can?(:destroy, @reply) @reply.destroy - render json: {ok: 1} + render json: { ok: 1 } end private diff --git a/app/controllers/api/v3/root_controller.rb b/app/controllers/api/v3/root_controller.rb index 10b7205a2a..257d5057f7 100644 --- a/app/controllers/api/v3/root_controller.rb +++ b/app/controllers/api/v3/root_controller.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - module Api module V3 class RootController < Api::V3::ApplicationController @@ -18,7 +16,7 @@ def not_found def hello optional! :limit, values: 0..100 - @meta = {time: Time.now} + @meta = { time: Time.now } @user = current_user render "api/v3/users/show" diff --git a/app/controllers/api/v3/topics_controller.rb b/app/controllers/api/v3/topics_controller.rb index 69d3f86091..6a22a5a44b 100644 --- a/app/controllers/api/v3/topics_controller.rb +++ b/app/controllers/api/v3/topics_controller.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - module Api module V3 class TopicsController < Api::V3::ApplicationController @@ -60,7 +58,7 @@ def index # { followed: 'Is followed this Topic', liked: 'Is liked this Topic', favorited: 'Is favorited this Topic' } # ``` def show - @meta = {followed: false, liked: false, favorited: false} + @meta = { followed: false, liked: false, favorited: false } if current_user current_user.touch_last_online_ts @@ -131,7 +129,7 @@ def update def destroy raise AccessDenied unless can?(:destroy, @topic) @topic.destroy_by(current_user) - render json: {ok: 1} + render json: { ok: 1 } end # 获取话题的回帖列表 @@ -152,7 +150,7 @@ def replies @replies = Reply.unscoped.where(topic_id: @topic.id).order(:id).includes(:user) @replies = @replies.offset(params[:offset].to_i).limit(params[:limit].to_i) @user_liked_reply_ids = current_user&.like_reply_ids_by_replies(@replies) || [] - @meta = {user_liked_reply_ids: @user_liked_reply_ids} + @meta = { user_liked_reply_ids: @user_liked_reply_ids } end # 创建对话题的回帖 @@ -179,7 +177,7 @@ def create_replies # POST /api/v3/topics/:id/follow def follow current_user.follow_topic(@topic) - render json: {ok: 1} + render json: { ok: 1 } end # Unfollow Topic @@ -187,7 +185,7 @@ def follow # POST /api/v3/topics/:id/unfollow def unfollow current_user.unfollow_topic(@topic) - render json: {ok: 1} + render json: { ok: 1 } end # Favorite Topic @@ -195,7 +193,7 @@ def unfollow # POST /api/v3/topics/:id/favorite def favorite current_user.favorite_topic(@topic.id) - render json: {ok: 1} + render json: { ok: 1 } end # Unfovorite Topic @@ -203,7 +201,7 @@ def favorite # POST /api/v3/topics/:id/unfavorite def unfavorite current_user.unfavorite_topic(@topic.id) - render json: {ok: 1} + render json: { ok: 1 } end # Ban Topic (Admin only) @@ -213,7 +211,7 @@ def unfavorite def ban raise AccessDenied.new("The current user does not have the authority to block other people's topics.") unless can?(:ban, @topic) @topic.ban! - render json: {ok: 1} + render json: { ok: 1 } end # Actions @@ -238,7 +236,7 @@ def action when "open" @topic.open! end - render json: {ok: 1} + render json: { ok: 1 } end private diff --git a/app/controllers/api/v3/users_controller.rb b/app/controllers/api/v3/users_controller.rb index d26b8c6dd1..118e1f3ada 100644 --- a/app/controllers/api/v3/users_controller.rb +++ b/app/controllers/api/v3/users_controller.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - module Api module V3 class UsersController < Api::V3::ApplicationController @@ -33,7 +31,7 @@ def me # GET /api/v3/users/:id # @return [UserDetailSerializer] def show - @meta = {followed: false, blocked: false} + @meta = { followed: false, blocked: false } if current_user @meta[:followed] = current_user.follow_user?(@user) @@ -148,7 +146,7 @@ def blocked # POST /api/v3/users/:id/follow def follow current_user.follow_user(@user) - render json: {ok: 1} + render json: { ok: 1 } end # Unfollow user @@ -156,7 +154,7 @@ def follow # POST /api/v3/users/:id/unfollow def unfollow current_user.unfollow_user(@user) - render json: {ok: 1} + render json: { ok: 1 } end # Block user @@ -164,7 +162,7 @@ def unfollow # POST /api/v3/users/:id/block def block current_user.block_user(@user.id) - render json: {ok: 1} + render json: { ok: 1 } end # Unblock user @@ -172,7 +170,7 @@ def block # POST /api/v3/users/:id/unblock def unblock current_user.unblock_user(@user.id) - render json: {ok: 1} + render json: { ok: 1 } end private diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 9e10ea8ed2..d163815345 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - # ApplicationController class ApplicationController < ActionController::Base include Localize diff --git a/app/controllers/application_controller/current_info.rb b/app/controllers/application_controller/current_info.rb index 4049f5fdde..fe3545e2d0 100644 --- a/app/controllers/application_controller/current_info.rb +++ b/app/controllers/application_controller/current_info.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class ApplicationController module CurrentInfo extend ActiveSupport::Concern diff --git a/app/controllers/application_controller/deviseable.rb b/app/controllers/application_controller/deviseable.rb index bd7481a87a..f86a9ec744 100644 --- a/app/controllers/application_controller/deviseable.rb +++ b/app/controllers/application_controller/deviseable.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class ApplicationController module Deviseable extend ActiveSupport::Concern diff --git a/app/controllers/application_controller/localize.rb b/app/controllers/application_controller/localize.rb index 0763d76da0..5f417112f7 100644 --- a/app/controllers/application_controller/localize.rb +++ b/app/controllers/application_controller/localize.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class ApplicationController module Localize extend ActiveSupport::Concern diff --git a/app/controllers/application_controller/turbolinks.rb b/app/controllers/application_controller/turbolinks.rb index 09caf33293..2f058864ff 100644 --- a/app/controllers/application_controller/turbolinks.rb +++ b/app/controllers/application_controller/turbolinks.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class ApplicationController module Turbolinks extend ActiveSupport::Concern diff --git a/app/controllers/application_controller/user_notifications.rb b/app/controllers/application_controller/user_notifications.rb index e15aa42534..f7419ed5e4 100644 --- a/app/controllers/application_controller/user_notifications.rb +++ b/app/controllers/application_controller/user_notifications.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class ApplicationController module UserNotifications extend ActiveSupport::Concern diff --git a/app/controllers/auth/sso_controller.rb b/app/controllers/auth/sso_controller.rb index 7b96d9271e..cb7a8dcde8 100644 --- a/app/controllers/auth/sso_controller.rb +++ b/app/controllers/auth/sso_controller.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - module Auth class SSOController < ApplicationController def show diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index deab64d635..19577a1362 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class CommentsController < ApplicationController before_action :authenticate_user! diff --git a/app/controllers/devices_controller.rb b/app/controllers/devices_controller.rb index 685d5d6f88..7eef2d3d0c 100644 --- a/app/controllers/devices_controller.rb +++ b/app/controllers/devices_controller.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class DevicesController < ApplicationController before_action :authenticate_user! diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index d1fff334b4..0f18c2e7b5 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class HomeController < ApplicationController def uploads return render_404 if Rails.env.production? diff --git a/app/controllers/likes_controller.rb b/app/controllers/likes_controller.rb index a42dd30413..01d4a43e89 100644 --- a/app/controllers/likes_controller.rb +++ b/app/controllers/likes_controller.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class LikesController < ApplicationController before_action :authenticate_user!, only: %i[create destroy] before_action :set_likeable diff --git a/app/controllers/nodes_controller.rb b/app/controllers/nodes_controller.rb index dbbf474f97..4411368d45 100644 --- a/app/controllers/nodes_controller.rb +++ b/app/controllers/nodes_controller.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class NodesController < ApplicationController before_action :authenticate_user!, only: %i[block unblock] @@ -10,11 +8,11 @@ def index def block current_user.block_node(params[:id]) - render json: {code: 0} + render json: { code: 0 } end def unblock current_user.unblock_node(params[:id]) - render json: {code: 0} + render json: { code: 0 } end end diff --git a/app/controllers/notifications/notifications_controller.rb b/app/controllers/notifications/notifications_controller.rb index fef19e131f..b0fa27da84 100644 --- a/app/controllers/notifications/notifications_controller.rb +++ b/app/controllers/notifications/notifications_controller.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - module Notifications class NotificationsController < Notifications::ApplicationController def index @@ -10,7 +8,7 @@ def index def read Notification.read!(current_user, params[:ids]) - render json: {ok: 1} + render json: { ok: 1 } end def clean diff --git a/app/controllers/oauth/applications_controller.rb b/app/controllers/oauth/applications_controller.rb index adeba79930..4d462adf28 100644 --- a/app/controllers/oauth/applications_controller.rb +++ b/app/controllers/oauth/applications_controller.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - module Oauth class ApplicationsController < Doorkeeper::ApplicationsController before_action :authenticate_user! @@ -52,7 +50,7 @@ def update else respond_to do |format| format.html { render :edit } - format.json { render json: {errors: @application.errors.full_messages}, status: :unprocessable_entity } + format.json { render json: { errors: @application.errors.full_messages }, status: :unprocessable_entity } end end end diff --git a/app/controllers/oauth/authorized_applications_controller.rb b/app/controllers/oauth/authorized_applications_controller.rb index fa4f3a51b7..902c5ec9a5 100644 --- a/app/controllers/oauth/authorized_applications_controller.rb +++ b/app/controllers/oauth/authorized_applications_controller.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - module Oauth class AuthorizedApplicationsController < Doorkeeper::ApplicationController before_action :authenticate_resource_owner! diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index a702c6bbd3..8f117589a2 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -1,20 +1,18 @@ -# frozen_string_literal: true - class PhotosController < ApplicationController load_and_authorize_resource def create if params[:file].blank? - render json: {ok: false}, status: 400 + render json: { ok: false }, status: 400 return end # 浮动窗口上传 @photo = Photo.new(image: params[:file], user: current_user) if @photo.save - render json: {ok: true, url: @photo.image.url(:large)} + render json: { ok: true, url: @photo.image.url(:large) } else - render json: {ok: false, message: @photo.errors.full_messages.join}, status: 400 + render json: { ok: false, message: @photo.errors.full_messages.join }, status: 400 end end end diff --git a/app/controllers/replies_controller.rb b/app/controllers/replies_controller.rb index 248dba2f21..7260ae716f 100644 --- a/app/controllers/replies_controller.rb +++ b/app/controllers/replies_controller.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class RepliesController < ApplicationController load_and_authorize_resource :reply diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index 25647c7024..56ad054686 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class SearchController < ApplicationController before_action :authenticate_user!, only: [:users] @@ -17,6 +15,6 @@ def index def users @result = User.search(params[:q], user: current_user, limit: params[:limit] || 10) - render json: @result.collect { |u| {login: u.login, name: u.name, avatar_url: u.large_avatar_url} } + render json: @result.collect { |u| { login: u.login, name: u.name, avatar_url: u.large_avatar_url } } end end diff --git a/app/controllers/settings_controller.rb b/app/controllers/settings_controller.rb index 2559789b84..1192b9c475 100644 --- a/app/controllers/settings_controller.rb +++ b/app/controllers/settings_controller.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class SettingsController < ApplicationController before_action :authenticate_user! before_action :set_user diff --git a/app/controllers/team_users_controller.rb b/app/controllers/team_users_controller.rb index 7a08d59e9d..e50eb602ee 100644 --- a/app/controllers/team_users_controller.rb +++ b/app/controllers/team_users_controller.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class TeamUsersController < ApplicationController require_module_enabled! :team diff --git a/app/controllers/teams_controller.rb b/app/controllers/teams_controller.rb index cfddae5224..8d30d15506 100644 --- a/app/controllers/teams_controller.rb +++ b/app/controllers/teams_controller.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class TeamsController < ApplicationController require_module_enabled! :team load_resource find_by: :login diff --git a/app/controllers/topics/list_actions.rb b/app/controllers/topics/list_actions.rb index 9e91690ecf..de666f843b 100644 --- a/app/controllers/topics/list_actions.rb +++ b/app/controllers/topics/list_actions.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - module Topics module ListActions extend ActiveSupport::Concern diff --git a/app/controllers/topics_controller.rb b/app/controllers/topics_controller.rb index 148ec2328c..86f14addbf 100644 --- a/app/controllers/topics_controller.rb +++ b/app/controllers/topics_controller.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class TopicsController < ApplicationController include Topics::ListActions @@ -59,7 +57,7 @@ def show def read cookie_read_flag = "_topic_#{@topic.id}_read".to_sym if cookies[cookie_read_flag].blank? - cookies[cookie_read_flag] = {value: "1", expires: 1.minutes} + cookies[cookie_read_flag] = { value: "1", expires: 1.minutes } @topic.hits.incr(1) end current_user&.read_topic(@topic) diff --git a/app/controllers/users/omniauth_callbacks_controller.rb b/app/controllers/users/omniauth_callbacks_controller.rb index f83cf9a0a3..e0afc322d2 100644 --- a/app/controllers/users/omniauth_callbacks_controller.rb +++ b/app/controllers/users/omniauth_callbacks_controller.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController User.omniauth_providers.each do |provider| send(:define_method, provider) do diff --git a/app/controllers/users/passwords_controller.rb b/app/controllers/users/passwords_controller.rb index fc0f530d80..16b60fe607 100644 --- a/app/controllers/users/passwords_controller.rb +++ b/app/controllers/users/passwords_controller.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class Users::PasswordsController < Devise::PasswordsController before_action :require_no_sso! @@ -17,7 +15,7 @@ def create yield resource if block_given? if successfully_sent?(resource) - respond_with({}, {location: after_sending_reset_password_instructions_path_for(resource_name)}) + respond_with({}, { location: after_sending_reset_password_instructions_path_for(resource_name) }) else respond_with(resource) end diff --git a/app/controllers/users/registrations_controller.rb b/app/controllers/users/registrations_controller.rb index 93a0d5ddac..75f3190c5a 100644 --- a/app/controllers/users/registrations_controller.rb +++ b/app/controllers/users/registrations_controller.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class Users::RegistrationsController < Devise::RegistrationsController before_action :require_no_sso!, only: %i[new create] diff --git a/app/controllers/users/sessions_controller.rb b/app/controllers/users/sessions_controller.rb index 4d433683a0..389fef9a48 100644 --- a/app/controllers/users/sessions_controller.rb +++ b/app/controllers/users/sessions_controller.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class Users::SessionsController < Devise::SessionsController before_action :require_no_sso!, only: %i[new create] diff --git a/app/controllers/users/team_actions.rb b/app/controllers/users/team_actions.rb index dda66a82a6..9dd5cb3ed8 100644 --- a/app/controllers/users/team_actions.rb +++ b/app/controllers/users/team_actions.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - module Users module TeamActions extend ActiveSupport::Concern diff --git a/app/controllers/users/user_actions.rb b/app/controllers/users/user_actions.rb index 1d461bcc04..d7a4c281e4 100644 --- a/app/controllers/users/user_actions.rb +++ b/app/controllers/users/user_actions.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - module Users module UserActions extend ActiveSupport::Concern @@ -28,12 +26,12 @@ def favorites def block current_user.block_user(@user.id) - render json: {code: 0} + render json: { code: 0 } end def unblock current_user.unblock_user(@user.id) - render json: {code: 0} + render json: { code: 0 } end def blocked @@ -46,12 +44,12 @@ def blocked def follow current_user.follow_user(@user) - render json: {code: 0, data: {followers_count: @user.reload.followers_count}} + render json: { code: 0, data: { followers_count: @user.reload.followers_count } } end def unfollow current_user.unfollow_user(@user) - render json: {code: 0, data: {followers_count: @user.reload.followers_count}} + render json: { code: 0, data: { followers_count: @user.reload.followers_count } } end def followers diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 7f9da33abe..279e01edb4 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class UsersController < ApplicationController before_action :set_user, except: %i[index city] before_action :check_exist!, except: %i[index city block unblock diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index dd6057b0d0..3e14447ba7 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - module ApplicationHelper def markdown(text) return nil if text.blank? @@ -66,7 +64,7 @@ def insert_code_menu_items_tag Setting.editor_languages.each do |lang| lexer = Rouge::Lexer.find(lang) if lexer - dropdown_items << link_to(lexer.title, "#", class: "dropdown-item", data: {lang: lang}) + dropdown_items << link_to(lexer.title, "#", class: "dropdown-item", data: { lang: lang }) end end raw dropdown_items.join("") diff --git a/app/helpers/likes_helper.rb b/app/helpers/likes_helper.rb index a585172e91..a3aa23f94d 100644 --- a/app/helpers/likes_helper.rb +++ b/app/helpers/likes_helper.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - module LikesHelper # Likeable Helper # diff --git a/app/helpers/locations_helper.rb b/app/helpers/locations_helper.rb index c5db00f6ac..e028300bcf 100644 --- a/app/helpers/locations_helper.rb +++ b/app/helpers/locations_helper.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - module LocationsHelper def location_name_tag(location, _options = {}) return "" if location.blank? diff --git a/app/helpers/nodes_helper.rb b/app/helpers/nodes_helper.rb index 29d8861df2..673b561143 100644 --- a/app/helpers/nodes_helper.rb +++ b/app/helpers/nodes_helper.rb @@ -1,4 +1,2 @@ -# frozen_string_literal: true - module NodesHelper end diff --git a/app/helpers/teams_helper.rb b/app/helpers/teams_helper.rb index 08b20a0638..5a7d7ee740 100644 --- a/app/helpers/teams_helper.rb +++ b/app/helpers/teams_helper.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - module TeamsHelper def team_member_counts_tag(team) count_text = t("teams.team_users_count", count: team.team_users_count) diff --git a/app/helpers/topics_helper.rb b/app/helpers/topics_helper.rb index 82da137cb0..41b1b766aa 100644 --- a/app/helpers/topics_helper.rb +++ b/app/helpers/topics_helper.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - require "digest/md5" module TopicsHelper def topic_favorite_tag(topic, opts = {}) diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index 857018e38d..714087073b 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - require "digest/md5" module UsersHelper diff --git a/app/jobs/application_job.rb b/app/jobs/application_job.rb index d92ffddcb5..a009ace51c 100644 --- a/app/jobs/application_job.rb +++ b/app/jobs/application_job.rb @@ -1,4 +1,2 @@ -# frozen_string_literal: true - class ApplicationJob < ActiveJob::Base end diff --git a/app/jobs/async_job.rb b/app/jobs/async_job.rb index 0fe2e8ab9a..2a5d38f690 100644 --- a/app/jobs/async_job.rb +++ b/app/jobs/async_job.rb @@ -1,10 +1,4 @@ -# frozen_string_literal: true - # We use ActiveJob::QueueAdapters::AsyncAdapter for lite jobs for run queue in Rails Process as async. # https://api.rubyonrails.org/classes/ActiveJob/QueueAdapters/AsyncAdapter.html class AsyncJob < ActiveJob::Base - self.queue_adapter = Rails.env.test? ? :inline : ActiveJob::QueueAdapters::AsyncAdapter.new( - min_threads: 4, - max_threads: 10 * Concurrent.processor_count - ) end diff --git a/app/jobs/github_repo_fetcher_job.rb b/app/jobs/github_repo_fetcher_job.rb index 862d8d4d39..9f81002a5d 100644 --- a/app/jobs/github_repo_fetcher_job.rb +++ b/app/jobs/github_repo_fetcher_job.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class GitHubRepoFetcherJob < ApplicationJob queue_as :http_request diff --git a/app/jobs/mention_topic_job.rb b/app/jobs/mention_topic_job.rb index e1ec02c3b8..b973290be6 100644 --- a/app/jobs/mention_topic_job.rb +++ b/app/jobs/mention_topic_job.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class MentionTopicJob < ApplicationJob queue_as :notifications diff --git a/app/jobs/notify_reply_job.rb b/app/jobs/notify_reply_job.rb index 8ae86ffbbb..8a04338ffa 100644 --- a/app/jobs/notify_reply_job.rb +++ b/app/jobs/notify_reply_job.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class NotifyReplyJob < ApplicationJob queue_as :notifications diff --git a/app/jobs/notify_topic_job.rb b/app/jobs/notify_topic_job.rb index 57f2dc61d4..d87f3aa22a 100644 --- a/app/jobs/notify_topic_job.rb +++ b/app/jobs/notify_topic_job.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class NotifyTopicJob < ApplicationJob queue_as :notifications @@ -13,7 +11,7 @@ def perform(topic_id) notified_user_ids = topic.mentioned_user_ids # Send notification for followers - default_note = {notify_type: "topic", target_type: "Topic", target_id: topic.id, actor_id: topic.user_id, created_at: Time.now, updated_at: Time.now} + default_note = { notify_type: "topic", target_type: "Topic", target_id: topic.id, actor_id: topic.user_id, created_at: Time.now, updated_at: Time.now } all_records = [] follower_ids.each do |uid| diff --git a/app/jobs/notify_topic_node_changed_job.rb b/app/jobs/notify_topic_node_changed_job.rb index 34997f4416..eaf2051e2e 100644 --- a/app/jobs/notify_topic_node_changed_job.rb +++ b/app/jobs/notify_topic_node_changed_job.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class NotifyTopicNodeChangedJob < AsyncJob def perform(topic_id, node_id:) topic = Topic.find_by_id(topic_id) diff --git a/app/jobs/push_job.rb b/app/jobs/push_job.rb index 601cb7323d..a9b72dd856 100644 --- a/app/jobs/push_job.rb +++ b/app/jobs/push_job.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class PushJob < ApplicationJob queue_as :notifications diff --git a/app/jobs/scheduler/doorkeeper_cleanup_job.rb b/app/jobs/scheduler/doorkeeper_cleanup_job.rb index 498fbb48cf..48e43bc366 100644 --- a/app/jobs/scheduler/doorkeeper_cleanup_job.rb +++ b/app/jobs/scheduler/doorkeeper_cleanup_job.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - module Scheduler class DoorkeeperCleanupJob < ApplicationJob def perform diff --git a/app/jobs/scheduler/notification_cleanup_job.rb b/app/jobs/scheduler/notification_cleanup_job.rb index f885088ba1..433f10d7a0 100644 --- a/app/jobs/scheduler/notification_cleanup_job.rb +++ b/app/jobs/scheduler/notification_cleanup_job.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - module Scheduler # cleanup notifications at 1 years ago class NotificationCleanupJob < ApplicationJob diff --git a/app/jobs/scheduler/online_user_stats_job.rb b/app/jobs/scheduler/online_user_stats_job.rb index 341e8446f5..dcd7c63910 100644 --- a/app/jobs/scheduler/online_user_stats_job.rb +++ b/app/jobs/scheduler/online_user_stats_job.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - module Scheduler # Cleanup inactive user record from redis class OnlineUserStatsJob < ApplicationJob diff --git a/app/jobs/scheduler/spam_cleanup_job.rb b/app/jobs/scheduler/spam_cleanup_job.rb index a2801eb485..015e187a01 100644 --- a/app/jobs/scheduler/spam_cleanup_job.rb +++ b/app/jobs/scheduler/spam_cleanup_job.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - module Scheduler # cleanup spam topic at 1 month ago class SpamCleanupJob < ApplicationJob diff --git a/app/jobs/scheduler/total_user_stats_job.rb b/app/jobs/scheduler/total_user_stats_job.rb index 47355d4b77..9f3ebdeb8e 100644 --- a/app/jobs/scheduler/total_user_stats_job.rb +++ b/app/jobs/scheduler/total_user_stats_job.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - module Scheduler # Count user replies count in recent class TotalUserStatsJob < ApplicationJob diff --git a/app/jobs/topic_read_job.rb b/app/jobs/topic_read_job.rb index 36528205d9..852f1d7afe 100644 --- a/app/jobs/topic_read_job.rb +++ b/app/jobs/topic_read_job.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class TopicReadJob < AsyncJob def perform(topic_id:, user_id:, replies_ids: nil) topic = Topic.find_by_id(topic_id) diff --git a/app/jobs/topic_reference_job.rb b/app/jobs/topic_reference_job.rb index ab9dab4c15..a597519a26 100644 --- a/app/jobs/topic_reference_job.rb +++ b/app/jobs/topic_reference_job.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class TopicReferenceJob < AsyncJob REFERENCE_PATTERN = %r{/topics/(\d+)} diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb index ba193b68c5..5e95586543 100644 --- a/app/mailers/application_mailer.rb +++ b/app/mailers/application_mailer.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class ApplicationMailer < ActionMailer::Base layout "mailer" helper :topics, :users diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index 586ec5c2d5..9a8994883e 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class UserMailer < ApplicationMailer def welcome(user_id) @user = User.find_by_id(user_id) diff --git a/app/models/ability.rb b/app/models/ability.rb index e35780d71b..750fa87de4 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class Ability include CanCan::Ability @@ -75,7 +73,7 @@ def roles_for_replies # For block spam, disalow Newbie reply at night. can :create, Reply unless current_lock_reply? can %i[update destroy], Reply, user_id: user.id - cannot %i[create update destroy], Reply, topic: {closed?: true} + cannot %i[create update destroy], Reply, topic: { closed?: true } end def current_lock_reply? diff --git a/app/models/application_record.rb b/app/models/application_record.rb index 4059fadacc..a70cb31c40 100644 --- a/app/models/application_record.rb +++ b/app/models/application_record.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class ApplicationRecord < ActiveRecord::Base primary_abstract_class diff --git a/app/models/authorization.rb b/app/models/authorization.rb index 971ab8ef17..0aa5aea337 100644 --- a/app/models/authorization.rb +++ b/app/models/authorization.rb @@ -1,10 +1,8 @@ -# frozen_string_literal: true - class Authorization < ApplicationRecord belongs_to :user validates :uid, :provider, presence: true - validates :uid, uniqueness: {scope: :provider} + validates :uid, uniqueness: { scope: :provider } def self.find_user_by_provider(provider, uid) where(provider: provider, uid: uid).first&.user diff --git a/app/models/cache_version.rb b/app/models/cache_version.rb index 870bc40008..bdaf9e591b 100644 --- a/app/models/cache_version.rb +++ b/app/models/cache_version.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - # Save speical cache version # For example: # Record last update, pin topic time for update cache_key to expire cache that used this key. diff --git a/app/models/comment.rb b/app/models/comment.rb index dac8d6d75d..d53dc75e69 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class Comment < ApplicationRecord include UserAvatarDelegate include Mentionable diff --git a/app/models/concerns/closeable.rb b/app/models/concerns/closeable.rb index f60df5eab0..6ade7f8038 100644 --- a/app/models/concerns/closeable.rb +++ b/app/models/concerns/closeable.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - # 开启关闭帖子功能 module Closeable extend ActiveSupport::Concern diff --git a/app/models/concerns/markdown_body.rb b/app/models/concerns/markdown_body.rb index daab2e7da6..e3250b0568 100644 --- a/app/models/concerns/markdown_body.rb +++ b/app/models/concerns/markdown_body.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - # 转换 body -> html # [Plugin API] module MarkdownBody diff --git a/app/models/concerns/mention_topic.rb b/app/models/concerns/mention_topic.rb index bdfea699f5..5ba4f49bb5 100644 --- a/app/models/concerns/mention_topic.rb +++ b/app/models/concerns/mention_topic.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - module MentionTopic extend ActiveSupport::Concern diff --git a/app/models/concerns/mentionable.rb b/app/models/concerns/mentionable.rb index 76f2c0a468..00f5f60b9b 100644 --- a/app/models/concerns/mentionable.rb +++ b/app/models/concerns/mentionable.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - module Mentionable extend ActiveSupport::Concern diff --git a/app/models/concerns/redis_countable.rb b/app/models/concerns/redis_countable.rb index eae36126c1..68b460cec2 100644 --- a/app/models/concerns/redis_countable.rb +++ b/app/models/concerns/redis_countable.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - # 增加访问量的功能 module RedisCountable extend ActiveSupport::Concern diff --git a/app/models/concerns/scoped_setting.rb b/app/models/concerns/scoped_setting.rb index ac572d0921..109c6484a2 100644 --- a/app/models/concerns/scoped_setting.rb +++ b/app/models/concerns/scoped_setting.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - # Backward compatible to support RailsSettingsCached 0.x scoped settings module ScopedSetting extend ActiveSupport::Concern diff --git a/app/models/concerns/searchable.rb b/app/models/concerns/searchable.rb index 8872b944d8..0b595926a2 100644 --- a/app/models/concerns/searchable.rb +++ b/app/models/concerns/searchable.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - module Searchable extend ActiveSupport::Concern diff --git a/app/models/concerns/soft_delete.rb b/app/models/concerns/soft_delete.rb index 421c03c615..2783d01cde 100644 --- a/app/models/concerns/soft_delete.rb +++ b/app/models/concerns/soft_delete.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - module SoftDelete extend ActiveSupport::Concern diff --git a/app/models/concerns/user_avatar_delegate.rb b/app/models/concerns/user_avatar_delegate.rb index 3eb250c1c1..d154b4ce92 100644 --- a/app/models/concerns/user_avatar_delegate.rb +++ b/app/models/concerns/user_avatar_delegate.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - module UserAvatarDelegate extend ActiveSupport::Concern diff --git a/app/models/current.rb b/app/models/current.rb index 7d8c58c08c..abea48b7e8 100644 --- a/app/models/current.rb +++ b/app/models/current.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class Current < ActiveSupport::CurrentAttributes attribute :request_id attribute :user diff --git a/app/models/device.rb b/app/models/device.rb index bb90ac87df..9f2cc72f74 100644 --- a/app/models/device.rb +++ b/app/models/device.rb @@ -1,12 +1,10 @@ -# frozen_string_literal: true - class Device < ApplicationRecord belongs_to :user - enum platform: %i[ios android] + enum :platform, %i[ios android] validates :platform, :token, presence: true - validates :token, uniqueness: {scope: %i[user_id platform]} + validates :token, uniqueness: { scope: %i[user_id platform] } def alive? return true if last_actived_at.blank? diff --git a/app/models/location.rb b/app/models/location.rb index 9799dc0cdc..10212dd78f 100644 --- a/app/models/location.rb +++ b/app/models/location.rb @@ -1,13 +1,9 @@ -# frozen_string_literal: true - class Location < ApplicationRecord - second_level_cache expires_in: 2.weeks - has_many :users scope :hot, -> { order(users_count: :desc).where.not(users_count: 0) } - validates :name, presence: true, uniqueness: {case_sensitive: false} + validates :name, presence: true, uniqueness: { case_sensitive: false } before_save { |loc| loc.name = loc.name.downcase.strip } diff --git a/app/models/node.rb b/app/models/node.rb index 9fcbb0a2fa..afd3c5e6a5 100644 --- a/app/models/node.rb +++ b/app/models/node.rb @@ -1,8 +1,4 @@ -# frozen_string_literal: true - class Node < ApplicationRecord - second_level_cache expires_in: 2.weeks - has_many :topics validates :name, presence: true diff --git a/app/models/notification.rb b/app/models/notification.rb index 116fd86a7a..ec0079e0df 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - # Auto generate with notifications gem. class Notification < ActiveRecord::Base include Notifications::Model @@ -15,7 +13,7 @@ def realtime_push_to_client end def self.realtime_push_to_client(user) - message = {count: Notification.unread_count(user)} + message = { count: Notification.unread_count(user) } ActionCable.server.broadcast("notifications_count/#{user.id}", message) end @@ -24,7 +22,7 @@ def self.unread_count(user) end def apns_note - @note ||= {alert: notify_title, badge: Notification.unread_count(user)} + @note ||= { alert: notify_title, badge: Notification.unread_count(user) } end def notify_title diff --git a/app/models/photo.rb b/app/models/photo.rb index 4ba98c256c..57c26a91b8 100644 --- a/app/models/photo.rb +++ b/app/models/photo.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class Photo < ApplicationRecord belongs_to :user, optional: true diff --git a/app/models/profile.rb b/app/models/profile.rb index a13fe7a0ae..92786fab34 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class Profile < ApplicationRecord belongs_to :user diff --git a/app/models/reply.rb b/app/models/reply.rb index f45815973b..82b53330a9 100644 --- a/app/models/reply.rb +++ b/app/models/reply.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - require "digest/md5" class Reply < ApplicationRecord @@ -24,7 +22,7 @@ class Reply < ApplicationRecord scope :fields_for_list, -> { select(:topic_id, :id, :body, :updated_at, :created_at) } validates :body, presence: true, unless: -> { system_event? } - validates :body, uniqueness: {scope: %i[topic_id user_id], message: I18n.t("replies.duplicate_error")}, unless: -> { system_event? } + validates :body, uniqueness: { scope: %i[topic_id user_id], message: I18n.t("replies.duplicate_error") }, unless: -> { system_event? } validate do ban_words = Setting.ban_words_on_reply.collect(&:strip) if !system_event? && body&.strip&.downcase&.in?(ban_words) diff --git a/app/models/reply/notify.rb b/app/models/reply/notify.rb index 7bf87f3e2a..0b8b0e38a4 100644 --- a/app/models/reply/notify.rb +++ b/app/models/reply/notify.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class Reply module Notify extend ActiveSupport::Concern @@ -11,7 +9,7 @@ module Notify end def broadcast_to_client - message = {id: id, user_id: user_id, action: :create} + message = { id: id, user_id: user_id, action: :create } ActionCable.server.broadcast("topics/#{topic_id}/replies", message) end diff --git a/app/models/reply/voteable.rb b/app/models/reply/voteable.rb index 16276e71d2..148554fc90 100644 --- a/app/models/reply/voteable.rb +++ b/app/models/reply/voteable.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class Reply module Voteable extend ActiveSupport::Concern diff --git a/app/models/search_document.rb b/app/models/search_document.rb index 652f7ba6aa..8569d5524f 100644 --- a/app/models/search_document.rb +++ b/app/models/search_document.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class SearchDocument < ActiveRecord::Base belongs_to :searchable, polymorphic: true diff --git a/app/models/setting.rb b/app/models/setting.rb index 74417e8d16..ab68fbbd6e 100644 --- a/app/models/setting.rb +++ b/app/models/setting.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - # RailsSettings Model class Setting < RailsSettings::Base LEGECY_ENVS = { @@ -83,7 +81,7 @@ def legecy_envs ] scope :basic do - field :app_name, default: (ENV["app_name"] || "Homeland"), validates: {presence: true} + field :app_name, default: (ENV["app_name"] || "Homeland"), validates: { presence: true } field :timezone, default: "UTC" # Module [topic,team,github,editor.code] field :modules, default: (ENV["modules"] || "all"), type: :array @@ -116,7 +114,7 @@ def legecy_envs scope :appearance do field :navbar_brand_html, default: -> { %(#{app_name}) } - field :default_locale, default: "en", validates: {presence: true, inclusion: {in: %w[en zh-CN]}} + field :default_locale, default: "en", validates: { presence: true, inclusion: { in: %w[en zh-CN] } } field :auto_locale, default: "false", type: :boolean field :custom_head_html, default: "" field :navbar_html, default: "" diff --git a/app/models/team.rb b/app/models/team.rb index 411de43350..177d74d725 100644 --- a/app/models/team.rb +++ b/app/models/team.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class Team < User has_one :profile, foreign_key: :user_id, dependent: :nullify has_many :replies, foreign_key: :user_id diff --git a/app/models/team_user.rb b/app/models/team_user.rb index ffbef6cba6..e22591b311 100644 --- a/app/models/team_user.rb +++ b/app/models/team_user.rb @@ -1,14 +1,12 @@ -# frozen_string_literal: true - class TeamUser < ApplicationRecord - enum role: %i[owner member] - enum status: %i[pendding accepted] + enum :role, %i[owner member] + enum :status, %i[pendding accepted] belongs_to :team, touch: true, counter_cache: true belongs_to :user validates :login, :team_id, :role, presence: true, on: :invite - validates :user_id, uniqueness: {scope: :team_id, message: I18n.t("teams.user_existed")} + validates :user_id, uniqueness: { scope: :team_id, message: I18n.t("teams.user_existed") } attr_accessor :login, :actor_id diff --git a/app/models/topic.rb b/app/models/topic.rb index 8b756fcce9..7a282ec190 100644 --- a/app/models/topic.rb +++ b/app/models/topic.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class Topic < ApplicationRecord include UserAvatarDelegate include Searchable diff --git a/app/models/topic/actions.rb b/app/models/topic/actions.rb index b1d9c73d5f..934f3e0dd7 100644 --- a/app/models/topic/actions.rb +++ b/app/models/topic/actions.rb @@ -1,11 +1,9 @@ -# frozen_string_literal: true - class Topic module Actions extend ActiveSupport::Concern included do - enum grade: {ban: -1, normal: 0, excellent: 1} + enum :grade, { ban: -1, normal: 0, excellent: 1 } # Follow enum method override methods must in `included` block. diff --git a/app/models/topic/auto_correct.rb b/app/models/topic/auto_correct.rb index e6250d9e00..0e36895c52 100644 --- a/app/models/topic/auto_correct.rb +++ b/app/models/topic/auto_correct.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class Topic module AutoCorrect extend ActiveSupport::Concern diff --git a/app/models/topic/notify.rb b/app/models/topic/notify.rb index e440e1db61..5e66fb679d 100644 --- a/app/models/topic/notify.rb +++ b/app/models/topic/notify.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class Topic module Notify extend ActiveSupport::Concern diff --git a/app/models/topic/rate_limit.rb b/app/models/topic/rate_limit.rb index fb5bc3f97b..47e0c99157 100644 --- a/app/models/topic/rate_limit.rb +++ b/app/models/topic/rate_limit.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class Topic module RateLimit extend ActiveSupport::Concern diff --git a/app/models/topic/search.rb b/app/models/topic/search.rb index 1bbae10f91..5fd9f4ee49 100644 --- a/app/models/topic/search.rb +++ b/app/models/topic/search.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class Topic module Search extend ActiveSupport::Concern diff --git a/app/models/user.rb b/app/models/user.rb index 9e1e7d73d6..9f34c33e19 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - require "digest/md5" class User < ApplicationRecord @@ -17,8 +15,6 @@ class User < ApplicationRecord include User::Roles include User::RedisOnlineTrackable - second_level_cache version: 4, expires_in: 2.weeks - LOGIN_FORMAT = 'A-Za-z0-9\-\_\.' ALLOW_LOGIN_FORMAT_REGEXP = /\A[#{LOGIN_FORMAT}]+\z/ @@ -41,11 +37,11 @@ class User < ApplicationRecord attr_accessor :password_confirmation - validates :login, format: {with: ALLOW_LOGIN_FORMAT_REGEXP, message: I18n.t("users.username_allows_format")}, - length: {in: 2..20}, + validates :login, format: { with: ALLOW_LOGIN_FORMAT_REGEXP, message: I18n.t("users.username_allows_format") }, + length: { in: 2..20 }, presence: true, - uniqueness: {case_sensitive: false} - validates :name, length: {maximum: 20} + uniqueness: { case_sensitive: false } + validates :name, length: { maximum: 20 } after_commit :send_welcome_mail, on: :create @@ -57,15 +53,17 @@ class User < ApplicationRecord :location_id, :twitter, :team_users_count, :created_at, :updated_at) } + form_select :state + # Override Devise database authentication def self.find_for_database_authentication(warden_conditions) conditions = warden_conditions.dup login = conditions.delete(:login).downcase - where(conditions.to_h).where(["(lower(login) = :value OR lower(email) = :value) and state != -1", {value: login}]).first + where(conditions.to_h).where(["(lower(login) = :value OR lower(email) = :value) and state != -1", { value: login }]).first end def self.find_by_email(email) - fetch_by_uniq_keys(email:) + find_by(email:) end def self.find_by_login!(slug) @@ -74,7 +72,7 @@ def self.find_by_login!(slug) def self.find_by_login(slug) return nil unless slug.match? ALLOW_LOGIN_FORMAT_REGEXP - fetch_by_uniq_keys(login: slug) || where("lower(login) = ?", slug.downcase).take + find_by(login: slug) || where("lower(login) = ?", slug.downcase).take end def self.find_by_login_or_email(login_or_email) diff --git a/app/models/user/avatar.rb b/app/models/user/avatar.rb index dc452b860b..3cf5dd585b 100644 --- a/app/models/user/avatar.rb +++ b/app/models/user/avatar.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class User module Avatar extend ActiveSupport::Concern diff --git a/app/models/user/blockable.rb b/app/models/user/blockable.rb index f03ef744d5..0bcf4ac3ff 100644 --- a/app/models/user/blockable.rb +++ b/app/models/user/blockable.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class User module Blockable extend ActiveSupport::Concern diff --git a/app/models/user/deviseable.rb b/app/models/user/deviseable.rb index 3011f77731..35eb235b41 100644 --- a/app/models/user/deviseable.rb +++ b/app/models/user/deviseable.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class User # Omniauth module Deviseable diff --git a/app/models/user/followable.rb b/app/models/user/followable.rb index c37987f0af..7de500c63a 100644 --- a/app/models/user/followable.rb +++ b/app/models/user/followable.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class User module Followable extend ActiveSupport::Concern diff --git a/app/models/user/github_repository.rb b/app/models/user/github_repository.rb index 66dbc5641f..63287e2e14 100644 --- a/app/models/user/github_repository.rb +++ b/app/models/user/github_repository.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class User module GitHubRepository extend ActiveSupport::Concern @@ -34,7 +32,7 @@ def fetch_github_repositories(user_id) conn = Faraday.new("https://api.github.com") conn.set_basic_auth(Setting.github_api_key, Setting.github_api_secret) - + begin resp = conn.get(user.github_repos_path) rescue => e diff --git a/app/models/user/likeable.rb b/app/models/user/likeable.rb index 76b1d0d877..77e7278de4 100644 --- a/app/models/user/likeable.rb +++ b/app/models/user/likeable.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class User # 对话题、回帖点赞 module Likeable diff --git a/app/models/user/profile_fields.rb b/app/models/user/profile_fields.rb index 8256b8f28c..ff5b5d349b 100644 --- a/app/models/user/profile_fields.rb +++ b/app/models/user/profile_fields.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class User module ProfileFields extend ActiveSupport::Concern diff --git a/app/models/user/redis_online_trackable.rb b/app/models/user/redis_online_trackable.rb index c3bf4064a8..65fdb76c23 100644 --- a/app/models/user/redis_online_trackable.rb +++ b/app/models/user/redis_online_trackable.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - # Track user online status class User module RedisOnlineTrackable diff --git a/app/models/user/reward_fields.rb b/app/models/user/reward_fields.rb index be869ce52b..4090246c4f 100644 --- a/app/models/user/reward_fields.rb +++ b/app/models/user/reward_fields.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class User module RewardFields extend ActiveSupport::Concern diff --git a/app/models/user/roles.rb b/app/models/user/roles.rb index 037b353519..8345ed8946 100644 --- a/app/models/user/roles.rb +++ b/app/models/user/roles.rb @@ -1,12 +1,10 @@ -# frozen_string_literal: true - class User # 用户权限相关 module Roles extend ActiveSupport::Concern included do - enum state: {deleted: -1, member: 1, blocked: 2, vip: 3, hr: 4, maintainer: 90, admin: 99} + enum :state, { deleted: -1, member: 1, blocked: 2, vip: 3, hr: 4, maintainer: 90, admin: 99 } # user.admin? define_method :admin? do diff --git a/app/models/user/soft_delete.rb b/app/models/user/soft_delete.rb index 4c3cbeb1b3..cb03e34b9c 100644 --- a/app/models/user/soft_delete.rb +++ b/app/models/user/soft_delete.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class User module SoftDelete extend ActiveSupport::Concern diff --git a/app/models/user/topic_actions.rb b/app/models/user/topic_actions.rb index c96cb2f7e8..f585233bde 100644 --- a/app/models/user/topic_actions.rb +++ b/app/models/user/topic_actions.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class User # 用户对话题的动作 module TopicActions diff --git a/app/models/user_sso.rb b/app/models/user_sso.rb index b959c0aa8d..be3b2d4194 100644 --- a/app/models/user_sso.rb +++ b/app/models/user_sso.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class UserSSO < ActiveRecord::Base belongs_to :user end diff --git a/app/uploaders/avatar_uploader.rb b/app/uploaders/avatar_uploader.rb index 4cb3afcdf7..7fe456d43c 100644 --- a/app/uploaders/avatar_uploader.rb +++ b/app/uploaders/avatar_uploader.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class AvatarUploader < BaseUploader def filename if super.present? diff --git a/app/uploaders/base_uploader.rb b/app/uploaders/base_uploader.rb index 62838cb4e4..69e8864651 100644 --- a/app/uploaders/base_uploader.rb +++ b/app/uploaders/base_uploader.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class BaseUploader < CarrierWave::Uploader::Base THUMB_IMAGE_EXTS = %w[.jpg .jpeg .gif .png] diff --git a/app/uploaders/photo_uploader.rb b/app/uploaders/photo_uploader.rb index 18f7411958..6322c26417 100644 --- a/app/uploaders/photo_uploader.rb +++ b/app/uploaders/photo_uploader.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class PhotoUploader < BaseUploader # Override the filename of the uploaded files: def filename diff --git a/app/views/api/v3/application/_abilities.json.jbuilder b/app/views/api/v3/application/_abilities.json.jbuilder index 48a3f1bdd9..649441676b 100644 --- a/app/views/api/v3/application/_abilities.json.jbuilder +++ b/app/views/api/v3/application/_abilities.json.jbuilder @@ -1,5 +1,3 @@ -# frozen_string_literal: true - # @class BaseSerializer # @!method abilities # 当前 accessToken 对应的用户对此数据的权限 diff --git a/app/views/api/v3/application/_node.json.jbuilder b/app/views/api/v3/application/_node.json.jbuilder index 90fbd7431e..3d7890956d 100644 --- a/app/views/api/v3/application/_node.json.jbuilder +++ b/app/views/api/v3/application/_node.json.jbuilder @@ -1,5 +1,3 @@ -# frozen_string_literal: true - # @class NodeSerializer # 节点 # diff --git a/app/views/api/v3/application/_notification.json.jbuilder b/app/views/api/v3/application/_notification.json.jbuilder index d1478cc12d..0b54ef40c2 100644 --- a/app/views/api/v3/application/_notification.json.jbuilder +++ b/app/views/api/v3/application/_notification.json.jbuilder @@ -1,5 +1,3 @@ -# frozen_string_literal: true - # 通知 # @class NotificationSerializer # diff --git a/app/views/api/v3/application/_reply.json.jbuilder b/app/views/api/v3/application/_reply.json.jbuilder index 8f83f84ce2..36554de609 100644 --- a/app/views/api/v3/application/_reply.json.jbuilder +++ b/app/views/api/v3/application/_reply.json.jbuilder @@ -1,5 +1,3 @@ -# frozen_string_literal: true - # 话题信息 # @class ReplySerializer # diff --git a/app/views/api/v3/application/_topic.json.jbuilder b/app/views/api/v3/application/_topic.json.jbuilder index e81f1da211..767d73ec38 100644 --- a/app/views/api/v3/application/_topic.json.jbuilder +++ b/app/views/api/v3/application/_topic.json.jbuilder @@ -1,5 +1,3 @@ -# frozen_string_literal: true - # 话题信息 # @class TopicSerializer # diff --git a/app/views/api/v3/application/_user.json.jbuilder b/app/views/api/v3/application/_user.json.jbuilder index 96e5726079..812341ff4d 100644 --- a/app/views/api/v3/application/_user.json.jbuilder +++ b/app/views/api/v3/application/_user.json.jbuilder @@ -1,5 +1,3 @@ -# frozen_string_literal: true - # 用户 API 返回数据结构 # @class UserSerializer # diff --git a/app/views/api/v3/nodes/index.json.jbuilder b/app/views/api/v3/nodes/index.json.jbuilder index b77697163c..7dbc2cc01b 100644 --- a/app/views/api/v3/nodes/index.json.jbuilder +++ b/app/views/api/v3/nodes/index.json.jbuilder @@ -1,3 +1 @@ -# frozen_string_literal: true - json.nodes @nodes, partial: "node", as: :node diff --git a/app/views/api/v3/nodes/show.json.jbuilder b/app/views/api/v3/nodes/show.json.jbuilder index 967be30ee5..7c7ed16535 100644 --- a/app/views/api/v3/nodes/show.json.jbuilder +++ b/app/views/api/v3/nodes/show.json.jbuilder @@ -1,6 +1,4 @@ -# frozen_string_literal: true - json.node do - json.partial! partial: "node", locals: {node: @node} + json.partial! partial: "node", locals: { node: @node } end json.meta @meta diff --git a/app/views/api/v3/notifications/index.json.jbuilder b/app/views/api/v3/notifications/index.json.jbuilder index 13fe7ca876..5077999121 100644 --- a/app/views/api/v3/notifications/index.json.jbuilder +++ b/app/views/api/v3/notifications/index.json.jbuilder @@ -1,3 +1 @@ -# frozen_string_literal: true - json.notifications @notifications, partial: "notification", as: :notification diff --git a/app/views/api/v3/photos/create.json.jbuilder b/app/views/api/v3/photos/create.json.jbuilder index b5f19df8ec..6fd1d85473 100644 --- a/app/views/api/v3/photos/create.json.jbuilder +++ b/app/views/api/v3/photos/create.json.jbuilder @@ -1,3 +1 @@ -# frozen_string_literal: true - json.image_url @photo.image.url(:large) diff --git a/app/views/api/v3/replies/show.json.jbuilder b/app/views/api/v3/replies/show.json.jbuilder index 0bd4a20be2..bcf14cb5f2 100644 --- a/app/views/api/v3/replies/show.json.jbuilder +++ b/app/views/api/v3/replies/show.json.jbuilder @@ -1,6 +1,4 @@ -# frozen_string_literal: true - json.reply do - json.partial! partial: "reply", locals: {reply: @reply, detail: true} + json.partial! partial: "reply", locals: { reply: @reply, detail: true } end json.meta @meta diff --git a/app/views/api/v3/topics/index.json.jbuilder b/app/views/api/v3/topics/index.json.jbuilder index 7fe1e396c1..95ba2fcb1e 100644 --- a/app/views/api/v3/topics/index.json.jbuilder +++ b/app/views/api/v3/topics/index.json.jbuilder @@ -1,3 +1 @@ -# frozen_string_literal: true - json.topics @topics, partial: "topic", as: :topic diff --git a/app/views/api/v3/topics/replies.json.jbuilder b/app/views/api/v3/topics/replies.json.jbuilder index c01d249e94..54585370fd 100644 --- a/app/views/api/v3/topics/replies.json.jbuilder +++ b/app/views/api/v3/topics/replies.json.jbuilder @@ -1,4 +1,2 @@ -# frozen_string_literal: true - json.replies @replies, partial: "reply", as: :reply json.meta @meta diff --git a/app/views/api/v3/topics/show.json.jbuilder b/app/views/api/v3/topics/show.json.jbuilder index 1024669c33..4b895a769f 100644 --- a/app/views/api/v3/topics/show.json.jbuilder +++ b/app/views/api/v3/topics/show.json.jbuilder @@ -1,6 +1,4 @@ -# frozen_string_literal: true - json.topic do - json.partial! partial: "topic", locals: {topic: @topic, detail: true} + json.partial! partial: "topic", locals: { topic: @topic, detail: true } end json.meta @meta diff --git a/app/views/api/v3/users/blocked.json.jbuilder b/app/views/api/v3/users/blocked.json.jbuilder index db7221aa8d..0b08c75a13 100644 --- a/app/views/api/v3/users/blocked.json.jbuilder +++ b/app/views/api/v3/users/blocked.json.jbuilder @@ -1,3 +1 @@ -# frozen_string_literal: true - json.blocked @users, partial: "user", as: :user diff --git a/app/views/api/v3/users/followers.json.jbuilder b/app/views/api/v3/users/followers.json.jbuilder index a094a240e7..89595835d5 100644 --- a/app/views/api/v3/users/followers.json.jbuilder +++ b/app/views/api/v3/users/followers.json.jbuilder @@ -1,3 +1 @@ -# frozen_string_literal: true - json.followers @users, partial: "user", as: :user diff --git a/app/views/api/v3/users/following.json.jbuilder b/app/views/api/v3/users/following.json.jbuilder index 7f20078cd6..162996371d 100644 --- a/app/views/api/v3/users/following.json.jbuilder +++ b/app/views/api/v3/users/following.json.jbuilder @@ -1,3 +1 @@ -# frozen_string_literal: true - json.following @users, partial: "user", as: :user diff --git a/app/views/api/v3/users/index.json.jbuilder b/app/views/api/v3/users/index.json.jbuilder index 3ff4ab87d9..51e5e151d2 100644 --- a/app/views/api/v3/users/index.json.jbuilder +++ b/app/views/api/v3/users/index.json.jbuilder @@ -1,3 +1 @@ -# frozen_string_literal: true - json.users @users, partial: "user", as: :user diff --git a/app/views/api/v3/users/replies.json.jbuilder b/app/views/api/v3/users/replies.json.jbuilder index 5fa77a8f64..3381a40370 100644 --- a/app/views/api/v3/users/replies.json.jbuilder +++ b/app/views/api/v3/users/replies.json.jbuilder @@ -1,5 +1,3 @@ -# frozen_string_literal: true - json.replies @replies do |reply| - json.partial! partial: "reply", locals: {reply: reply, detail: true} + json.partial! partial: "reply", locals: { reply: reply, detail: true } end diff --git a/app/views/api/v3/users/show.json.jbuilder b/app/views/api/v3/users/show.json.jbuilder index 82a542db7f..6df5f4b6c6 100644 --- a/app/views/api/v3/users/show.json.jbuilder +++ b/app/views/api/v3/users/show.json.jbuilder @@ -1,6 +1,4 @@ -# frozen_string_literal: true - json.user do - json.partial! partial: "user", locals: {user: @user, detail: true} + json.partial! partial: "user", locals: { user: @user, detail: true } end json.meta @meta diff --git a/app/views/api/v3/users/topics.json.jbuilder b/app/views/api/v3/users/topics.json.jbuilder index 7fe1e396c1..95ba2fcb1e 100644 --- a/app/views/api/v3/users/topics.json.jbuilder +++ b/app/views/api/v3/users/topics.json.jbuilder @@ -1,3 +1 @@ -# frozen_string_literal: true - json.topics @topics, partial: "topic", as: :topic diff --git a/app/views/doorkeeper/authorizations/new.html.erb b/app/views/doorkeeper/authorizations/new.html.erb index 32987b7af9..eaeabd9046 100644 --- a/app/views/doorkeeper/authorizations/new.html.erb +++ b/app/views/doorkeeper/authorizations/new.html.erb @@ -20,7 +20,7 @@ <% end %> -
+
<%= form_tag oauth_authorization_path, class: "col-md-6", style: "margin-bottom: 0", method: :post do %> <%= hidden_field_tag :client_id, @pre_auth.client.uid %> <%= hidden_field_tag :redirect_uri, @pre_auth.redirect_uri %> diff --git a/app/views/topics/feed.builder b/app/views/topics/feed.builder index 2b71ea9c9b..e1aadaa41d 100644 --- a/app/views/topics/feed.builder +++ b/app/views/topics/feed.builder @@ -1,5 +1,3 @@ -# frozen_string_literal: true - xml.instruct! :xml, version: "1.0" xml.rss(version: "2.0") do xml.channel do diff --git a/app/views/topics/node_feed.builder b/app/views/topics/node_feed.builder index 0253092510..cf12ab6264 100644 --- a/app/views/topics/node_feed.builder +++ b/app/views/topics/node_feed.builder @@ -1,5 +1,3 @@ -# frozen_string_literal: true - xml.instruct! :xml, version: "1.0" xml.rss version: "2.0" do xml.channel do diff --git a/app/views/topics/preview.json.jbuilder b/app/views/topics/preview.json.jbuilder index 6090ffad73..7bdd91360a 100644 --- a/app/views/topics/preview.json.jbuilder +++ b/app/views/topics/preview.json.jbuilder @@ -1,3 +1 @@ -# frozen_string_literal: true - json.body markdown(@body) diff --git a/app/views/users/feed.builder b/app/views/users/feed.builder index 1dfd090322..57c6656861 100644 --- a/app/views/users/feed.builder +++ b/app/views/users/feed.builder @@ -1,5 +1,3 @@ -# frozen_string_literal: true - xml.instruct! :xml, version: "1.0" xml.rss(version: "2.0") do xml.channel do diff --git a/bin/dev b/bin/dev new file mode 100755 index 0000000000..5f91c20545 --- /dev/null +++ b/bin/dev @@ -0,0 +1,2 @@ +#!/usr/bin/env ruby +exec "./bin/rails", "server", *ARGV diff --git a/bin/rubocop b/bin/rubocop new file mode 100755 index 0000000000..40330c0ff1 --- /dev/null +++ b/bin/rubocop @@ -0,0 +1,8 @@ +#!/usr/bin/env ruby +require "rubygems" +require "bundler/setup" + +# explicit rubocop config increases performance slightly while avoiding config confusion. +ARGV.unshift("--config", File.expand_path("../.rubocop.yml", __dir__)) + +load Gem.bin_path("rubocop", "rubocop") diff --git a/bin/setup b/bin/setup index a1d6aaa4fb..b3be64607e 100755 --- a/bin/setup +++ b/bin/setup @@ -1,6 +1,4 @@ #!/usr/bin/env ruby -# frozen_string_literal: true - require "pathname" # path to your application root. diff --git a/bin/thrust b/bin/thrust new file mode 100755 index 0000000000..36bde2d832 --- /dev/null +++ b/bin/thrust @@ -0,0 +1,5 @@ +#!/usr/bin/env ruby +require "rubygems" +require "bundler/setup" + +load Gem.bin_path("thruster", "thrust") diff --git a/config.ru b/config.ru index 2e0308469b..4a3c09a688 100644 --- a/config.ru +++ b/config.ru @@ -1,5 +1,3 @@ -# frozen_string_literal: true - # This file is used by Rack-based servers to start the application. require_relative "config/environment" diff --git a/config/application.rb b/config/application.rb index 224467b3cf..5140d46b84 100644 --- a/config/application.rb +++ b/config/application.rb @@ -11,12 +11,12 @@ module Homeland class Application < Rails::Application # Initialize configuration defaults for originally generated Rails version. - config.load_defaults 7.0 + config.load_defaults 8.0 - # Settings in config/environments/* take precedence over those specified here. - # Application configuration can go into files in config/initializers - # -- all .rb files in that directory are automatically loaded after loading - # the framework and any gems in your application. + # Please, add to the `ignore` list any other `lib` subdirectories that do + # not contain `.rb` files, or that should not be reloaded or eager loaded. + # Common ones are `templates`, `generators`, or `middleware`, for example. + config.autoload_lib(ignore: %w[assets tasks]) # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. config.i18n.load_path += Dir[Rails.root.join("plugins", "*/locales", "*.{rb,yml}").to_s] @@ -47,7 +47,7 @@ class Application < Rails::Application end redis_config = Application.config_for(:redis) - config.cache_store = [:redis_cache_store, {namespace: "cache", url: redis_config["url"], expires_in: 4.weeks}] + config.cache_store = [:redis_cache_store, { namespace: "cache", url: redis_config["url"], expires_in: 4.weeks }] config.active_job.queue_adapter = :sidekiq config.middleware.use Rack::Attack diff --git a/config/database.yml b/config/database.yml index 04bd308cba..52d32b66c7 100644 --- a/config/database.yml +++ b/config/database.yml @@ -10,6 +10,7 @@ development: host: localhost port: 54321 user: postgres + gssencmode: "disable" # Warning: The database defined as "test" will be erased and # re-generated from your development database when you run "rake". diff --git a/config/environments/development.rb b/config/environments/development.rb index 16273d0ed1..6ecb3f6981 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -3,9 +3,7 @@ Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. - # In the development environment your application's code is reloaded any time - # it changes. This slows down response time but is perfect for development - # since you don't have to restart the web server when you make code changes. + # Make code changes take effect immediately without server restart. config.enable_reloading = true # Do not eager load code on boot. @@ -14,21 +12,17 @@ # Show full error reports. config.consider_all_requests_local = true - # Enable server timing + # Enable server timing. config.server_timing = true - # Enable/disable caching. By default caching is disabled. - # Run rails dev:cache to toggle caching. + # Enable/disable Action Controller caching. By default Action Controller caching is disabled. + # Run rails dev:cache to toggle Action Controller caching. if Rails.root.join("tmp/caching-dev.txt").exist? config.action_controller.perform_caching = true config.action_controller.enable_fragment_cache_logging = true - - config.public_file_server.headers = { - "Cache-Control" => "public, max-age=#{2.days.to_i}" - } + config.public_file_server.headers = { "cache-control" => "public, max-age=#{2.days.to_i}" } else config.action_controller.perform_caching = false - config.cache_store = :null_store end @@ -38,23 +32,24 @@ # Don't care if the mailer can't send. config.action_mailer.raise_delivery_errors = false + # Make template changes take effect immediately. config.action_mailer.perform_caching = false + # Set localhost to be used by links generated in mailer templates. + config.action_mailer.default_url_options = { host: "localhost", port: 3000 } + # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log - # Raise exceptions for disallowed deprecations. - config.active_support.disallowed_deprecation = :raise - - # Tell Active Support which deprecation messages to disallow. - config.active_support.disallowed_deprecation_warnings = [] - # Raise an error on page load if there are pending migrations. config.active_record.migration_error = :page_load # Highlight code that triggered database queries in logs. config.active_record.verbose_query_logs = true + # Append comments with runtime information tags to SQL queries in logs. + config.active_record.query_log_tags_enabled = true + # Highlight code that enqueued background job in logs. config.active_job.verbose_enqueue_logs = true @@ -65,13 +60,16 @@ # config.i18n.raise_on_missing_translations = true # Annotate rendered view with file names. - # config.action_view.annotate_rendered_view_with_filenames = true + config.action_view.annotate_rendered_view_with_filenames = true # Uncomment if you wish to allow Action Cable access from any origin. # config.action_cable.disable_request_forgery_protection = true config.active_job.queue_adapter = :inline - # Raise error when a before_action's only/except options reference missing actions + # Raise error when a before_action's only/except options reference missing actions. config.action_controller.raise_on_missing_callback_actions = true + + # Apply autocorrection by RuboCop to files generated by `bin/rails generate`. + # config.generators.apply_rubocop_autocorrect_after_generate! end diff --git a/config/environments/production.rb b/config/environments/production.rb index ce619977e5..cee9c91204 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -6,22 +6,17 @@ # Code is not reloaded between requests. config.enable_reloading = false - # Eager load code on boot. This eager loads most of Rails and - # your application in memory, allowing both threaded web servers - # and those relying on copy on write to perform better. - # Rake tasks automatically ignore this option for performance. + # Eager load code on boot for better performance and memory savings (ignored by Rake tasks). config.eager_load = true - # Full error reports are disabled and caching is turned on. + # Full error reports are disabled. config.consider_all_requests_local = false - config.action_controller.perform_caching = true - # Ensures that a master key has been made available in ENV["RAILS_MASTER_KEY"], config/master.key, or an environment - # key such as config/credentials/production.key. This key is used to decrypt credentials (and other encrypted files). - # config.require_master_key = true + # Turn on fragment caching in view templates. + config.action_controller.perform_caching = true - # Enable static file serving from the `/public` folder (turn off if using NGINX/Apache for it) - config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present? + # Cache assets for far-future expiry since they are all digest stamped. + config.public_file_server.headers = { "cache-control" => "public, max-age=#{1.year.to_i}" } # Compress CSS using a preprocessor. config.assets.css_compressor = :sass @@ -36,57 +31,73 @@ end end - # Specifies the header that your server uses for sending files. - # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache - config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX - # Store uploaded files on the local file system (see config/storage.yml for options). config.active_storage.service = :local - # Mount Action Cable outside main process or domain. - # config.action_cable.mount_path = nil - # config.action_cable.url = 'wss://example.com/cable' - # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] config.to_prepare do Rails.application.config.action_cable.allowed_request_origins = [Setting.cable_allowed_request_origin] end + # Assume all access to the app is happening through a SSL-terminating reverse proxy. + config.assume_ssl = true + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. config.force_ssl = false - # Log to STDOUT by default - config.logger = ActiveSupport::Logger.new(STDOUT) - .tap { |logger| logger.formatter = ::Logger::Formatter.new } - .then { |logger| ActiveSupport::TaggedLogging.new(logger) } + # Skip http-to-https redirect for the default health check endpoint. + # config.ssl_options = { redirect: { exclude: ->(request) { request.path == "/up" } } } - # Prepend all log lines with the following tags. - config.log_tags = [:request_id] + # Log to STDOUT with the current request id as a default log tag. + config.log_tags = [ :request_id ] + config.logger = ActiveSupport::TaggedLogging.logger(STDOUT) - # Info include generic and useful information about system operation, but avoids logging too much - # information to avoid inadvertent exposure of personally identifiable information (PII). If you - # want to log everything, set the level to "debug". + # Change to "debug" to log everything (including potentially personally-identifiable information!) config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info") - # Use a different cache store in production. - # config.cache_store = :mem_cache_store + # Prevent health checks from clogging up the logs. + config.silence_healthcheck_path = "/up" - # Use a real queuing backend for Active Job (and separate queues per environment). - # config.active_job.queue_adapter = :resque - # config.active_job.queue_name_prefix = "homeland_#{Rails.env}" + # Don't log any deprecations. + config.active_support.report_deprecations = false - config.action_mailer.perform_caching = false + # Replace the default in-process memory cache store with a durable alternative. + # config.cache_store = :mem_cache_store + + # Replace the default in-process and non-durable queuing backend for Active Job. + # config.active_job.queue_adapter = :resque # Ignore bad email addresses and do not raise email delivery errors. # Set this to true and configure the email server for immediate delivery to raise delivery errors. # config.action_mailer.raise_delivery_errors = false + # Set host to be used by links generated in mailer templates. + # config.action_mailer.default_url_options = { host: "example.com" } + + # Specify outgoing SMTP server. Remember to add smtp/* credentials via rails credentials:edit. + # config.action_mailer.smtp_settings = { + # user_name: Rails.application.credentials.dig(:smtp, :user_name), + # password: Rails.application.credentials.dig(:smtp, :password), + # address: "smtp.example.com", + # port: 587, + # authentication: :plain + # } + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to # the I18n.default_locale when a translation cannot be found). config.i18n.fallbacks = true - # Don't log any deprecations. - config.active_support.report_deprecations = false - # Do not dump schema after migrations. config.active_record.dump_schema_after_migration = false + + # Only use :id for inspections in production. + config.active_record.attributes_for_inspect = [ :id ] + + # Enable DNS rebinding protection and other `Host` header attacks. + # config.hosts = [ + # "example.com", # Allow requests from example.com + # /.*\.example\.com/ # Allow requests from subdomains like `www.example.com` + # ] + # + # Skip DNS rebinding protection for the default health check endpoint. + # config.host_authorization = { exclude: ->(request) { request.path == "/up" } } end diff --git a/config/environments/test.rb b/config/environments/test.rb index 9a4ad5455a..bf8c88fbc9 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -1,5 +1,3 @@ -require "active_support/core_ext/integer/time" - # The test environment is used exclusively to run your application's # test suite. You never need to work with it otherwise. Remember that # your test database is "scratch space" for the test suite and is wiped @@ -15,48 +13,43 @@ # this is usually not necessary, and can slow down your test suite. However, it's # recommended that you enable it in continuous integration systems to ensure eager # loading is working properly before deploying your code. - # https://github.com/rails/rails/pull/49509 config.eager_load = ENV["CI"].present? - # Configure public file server for tests with Cache-Control for performance. - config.public_file_server.enabled = true - config.public_file_server.headers = { - "Cache-Control" => "public, max-age=#{1.hour.to_i}" - } + # Configure public file server for tests with cache-control for performance. + config.public_file_server.headers = { "cache-control" => "public, max-age=3600" } - # Show full error reports and disable caching. + # Show full error reports. config.consider_all_requests_local = true - config.action_controller.perform_caching = false config.cache_store = :memory_store - # Raise exceptions instead of rendering exception templates. - config.action_dispatch.show_exceptions = :none + # Render exception templates for rescuable exceptions and raise for other exceptions. + config.action_dispatch.show_exceptions = :rescuable # Disable request forgery protection in test environment. config.action_controller.allow_forgery_protection = false + config.active_job.queue_adapter = :inline + # Store uploaded files on the local file system in a temporary directory. config.active_storage.service = :test - config.action_mailer.perform_caching = false - # Tell Action Mailer not to deliver emails to the real world. # The :test delivery method accumulates sent emails in the # ActionMailer::Base.deliveries array. config.action_mailer.delivery_method = :test + # Set host to be used by links generated in mailer templates. + config.action_mailer.default_url_options = { host: "example.com" } + # Print deprecation notices to the stderr. config.active_support.deprecation = :stderr - # Raise exceptions for disallowed deprecations. - config.active_support.disallowed_deprecation = :raise - - # Tell Active Support which deprecation messages to disallow. - config.active_support.disallowed_deprecation_warnings = [] - # Raises error for missing translations. # config.i18n.raise_on_missing_translations = true # Annotate rendered view with file names. # config.action_view.annotate_rendered_view_with_filenames = true + + # Raise error when a before_action's only/except options reference missing actions. + config.action_controller.raise_on_missing_callback_actions = true end diff --git a/config/initializers/_setup_mailer.rb b/config/initializers/_setup_mailer.rb index 94312a539d..7fe9acecdf 100644 --- a/config/initializers/_setup_mailer.rb +++ b/config/initializers/_setup_mailer.rb @@ -1,3 +1,3 @@ Rails.application.config.to_prepare do - ActionMailer::Base.default_url_options = {host: Setting.domain, protocol: Setting.protocol} + ActionMailer::Base.default_url_options = { host: Setting.domain, protocol: Setting.protocol } end diff --git a/config/initializers/application_controller_renderer.rb b/config/initializers/application_controller_renderer.rb index f4556db399..89d2efab2b 100644 --- a/config/initializers/application_controller_renderer.rb +++ b/config/initializers/application_controller_renderer.rb @@ -1,4 +1,3 @@ -# frozen_string_literal: true # Be sure to restart your server when you modify this file. # ActiveSupport::Reloader.to_prepare do diff --git a/config/initializers/backtrace_silencers.rb b/config/initializers/backtrace_silencers.rb index 42bb3115ef..b67c3a6bfd 100644 --- a/config/initializers/backtrace_silencers.rb +++ b/config/initializers/backtrace_silencers.rb @@ -1,4 +1,3 @@ -# frozen_string_literal: true # Be sure to restart your server when you modify this file. # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. diff --git a/config/initializers/carrierwave.rb b/config/initializers/carrierwave.rb index 546b75a597..6308bf6fda 100644 --- a/config/initializers/carrierwave.rb +++ b/config/initializers/carrierwave.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - require "carrierwave" require "carrierwave/validations/active_model" diff --git a/config/initializers/cookies_serializer.rb b/config/initializers/cookies_serializer.rb index ee8dff9c99..5a6a32d371 100644 --- a/config/initializers/cookies_serializer.rb +++ b/config/initializers/cookies_serializer.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - # Be sure to restart your server when you modify this file. # Specify a serializer for the signed and encrypted cookie jars. diff --git a/config/initializers/cors.rb b/config/initializers/cors.rb index cb1e44a3fc..4c5a4defa9 100644 --- a/config/initializers/cors.rb +++ b/config/initializers/cors.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - # Be sure to restart your server when you modify this file. # Avoid CORS issues when API is called from the frontend app. diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index e9549d7a85..9e36bf390c 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - TWITTER_OMNIAUTH_SETUP = lambda do |env| env["omniauth.strategy"].options[:consumer_key] = Setting.twitter_api_key env["omniauth.strategy"].options[:consumer_secret] = Setting.twitter_api_secret diff --git a/config/initializers/doorkeeper.rb b/config/initializers/doorkeeper.rb index 2a88235c8a..39b933e105 100644 --- a/config/initializers/doorkeeper.rb +++ b/config/initializers/doorkeeper.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - Doorkeeper.configure do # Change the ORM that doorkeeper will use. # Currently supported options are :active_record, :mongoid2, :mongoid3, @@ -12,7 +10,7 @@ end resource_owner_from_credentials do - request.params[:user] = {login: request.params[:username], password: request.params[:password]} + request.params[:user] = { login: request.params[:username], password: request.params[:password] } request.env["devise.allow_params_authentication"] = true # 清理之前的 warden 信息 request.env["warden"].logout(:user) @@ -114,11 +112,3 @@ # WWW-Authenticate Realm (default "Doorkeeper"). realm(ENV["app_name"] || "Homeland") end - -# https://github.com/doorkeeper-gem/doorkeeper/issues/1467 -# HOTFIX: find_access_token_in_batches with Ruby 3.0 -Doorkeeper::AccessTokenMixin::ClassMethods.module_eval do - def find_access_token_in_batches(relation, **args, &block) - relation.find_in_batches(**args, &block) - end -end diff --git a/config/initializers/exception-track.rb b/config/initializers/exception-track.rb index 525fd043fc..374608353e 100644 --- a/config/initializers/exception-track.rb +++ b/config/initializers/exception-track.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - require "exception_notification/sidekiq" ExceptionTrack.configure do diff --git a/config/initializers/feature_policy.rb b/config/initializers/feature_policy.rb index 4de54a249f..a1c46695d2 100644 --- a/config/initializers/feature_policy.rb +++ b/config/initializers/feature_policy.rb @@ -1,4 +1,3 @@ -# frozen_string_literal: true # Define an application-wide HTTP feature policy. For further # information see https://developers.google.com/web/updates/2018/06/feature-policy # diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb index fb16c03977..47d7b2ddf8 100644 --- a/config/initializers/filter_parameter_logging.rb +++ b/config/initializers/filter_parameter_logging.rb @@ -1,9 +1,7 @@ -# frozen_string_literal: true - # Be sure to restart your server when you modify this file. # Configure sensitive parameters which will be filtered from the log file. Rails.application.config.filter_parameters += [ - :passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn, + :passw, :email, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn, :cvv, :cvc, :auth, :certificate, :access, :private, :protected, :body ] diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb index 4faae2b07b..28a54b3b30 100644 --- a/config/initializers/inflections.rb +++ b/config/initializers/inflections.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - # Be sure to restart your server when you modify this file. # Add new inflection rules using the following format. Inflections diff --git a/config/initializers/kaminari_config.rb b/config/initializers/kaminari_config.rb index a4075454e1..1433ffde22 100644 --- a/config/initializers/kaminari_config.rb +++ b/config/initializers/kaminari_config.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - Kaminari.configure do |config| config.default_per_page = 30 # config.max_per_page = nil diff --git a/config/initializers/mime_types.rb b/config/initializers/mime_types.rb index 6e1d16f027..dc1899682b 100644 --- a/config/initializers/mime_types.rb +++ b/config/initializers/mime_types.rb @@ -1,4 +1,3 @@ -# frozen_string_literal: true # Be sure to restart your server when you modify this file. # Add new mime types for use in respond_to blocks: diff --git a/config/initializers/new_framework_defaults_6_1.rb b/config/initializers/new_framework_defaults_6_1.rb deleted file mode 100644 index 2f01b61c8b..0000000000 --- a/config/initializers/new_framework_defaults_6_1.rb +++ /dev/null @@ -1,46 +0,0 @@ -# frozen_string_literal: true -# Be sure to restart your server when you modify this file. -# -# This file contains migration options to ease your Rails 6.1 upgrade. -# -# Once upgraded flip defaults one by one to migrate to the new default. -# -# Read the Guide for Upgrading Ruby on Rails for more info on each option. - -# Support for inversing belongs_to -> has_many Active Record associations. -# Rails.application.config.active_record.has_many_inversing = true - -# Track Active Storage variants in the database. -# Rails.application.config.active_storage.track_variants = true - -# Apply random variation to the delay when retrying failed jobs. -# Rails.application.config.active_job.retry_jitter = 0.15 - -# Stop executing `after_enqueue`/`after_perform` callbacks if -# `before_enqueue`/`before_perform` respectively halts with `throw :abort`. -# Rails.application.config.active_job.skip_after_callbacks_if_terminated = true - -# Specify cookies SameSite protection level: either :none, :lax, or :strict. -# -# This change is not backwards compatible with earlier Rails versions. -# It's best enabled when your entire app is migrated and stable on 6.1. -# Rails.application.config.action_dispatch.cookies_same_site_protection = :lax - -# Generate CSRF tokens that are encoded in URL-safe Base64. -# -# This change is not backwards compatible with earlier Rails versions. -# It's best enabled when your entire app is migrated and stable on 6.1. -# Rails.application.config.action_controller.urlsafe_csrf_tokens = true - -# Specify whether `ActiveSupport::TimeZone.utc_to_local` returns a time with an -# UTC offset or a UTC time. -# ActiveSupport.utc_to_local_returns_utc_offset_times = true - -# Change the default HTTP status code to `308` when redirecting non-GET/HEAD -# requests to HTTPS in `ActionDispatch::SSL` middleware. -# Rails.application.config.action_dispatch.ssl_default_redirect_status = 308 - -# Use new connection handling API. For most applications this won't have any -# effect. For applications using multiple databases, this new API provides -# support for granular connection swapping. -# Rails.application.config.active_record.legacy_connection_handling = false diff --git a/config/initializers/new_framework_defaults_7_0.rb b/config/initializers/new_framework_defaults_7_0.rb deleted file mode 100644 index a579326e20..0000000000 --- a/config/initializers/new_framework_defaults_7_0.rb +++ /dev/null @@ -1,117 +0,0 @@ -# Be sure to restart your server when you modify this file. -# -# This file eases your Rails 7.0 framework defaults upgrade. -# -# Uncomment each configuration one by one to switch to the new default. -# Once your application is ready to run with all new defaults, you can remove -# this file and set the `config.load_defaults` to `7.0`. -# -# Read the Guide for Upgrading Ruby on Rails for more info on each option. -# https://guides.rubyonrails.org/upgrading_ruby_on_rails.html - -# `button_to` view helper will render `