Convert a lot of :a => b to a: b and bring peace to the world

Convert a lot of :a => b to a: b and bring peace to the world

diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 0d0f97cc97..812d5bcdd2 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -217,7 +217,7 @@ class ApplicationController < ActionController::Base
     def check_restricted_access
       # note current_user is defined in the CurrentUser mixin
       if SiteSetting.access_password.present? && cookies[:_access] != SiteSetting.access_password
-        redirect_to request_access_path(:return_path => request.fullpath)
+        redirect_to request_access_path(return_path: request.fullpath)
         return false
       end
     end
diff --git a/app/controllers/forums_controller.rb b/app/controllers/forums_controller.rb
index 4cd50ee8c3..29d3600d62 100644
--- a/app/controllers/forums_controller.rb
+++ b/app/controllers/forums_controller.rb
@@ -6,7 +6,7 @@ class ForumsController < ApplicationController
 
   def status
     if $shutdown
-      render text: 'shutting down', :status => 500
+      render text: 'shutting down', status: 500
     else
       render text: 'ok'
     end
diff --git a/app/controllers/topics_controller.rb b/app/controllers/topics_controller.rb
index 4015dfdb3a..f477852fbe 100644
--- a/app/controllers/topics_controller.rb
+++ b/app/controllers/topics_controller.rb
@@ -20,7 +20,7 @@ class TopicsController < ApplicationController
   before_filter :consider_user_for_promotion, only: :show
 
   skip_before_filter :check_xhr, only: [:avatar, :show, :feed]
-  caches_action :avatar, :cache_path => Proc.new {|c| "#{c.params[:post_number]}-#{c.params[:topic_id]}" }
+  caches_action :avatar, cache_path: Proc.new {|c| "#{c.params[:post_number]}-#{c.params[:topic_id]}" }
 
 
   def show
diff --git a/app/controllers/users/omniauth_callbacks_controller.rb b/app/controllers/users/omniauth_callbacks_controller.rb
index efa4872d2f..7b320d0b45 100644
--- a/app/controllers/users/omniauth_callbacks_controller.rb
+++ b/app/controllers/users/omniauth_callbacks_controller.rb
@@ -14,7 +14,7 @@ class Users::OmniauthCallbacksController < ApplicationController
   skip_before_filter :check_xhr
 
   # must be done, cause we may trigger a POST
-  skip_before_filter :verify_authenticity_token, :only => :complete
+  skip_before_filter :verify_authenticity_token, only: :complete
 
   def complete
     # Make sure we support that provider
@@ -49,7 +49,7 @@ class Users::OmniauthCallbacksController < ApplicationController
       twitter_screen_name: screen_name
     }
 
-    user_info = TwitterUserInfo.where(:twitter_user_id => twitter_user_id).first
+    user_info = TwitterUserInfo.where(twitter_user_id: twitter_user_id).first
 
     @data = {
       username: screen_name,
@@ -97,7 +97,7 @@ class Users::OmniauthCallbacksController < ApplicationController
       email_valid: true
     }
 
-    user_info = FacebookUserInfo.where(:facebook_user_id => fb_uid ).first
+    user_info = FacebookUserInfo.where(facebook_user_id: fb_uid).first
 
     @data = {
       username: username,
@@ -194,7 +194,7 @@ class Users::OmniauthCallbacksController < ApplicationController
       github_screen_name: screen_name
     }
 
-    user_info = GithubUserInfo.where(:github_user_id => github_user_id).first
+    user_info = GithubUserInfo.where(github_user_id: github_user_id).first
 
     @data = {
       username: screen_name,
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index b337a95362..41924d5467 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -27,7 +27,7 @@ class UsersController < ApplicationController
   end
 
   def update
-    user = User.where(:username_lower => params[:username].downcase).first
+    user = User.where(username_lower: params[:username].downcase).first
     guardian.ensure_can_edit!(user)
     json_result(user) do |u|
 
@@ -179,7 +179,7 @@ class UsersController < ApplicationController
       # Create auth records
       if auth.present?
         if auth[:twitter_user_id] && auth[:twitter_screen_name] && TwitterUserInfo.find_by_twitter_user_id(auth[:twitter_user_id]).nil?
-          TwitterUserInfo.create(:user_id => user.id, :screen_name => auth[:twitter_screen_name], :twitter_user_id => auth[:twitter_user_id])
+          TwitterUserInfo.create(user_id: user.id, screen_name: auth[:twitter_screen_name], twitter_user_id: auth[:twitter_user_id])
         end
 
         if auth[:facebook].present? && FacebookUserInfo.find_by_facebook_user_id(auth[:facebook][:facebook_user_id]).nil?
@@ -187,7 +187,7 @@ class UsersController < ApplicationController
         end
 
         if auth[:github_user_id] && auth[:github_screen_name] && GithubUserInfo.find_by_github_user_id(auth[:github_user_id]).nil?
-          GithubUserInfo.create(:user_id => user.id, :screen_name => auth[:github_screen_name], :github_user_id => auth[:github_user_id])
+          GithubUserInfo.create(user_id: user.id, screen_name: auth[:github_screen_name], github_user_id: auth[:github_user_id])
         end
       end
 
@@ -219,7 +219,7 @@ class UsersController < ApplicationController
     # TEMP to catch all missing spots
     # raise ActiveRecord::RecordNotFound
 
-    user = User.select(:email).where(:username_lower => params[:username].downcase).first
+    user = User.select(:email).where(username_lower: params[:username].downcase).first
     if user
       # for now we only support gravatar in square (redirect cached for a day), later we can use x-sendfile and/or a cdn to serve local
       size = params[:size].to_i
diff --git a/app/helpers/common_helper.rb b/app/helpers/common_helper.rb
index 83ee98efa5..8a1efe4271 100644
--- a/app/helpers/common_helper.rb
+++ b/app/helpers/common_helper.rb
@@ -1,7 +1,7 @@
 module CommonHelper
   def render_google_analytics_code
     if Rails.env == "production" &&  SiteSetting.ga_tracking_code.present?
-      render :partial => "common/google_analytics"
+      render partial: "common/google_analytics"
     end
   end
-end
\ No newline at end of file
+end
diff --git a/app/mailers/user_notifications.rb b/app/mailers/user_notifications.rb
index 4a1bc1de90..25f37ae645 100644
--- a/app/mailers/user_notifications.rb
+++ b/app/mailers/user_notifications.rb
@@ -53,8 +53,8 @@ class UserNotifications < ActionMailer::Base
       mail to: user.email,
            from: "#{I18n.t('user_notifications.digest.from', site_name: SiteSetting.title)} <#{SiteSetting.notification_email}>",
            subject: I18n.t('user_notifications.digest.subject_template',
-                            :site_name => @site_name,
-                            :date => I18n.l(Time.now, format: :short))
+                            site_name: @site_name,
+                            date: I18n.l(Time.now, format: :short))
     end
   end
 
diff --git a/app/models/category_list.rb b/app/models/category_list.rb
index 255f52d16f..60ff863deb 100644
--- a/app/models/category_list.rb
+++ b/app/models/category_list.rb
@@ -5,7 +5,7 @@ class CategoryList
 
   def initialize(current_user)
     @categories = Category
-                    .includes(:featured_topics => [:category])
+                    .includes(featured_topics: [:category])
                     .includes(:featured_users)
                     .order('topics_week desc, topics_month desc, topics_year desc')
                     .to_a
diff --git a/app/models/user_action.rb b/app/models/user_action.rb
index b7d6363a53..283e22bed2 100644
--- a/app/models/user_action.rb
+++ b/app/models/user_action.rb
@@ -1,7 +1,7 @@
 class UserAction < ActiveRecord::Base
   belongs_to :user
-  belongs_to :target_post, :class_name => "Post"
-  belongs_to :target_topic, :class_name => "Topic"
+  belongs_to :target_post, class_name: "Post"
+  belongs_to :target_topic, class_name: "Topic"
   attr_accessible :acting_user_id, :action_type, :target_topic_id, :target_post_id, :target_user_id, :user_id
 
   validates_presence_of :action_type

[... diff too long, it was truncated ...]

GitHub sha: 5dfb04e4

-1

-1

Umm… -1 ?

Rather than saying -1, why not explain why you don’t like it?

Sure. Sorry if I didn’t explain it before, my fault =)

Well, the new hash syntax is good to do things like:

{
  name: @user.name,
  username: @user.username,
  password: "",
  email: @user.email
}

But it have such limitations and annoying things:

{ foo: :bar } # Annoying
{ 'foo-bar': :cocada } # syntax error, unexpected ':', expecting tASSOC

Sometimes => will be the only available choice, so why don’t always use this?

I agree with @brennovich.

Also, why change it? The old syntax is pretty clear. When learning ruby, we are told that symbols starts with a colon. Don’t you think this new syntax kinda breaks this thought?

Please consider reading this post: http://logicalfriday.com/2011/06/20/i-dont-like-the-ruby-1-9-hash-syntax/

Is this turning into a bikeshed discussion?

http://www.codinghorror.com/blog/2009/03/procrastination-and-the-bikeshed-effect.html

Should it be cornflower blue or some other color?

@brennovich and @mateusg: This change got our code confirming to the coding conventions as per the CONTRIBUTING.md document (https://github.com/discourse/discourse/blob/master/docs/CONTRIBUTING.md)

I think meta might be a better place to discuss your issue with particular choice.

Agreed, move this to http://meta.discourse.org as a topic in the “dev” category.

meta.discourse is a much more appropriate place to have a discussion about this, GitHub is not great for discussion.