Commit bee9a921 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'ee-style-proc-cop' into 'master'

Enable Style/Proc cop for rubocop

See merge request !1559
parents d29d6f7d 15a252ed
...@@ -535,6 +535,10 @@ Style/WhileUntilModifier: ...@@ -535,6 +535,10 @@ Style/WhileUntilModifier:
Style/WordArray: Style/WordArray:
Enabled: true Enabled: true
# Use `proc` instead of `Proc.new`.
Style/Proc:
Enabled: true
# Metrics ##################################################################### # Metrics #####################################################################
# A calculated magnitude based on number of assignments, # A calculated magnitude based on number of assignments,
......
...@@ -226,11 +226,6 @@ Style/PredicateName: ...@@ -226,11 +226,6 @@ Style/PredicateName:
Style/PreferredHashMethods: Style/PreferredHashMethods:
Enabled: false Enabled: false
# Offense count: 9
# Cop supports --auto-correct.
Style/Proc:
Enabled: false
# Offense count: 64 # Offense count: 64
# Cop supports --auto-correct. # Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles. # Configuration parameters: EnforcedStyle, SupportedStyles.
......
...@@ -5,8 +5,8 @@ class BaseMailer < ActionMailer::Base ...@@ -5,8 +5,8 @@ class BaseMailer < ActionMailer::Base
attr_accessor :current_user attr_accessor :current_user
helper_method :current_user, :can? helper_method :current_user, :can?
default from: Proc.new { default_sender_address.format } default from: proc { default_sender_address.format }
default reply_to: Proc.new { default_reply_to_address.format } default reply_to: proc { default_reply_to_address.format }
def can? def can?
Ability.allowed?(current_user, action, subject) Ability.allowed?(current_user, action, subject)
......
...@@ -32,7 +32,7 @@ class Milestone < ActiveRecord::Base ...@@ -32,7 +32,7 @@ class Milestone < ActiveRecord::Base
validates :title, presence: true, uniqueness: { scope: :project_id } validates :title, presence: true, uniqueness: { scope: :project_id }
validates :project, presence: true 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 strip_attributes :title
......
...@@ -25,7 +25,7 @@ class Service < ActiveRecord::Base ...@@ -25,7 +25,7 @@ class Service < ActiveRecord::Base
belongs_to :project, inverse_of: :services belongs_to :project, inverse_of: :services
has_one :service_hook 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 :visible, -> { where.not(type: 'GitlabIssueTrackerService') }
scope :issue_trackers, -> { where(category: 'issue_tracker') } scope :issue_trackers, -> { where(category: 'issue_tracker') }
......
---
title: Enable Style/Proc cop for rubocop
merge_request:
author: mhasbini
...@@ -121,7 +121,7 @@ module API ...@@ -121,7 +121,7 @@ module API
end end
def oauth2_bearer_token_error_handler def oauth2_bearer_token_error_handler
Proc.new do |e| proc do |e|
response = response =
case e case e
when MissingTokenError when MissingTokenError
......
...@@ -137,9 +137,9 @@ module Gitlab ...@@ -137,9 +137,9 @@ module Gitlab
def name_proc def name_proc
if allow_username_or_email_login if allow_username_or_email_login
Proc.new { |name| name.gsub(/@.*\z/, '') } proc { |name| name.gsub(/@.*\z/, '') }
else else
Proc.new { |name| name } proc { |name| name }
end end
end end
......
...@@ -1090,7 +1090,7 @@ namespace :gitlab do ...@@ -1090,7 +1090,7 @@ namespace :gitlab do
end end
def check_gitlab_geo_node(node) def check_gitlab_geo_node(node)
display_error = Proc.new do |e| display_error = proc do |e|
puts 'no'.color(:red) puts 'no'.color(:red)
puts ' Reason:'.color(:blue) puts ' Reason:'.color(:blue)
puts " #{e.message}" puts " #{e.message}"
......
...@@ -56,7 +56,7 @@ describe 'trusted_proxies', lib: true do ...@@ -56,7 +56,7 @@ describe 'trusted_proxies', lib: true do
end end
def stub_request(headers = {}) 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) ActionDispatch::Request.new(headers)
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment