From 0105930afad44de8d3c63c542b7762d668e1c205 Mon Sep 17 00:00:00 2001 From: Peter Bhat Harkins Date: Mon, 18 May 2020 19:28:26 -0500 Subject: [PATCH] bump rails; rubocop cleanup --- .rubocop.yml | 10 +- Gemfile | 4 +- Gemfile.lock | 211 +++++++++--------- app/mailers/application_mailer.rb | 3 + app/mailers/ban_notification.rb | 4 +- app/mailers/email_message.rb | 4 +- app/mailers/email_reply.rb | 4 +- app/mailers/invitation_mailer.rb | 4 +- app/mailers/invitation_request_mailer.rb | 4 +- app/mailers/password_reset.rb | 4 +- .../20200519000845_index_users_on_email.rb | 6 + db/schema.rb | 3 +- extras/sponge.rb | 2 +- spec/models/markdowner_spec.rb | 8 - 14 files changed, 135 insertions(+), 136 deletions(-) create mode 100644 app/mailers/application_mailer.rb create mode 100644 db/migrate/20200519000845_index_users_on_email.rb diff --git a/.rubocop.yml b/.rubocop.yml index 71e0ebea..9aabb978 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -45,8 +45,6 @@ Layout/FirstHashElementIndentation: EnforcedStyle: consistent Layout/HashAlignment: Enabled: false -Layout/LineLength: - Max: 100 Layout/MultilineMethodCallBraceLayout: Enabled: false Layout/MultilineMethodCallIndentation: @@ -62,6 +60,10 @@ Layout/SpaceInsideRangeLiteral: # Lint Lint/SuppressedException: Enabled: false +Lint/RaiseException: + Enabled: true +Lint/StructNewOverride: + Enabled: true # Metrics Metrics/AbcSize: @@ -74,6 +76,8 @@ Metrics/ClassLength: Enabled: false Metrics/CyclomaticComplexity: Enabled: false +Metrics/LineLength: + Max: 100 Metrics/MethodLength: Enabled: false Metrics/ModuleLength: @@ -186,6 +190,8 @@ Style/FrozenStringLiteralComment: EnforcedStyle: never Style/GuardClause: Enabled: false +Style/HashEachMethods: + Enabled: true Style/HashSyntax: EnforcedStyle: no_mixed_keys Style/IfInsideElse: diff --git a/Gemfile b/Gemfile index 7231620c..cebdbf9b 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ source "https://rubygems.org" -gem "rails", "~> 5.2.4.2" +gem "rails", "~> 5.2.4.3" gem "mysql2" @@ -50,7 +50,7 @@ group :test, :development do gem "listen" gem "rspec-rails" gem "factory_bot_rails" - gem "rubocop", require: false + gem "rubocop", "0.81", require: false gem "rubocop-rails", require: false gem "rubocop-rspec", require: false gem "faker" diff --git a/Gemfile.lock b/Gemfile.lock index 4a46df1f..5d6b40cf 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -2,91 +2,91 @@ GEM remote: https://rubygems.org/ specs: Ascii85 (1.0.3) - actioncable (5.2.4.2) - actionpack (= 5.2.4.2) + actioncable (5.2.4.3) + actionpack (= 5.2.4.3) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailer (5.2.4.2) - actionpack (= 5.2.4.2) - actionview (= 5.2.4.2) - activejob (= 5.2.4.2) + actionmailer (5.2.4.3) + actionpack (= 5.2.4.3) + actionview (= 5.2.4.3) + activejob (= 5.2.4.3) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (5.2.4.2) - actionview (= 5.2.4.2) - activesupport (= 5.2.4.2) + actionpack (5.2.4.3) + actionview (= 5.2.4.3) + activesupport (= 5.2.4.3) rack (~> 2.0, >= 2.0.8) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.2) actionpack-page_caching (1.1.1) actionpack (>= 4.0.0, < 6) - actionview (5.2.4.2) - activesupport (= 5.2.4.2) + actionview (5.2.4.3) + activesupport (= 5.2.4.3) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.3) - activejob (5.2.4.2) - activesupport (= 5.2.4.2) + activejob (5.2.4.3) + activesupport (= 5.2.4.3) globalid (>= 0.3.6) - activemodel (5.2.4.2) - activesupport (= 5.2.4.2) - activerecord (5.2.4.2) - activemodel (= 5.2.4.2) - activesupport (= 5.2.4.2) + activemodel (5.2.4.3) + activesupport (= 5.2.4.3) + activerecord (5.2.4.3) + activemodel (= 5.2.4.3) + activesupport (= 5.2.4.3) arel (>= 9.0) - activerecord-typedstore (1.2.2) - activerecord (>= 4.2) - activestorage (5.2.4.2) - actionpack (= 5.2.4.2) - activerecord (= 5.2.4.2) + activerecord-typedstore (1.3.0) + activerecord (>= 5.2) + activestorage (5.2.4.3) + actionpack (= 5.2.4.3) + activerecord (= 5.2.4.3) marcel (~> 0.3.1) - activesupport (5.2.4.2) + activesupport (5.2.4.3) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 0.7, < 2) minitest (~> 5.1) tzinfo (~> 1.1) - addressable (2.6.0) - public_suffix (>= 2.0.2, < 4.0) + addressable (2.7.0) + public_suffix (>= 2.0.2, < 5.0) afm (0.2.2) arel (9.0.0) ast (2.4.0) bcrypt (3.1.13) builder (3.2.4) - bullet (6.0.0) + bullet (6.1.0) activesupport (>= 3.0.0) uniform_notifier (~> 1.11) - byebug (11.0.1) - capybara (3.15.1) + byebug (11.1.3) + capybara (3.32.2) addressable mini_mime (>= 0.1.3) nokogiri (~> 1.8) rack (>= 1.6.0) rack-test (>= 0.6.3) - regexp_parser (~> 1.2) + regexp_parser (~> 1.5) xpath (~> 3.2) chunky_png (1.3.11) - commonmarker (0.20.1) + commonmarker (0.21.0) ruby-enum (~> 0.5) concurrent-ruby (1.1.6) crass (1.0.6) - database_cleaner (1.7.0) + database_cleaner (1.8.5) diff-lcs (1.3) dynamic_form (1.1.4) erubi (1.9.0) - exception_notification (4.3.0) - actionmailer (>= 4.0, < 6) - activesupport (>= 4.0, < 6) + exception_notification (4.4.0) + actionmailer (>= 4.0, < 7) + activesupport (>= 4.0, < 7) execjs (2.7.0) - factory_bot (5.0.2) + factory_bot (5.2.0) activesupport (>= 4.2.0) - factory_bot_rails (5.0.2) - factory_bot (~> 5.0.2) + factory_bot_rails (5.2.0) + factory_bot (~> 5.2.0) railties (>= 4.2.0) - faker (1.9.3) - i18n (>= 0.7) - ffi (1.11.1) + faker (2.11.0) + i18n (>= 1.6, < 2) + ffi (1.12.2) globalid (0.4.2) activesupport (>= 4.2.0) good_migrations (0.0.2) @@ -97,16 +97,15 @@ GEM i18n (1.8.2) concurrent-ruby (~> 1.0) jaro_winkler (1.5.4) - jquery-rails (4.3.5) + jquery-rails (4.4.0) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) - json (2.2.0) - kgio (2.11.2) - listen (3.1.5) - rb-fsevent (~> 0.9, >= 0.9.4) - rb-inotify (~> 0.9, >= 0.9.7) - ruby_dep (~> 1.2) + json (2.3.0) + kgio (2.11.3) + listen (3.2.1) + rb-fsevent (~> 0.10, >= 0.10.3) + rb-inotify (~> 0.9, >= 0.9.10) loofah (2.5.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) @@ -119,97 +118,101 @@ GEM mini_mime (1.0.2) mini_portile2 (2.4.0) minitest (5.14.1) - mysql2 (0.5.2) + mysql2 (0.5.3) nio4r (2.5.2) nokogiri (1.10.9) mini_portile2 (~> 2.4.0) oauth (0.5.4) parallel (1.19.1) - parser (2.7.0.2) + parser (2.7.1.2) ast (~> 2.4.0) - pdf-reader (2.2.0) + pdf-reader (2.4.0) Ascii85 (~> 1.0.0) afm (~> 0.2.1) hashery (~> 2.0) ruby-rc4 ttfunk - public_suffix (3.1.1) + public_suffix (4.0.5) rack (2.2.2) rack-test (1.1.0) rack (>= 1.0, < 3) - rails (5.2.4.2) - actioncable (= 5.2.4.2) - actionmailer (= 5.2.4.2) - actionpack (= 5.2.4.2) - actionview (= 5.2.4.2) - activejob (= 5.2.4.2) - activemodel (= 5.2.4.2) - activerecord (= 5.2.4.2) - activestorage (= 5.2.4.2) - activesupport (= 5.2.4.2) + rails (5.2.4.3) + actioncable (= 5.2.4.3) + actionmailer (= 5.2.4.3) + actionpack (= 5.2.4.3) + actionview (= 5.2.4.3) + activejob (= 5.2.4.3) + activemodel (= 5.2.4.3) + activerecord (= 5.2.4.3) + activestorage (= 5.2.4.3) + activesupport (= 5.2.4.3) bundler (>= 1.3.0) - railties (= 5.2.4.2) + railties (= 5.2.4.3) sprockets-rails (>= 2.0.0) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) rails-html-sanitizer (1.3.0) loofah (~> 2.3) - railties (5.2.4.2) - actionpack (= 5.2.4.2) - activesupport (= 5.2.4.2) + railties (5.2.4.3) + actionpack (= 5.2.4.3) + activesupport (= 5.2.4.3) method_source rake (>= 0.8.7) thor (>= 0.19.0, < 2.0) rainbow (3.0.0) - raindrops (0.19.0) + raindrops (0.19.1) rake (13.0.1) - rb-fsevent (0.10.3) - rb-inotify (0.10.0) + rb-fsevent (0.10.4) + rb-inotify (0.10.1) ffi (~> 1.0) rb-readline (0.5.5) - regexp_parser (1.5.1) - rotp (5.1.0) - addressable (~> 2.5) - rqrcode (0.10.1) + regexp_parser (1.7.0) + rexml (3.2.4) + rotp (6.0.0) + addressable (~> 2.7) + rqrcode (1.1.2) chunky_png (~> 1.0) - rspec-core (3.8.1) - rspec-support (~> 3.8.0) - rspec-expectations (3.8.4) + rqrcode_core (~> 0.1) + rqrcode_core (0.1.2) + rspec-core (3.9.2) + rspec-support (~> 3.9.3) + rspec-expectations (3.9.2) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.8.0) - rspec-mocks (3.8.1) + rspec-support (~> 3.9.0) + rspec-mocks (3.9.1) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.8.0) - rspec-rails (3.8.2) - actionpack (>= 3.0) - activesupport (>= 3.0) - railties (>= 3.0) - rspec-core (~> 3.8.0) - rspec-expectations (~> 3.8.0) - rspec-mocks (~> 3.8.0) - rspec-support (~> 3.8.0) - rspec-support (3.8.2) - rubocop (0.79.0) + rspec-support (~> 3.9.0) + rspec-rails (4.0.1) + actionpack (>= 4.2) + activesupport (>= 4.2) + railties (>= 4.2) + rspec-core (~> 3.9) + rspec-expectations (~> 3.9) + rspec-mocks (~> 3.9) + rspec-support (~> 3.9) + rspec-support (3.9.3) + rubocop (0.81.0) jaro_winkler (~> 1.5.1) parallel (~> 1.10) parser (>= 2.7.0.1) rainbow (>= 2.2.2, < 4.0) + rexml ruby-progressbar (~> 1.7) - unicode-display_width (>= 1.4.0, < 1.7) - rubocop-rails (2.3.2) + unicode-display_width (>= 1.4.0, < 2.0) + rubocop-rails (2.5.2) + activesupport rack (>= 1.1) rubocop (>= 0.72.0) - rubocop-rspec (1.36.0) + rubocop-rspec (1.39.0) rubocop (>= 0.68.1) - ruby-enum (0.7.2) + ruby-enum (0.8.0) i18n ruby-progressbar (1.10.1) ruby-rc4 (0.1.5) - ruby_dep (1.5.0) - ruumba (0.1.10) + ruumba (0.1.14) rubocop - scenic (1.5.1) + scenic (1.5.2) activerecord (>= 4.0.0) railties (>= 4.0.0) scenic-mysql_adapter (1.0.1) @@ -217,7 +220,7 @@ GEM scenic (>= 1.4.0) scout_apm (2.6.2) parser - sitemap_generator (6.0.2) + sitemap_generator (6.1.0) builder (~> 3.0) sprockets (3.7.2) concurrent-ruby (~> 1.0) @@ -233,16 +236,16 @@ GEM transaction_retry (1.0.3) activerecord (>= 3.0.11) transaction_isolation (>= 1.0.2) - ttfunk (1.5.1) + ttfunk (1.6.2.1) tzinfo (1.2.7) thread_safe (~> 0.1) - uglifier (4.1.20) + uglifier (4.2.0) execjs (>= 0.3.0, < 3) - unicode-display_width (1.6.1) - unicorn (5.5.1) + unicode-display_width (1.7.0) + unicorn (5.5.5) kgio (~> 2.6) raindrops (~> 0.7) - uniform_notifier (1.12.1) + uniform_notifier (1.13.0) websocket-driver (0.7.1) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.4) @@ -275,12 +278,12 @@ DEPENDENCIES nokogiri (>= 1.10.8) oauth pdf-reader - rails (~> 5.2.4.2) + rails (~> 5.2.4.3) rb-readline rotp rqrcode rspec-rails - rubocop + rubocop (= 0.81) rubocop-rails rubocop-rspec ruumba diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb new file mode 100644 index 00000000..7a574000 --- /dev/null +++ b/app/mailers/application_mailer.rb @@ -0,0 +1,3 @@ +class ApplicationMailer < ActionMailer::Base + default :from => "#{Rails.application.name} " +end diff --git a/app/mailers/ban_notification.rb b/app/mailers/ban_notification.rb index f4bb628e..c31974fe 100644 --- a/app/mailers/ban_notification.rb +++ b/app/mailers/ban_notification.rb @@ -1,6 +1,4 @@ -class BanNotification < ActionMailer::Base - default :from => "#{Rails.application.name} " - +class BanNotification < ApplicationMailer def notify(user, banner, reason) @banner = banner @reason = reason diff --git a/app/mailers/email_message.rb b/app/mailers/email_message.rb index ea8c8989..566274b8 100644 --- a/app/mailers/email_message.rb +++ b/app/mailers/email_message.rb @@ -1,6 +1,4 @@ -class EmailMessage < ActionMailer::Base - default :from => "#{Rails.application.name} " - +class EmailMessage < ApplicationMailer def notify(message, user) @message = message @user = user diff --git a/app/mailers/email_reply.rb b/app/mailers/email_reply.rb index f450b560..3622b09d 100644 --- a/app/mailers/email_reply.rb +++ b/app/mailers/email_reply.rb @@ -1,6 +1,4 @@ -class EmailReply < ActionMailer::Base - default :from => "#{Rails.application.name} " - +class EmailReply < ApplicationMailer def reply(comment, user) @comment = comment @user = user diff --git a/app/mailers/invitation_mailer.rb b/app/mailers/invitation_mailer.rb index 50d5215f..a583cd7c 100644 --- a/app/mailers/invitation_mailer.rb +++ b/app/mailers/invitation_mailer.rb @@ -1,6 +1,4 @@ -class InvitationMailer < ActionMailer::Base - default :from => "#{Rails.application.name} " - +class InvitationMailer < ApplicationMailer def invitation(invitation) @invitation = invitation diff --git a/app/mailers/invitation_request_mailer.rb b/app/mailers/invitation_request_mailer.rb index fcb61f8d..27e18147 100644 --- a/app/mailers/invitation_request_mailer.rb +++ b/app/mailers/invitation_request_mailer.rb @@ -1,6 +1,4 @@ -class InvitationRequestMailer < ActionMailer::Base - default :from => "#{Rails.application.name} " - +class InvitationRequestMailer < ApplicationMailer def invitation_request(invitation_request) @invitation_request = invitation_request diff --git a/app/mailers/password_reset.rb b/app/mailers/password_reset.rb index f618185b..750804f7 100644 --- a/app/mailers/password_reset.rb +++ b/app/mailers/password_reset.rb @@ -1,6 +1,4 @@ -class PasswordReset < ActionMailer::Base - default :from => "#{Rails.application.name} " - +class PasswordReset < ApplicationMailer def password_reset_link(user, ip) @user = user @ip = ip diff --git a/db/migrate/20200519000845_index_users_on_email.rb b/db/migrate/20200519000845_index_users_on_email.rb new file mode 100644 index 00000000..4b47494c --- /dev/null +++ b/db/migrate/20200519000845_index_users_on_email.rb @@ -0,0 +1,6 @@ +class IndexUsersOnEmail < ActiveRecord::Migration[5.2] + def change + # postgresql users: you may want https://stackoverflow.com/a/32136337 + add_index :users, :email, unique: true + end +end diff --git a/db/schema.rb b/db/schema.rb index 2ab8a10c..4c55188f 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2020_02_10_155624) do +ActiveRecord::Schema.define(version: 2020_05_19_000845) do create_table "comments", id: :bigint, unsigned: true, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| t.datetime "created_at", null: false @@ -286,6 +286,7 @@ ActiveRecord::Schema.define(version: 2020_02_10_155624) do t.text "settings" t.index ["banned_by_user_id"], name: "users_banned_by_user_id_fk" t.index ["disabled_invite_by_user_id"], name: "users_disabled_invite_by_user_id_fk" + t.index ["email"], name: "index_users_on_email", unique: true t.index ["invited_by_user_id"], name: "users_invited_by_user_id_fk" t.index ["mailing_list_mode"], name: "mailing_list_enabled" t.index ["mailing_list_token"], name: "mailing_list_token", unique: true diff --git a/extras/sponge.rb b/extras/sponge.rb index f14f63e9..b4f8953a 100644 --- a/extras/sponge.rb +++ b/extras/sponge.rb @@ -88,7 +88,7 @@ class Sponge cooks = @cookies[host] || {} # check for domain cookies - @cookies.keys.each do |dom| + @cookies.each_key do |dom| if dom.length < host.length && dom == host[host.length - dom.length .. host.length - 1] dputs "adding domain keys from #{dom}" cooks = cooks.merge @cookies[dom] diff --git a/spec/models/markdowner_spec.rb b/spec/models/markdowner_spec.rb index 8c8521df..ec469691 100644 --- a/spec/models/markdowner_spec.rb +++ b/spec/models/markdowner_spec.rb @@ -86,14 +86,6 @@ describe Markdowner do end end - context "with title text" do - let(:title_text) { 'title text' } - - it "turns inline image into links with title text" do - expect(subject).to eq(target_html(title_text)) - end - end - context "with title text and alt text" do let(:title_text) { 'title text' }