DEV: Correct auth_provider deprecation warning

DEV: Correct auth_provider deprecation warning

From 71aaed272cb2e8155e771b8055b7eec975b8c66b Mon Sep 17 00:00:00 2001
From: David Taylor <david@taylorhq.com>
Date: Fri, 30 Nov 2018 22:22:26 +0000
Subject: [PATCH] DEV: Correct auth_provider deprecation warning


diff --git a/lib/auth/auth_provider.rb b/lib/auth/auth_provider.rb
index ca56c4e..149744c 100644
--- a/lib/auth/auth_provider.rb
+++ b/lib/auth/auth_provider.rb
@@ -18,7 +18,7 @@ class Auth::AuthProvider
     @enabled_setting = val
   end
 
-  def background_color=(val) Discourse.deprecate("background_color is no longer functional. Please define authenticator.enabled? instead") end;
+  def background_color=(val) Discourse.deprecate("background_color is no longer functional. Please use CSS instead") end;
 
   def name
     authenticator.name

GitHub

Hmmm, not a huge fan of this fancy

def background_color=(val) Discourse.deprecate("background_color is no longer functional. Please use CSS instead") end;`

Instead:

def background_color=(val)
   Discourse.deprecate("background_color is no longer functional. Please use CSS instead") 
end

Magic has risk of backfiring:

irb(main):001:0> def a puts; end
=> :a
irb(main):002:0> a
Traceback (most recent call last):
        3: from /home/sam/.rbenv/versions/2.5.2/bin/irb:11:in `<main>'
        2: from (irb):2
        1: from (irb):1:in `a'
ArgumentError (wrong number of arguments (given 0, expected 1))
irb(main):003:0> def a() puts; end
=> :a
irb(main):004:0> a

=> nil
irb(main):005:0> def a; puts; end
=> :a
irb(main):006:0> a

=> nil
irb(main):
3 Likes

Reformatted in DEV: Reformat single line method definition · discourse/discourse@9125b5f · GitHub

I also opened a PR to enforce this in Rubocop, so that it doesn’t happen again: DEV: Enable `Style/SingleLineMethods` and `Style/Semicolon` in Rubocop by davidtaylorhq · Pull Request #6717 · discourse/discourse · GitHub

2 Likes