summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2017-04-03 16:47:18 +0000
committerRémy Coutable <remy@rymai.me>2017-04-03 16:47:18 +0000
commitca6a7f1e9c9296317315249de9b8b3803d1c6ddc (patch)
tree3f4c8c39b4586a480e8989648ecf7d9525acf683
parentb2700e64cce7c9b258e117a995eda8de00a8a988 (diff)
parent0a09925dcef1976970bc2674432f69d46786c38f (diff)
downloadgitlab-ce-ca6a7f1e9c9296317315249de9b8b3803d1c6ddc.tar.gz
Merge branch 'style-proc-cop' into 'master'
Enable Style/Proc cop for rubocop See merge request !10382
-rw-r--r--.rubocop.yml4
-rw-r--r--.rubocop_todo.yml5
-rw-r--r--app/mailers/base_mailer.rb4
-rw-r--r--app/models/milestone.rb2
-rw-r--r--app/models/service.rb2
-rw-r--r--changelogs/unreleased/style-proc-cop.yml4
-rw-r--r--lib/api/api_guard.rb2
-rw-r--r--lib/gitlab/ldap/config.rb4
-rw-r--r--spec/initializers/trusted_proxies_spec.rb2
9 files changed, 16 insertions, 13 deletions
diff --git a/.rubocop.yml b/.rubocop.yml
index fa1370ea1f3..ac6b141cea3 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -533,6 +533,10 @@ Style/WhileUntilModifier:
Style/WordArray:
Enabled: true
+# Use `proc` instead of `Proc.new`.
+Style/Proc:
+ Enabled: true
+
# Metrics #####################################################################
# A calculated magnitude based on number of assignments,
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index c24142c0a11..8588988dc87 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -226,11 +226,6 @@ Style/PredicateName:
Style/PreferredHashMethods:
Enabled: false
-# Offense count: 8
-# Cop supports --auto-correct.
-Style/Proc:
- Enabled: false
-
# Offense count: 62
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
diff --git a/app/mailers/base_mailer.rb b/app/mailers/base_mailer.rb
index 79c3c2e62c5..a9b6b33eb5c 100644
--- a/app/mailers/base_mailer.rb
+++ b/app/mailers/base_mailer.rb
@@ -5,8 +5,8 @@ class BaseMailer < ActionMailer::Base
attr_accessor :current_user
helper_method :current_user, :can?
- default from: Proc.new { default_sender_address.format }
- default reply_to: Proc.new { default_reply_to_address.format }
+ default from: proc { default_sender_address.format }
+ default reply_to: proc { default_reply_to_address.format }
def can?
Ability.allowed?(current_user, action, subject)
diff --git a/app/models/milestone.rb b/app/models/milestone.rb
index e85d5709624..ac205b9b738 100644
--- a/app/models/milestone.rb
+++ b/app/models/milestone.rb
@@ -30,7 +30,7 @@ class Milestone < ActiveRecord::Base
validates :title, presence: true, uniqueness: { scope: :project_id }
validates :project, presence: true
- validate :start_date_should_be_less_than_due_date, if: Proc.new { |m| m.start_date.present? && m.due_date.present? }
+ validate :start_date_should_be_less_than_due_date, if: proc { |m| m.start_date.present? && m.due_date.present? }
strip_attributes :title
diff --git a/app/models/service.rb b/app/models/service.rb
index e73f7e5d1a3..54550177744 100644
--- a/app/models/service.rb
+++ b/app/models/service.rb
@@ -25,7 +25,7 @@ class Service < ActiveRecord::Base
belongs_to :project, inverse_of: :services
has_one :service_hook
- validates :project_id, presence: true, unless: Proc.new { |service| service.template? }
+ validates :project_id, presence: true, unless: proc { |service| service.template? }
scope :visible, -> { where.not(type: 'GitlabIssueTrackerService') }
scope :issue_trackers, -> { where(category: 'issue_tracker') }
diff --git a/changelogs/unreleased/style-proc-cop.yml b/changelogs/unreleased/style-proc-cop.yml
new file mode 100644
index 00000000000..25acab740bd
--- /dev/null
+++ b/changelogs/unreleased/style-proc-cop.yml
@@ -0,0 +1,4 @@
+---
+title: Enable Style/Proc cop for rubocop
+merge_request:
+author: mhasbini
diff --git a/lib/api/api_guard.rb b/lib/api/api_guard.rb
index 409cb5b924f..9fcf04efa38 100644
--- a/lib/api/api_guard.rb
+++ b/lib/api/api_guard.rb
@@ -121,7 +121,7 @@ module API
end
def oauth2_bearer_token_error_handler
- Proc.new do |e|
+ proc do |e|
response =
case e
when MissingTokenError
diff --git a/lib/gitlab/ldap/config.rb b/lib/gitlab/ldap/config.rb
index 28129198438..46deea3cc9f 100644
--- a/lib/gitlab/ldap/config.rb
+++ b/lib/gitlab/ldap/config.rb
@@ -124,9 +124,9 @@ module Gitlab
def name_proc
if allow_username_or_email_login
- Proc.new { |name| name.gsub(/@.*\z/, '') }
+ proc { |name| name.gsub(/@.*\z/, '') }
else
- Proc.new { |name| name }
+ proc { |name| name }
end
end
diff --git a/spec/initializers/trusted_proxies_spec.rb b/spec/initializers/trusted_proxies_spec.rb
index ff8b8daa347..70a18f31744 100644
--- a/spec/initializers/trusted_proxies_spec.rb
+++ b/spec/initializers/trusted_proxies_spec.rb
@@ -56,7 +56,7 @@ describe 'trusted_proxies', lib: true do
end
def stub_request(headers = {})
- ActionDispatch::RemoteIp.new(Proc.new { }, false, Rails.application.config.action_dispatch.trusted_proxies).call(headers)
+ ActionDispatch::RemoteIp.new(proc { }, false, Rails.application.config.action_dispatch.trusted_proxies).call(headers)
ActionDispatch::Request.new(headers)
end