Enable Style/Proc cop for rubocop

This commit is contained in:
mhasbini 2017-03-31 18:11:28 +03:00
parent 9fc17f6f4a
commit 0a09925dce
9 changed files with 16 additions and 13 deletions

View file

@ -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,

View file

@ -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.

View file

@ -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)

View file

@ -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

View file

@ -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') }

View file

@ -0,0 +1,4 @@
---
title: Enable Style/Proc cop for rubocop
merge_request:
author: mhasbini

View file

@ -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

View file

@ -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

View file

@ -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