Commit fe3f623cae2f6fb459b0e8fbbdbade55f3d889ba

Authored by Laust Rud Jacobsen
1 parent 7f626d1d
Exists in master and in 1 other branch production

Rubocop: use lambda for multi-line lambdas

.rubocop_todo.yml
@@ -158,15 +158,6 @@ Style/IfUnlessModifier: @@ -158,15 +158,6 @@ Style/IfUnlessModifier:
158 - 'app/models/notice.rb' 158 - 'app/models/notice.rb'
159 - 'app/models/user.rb' 159 - 'app/models/user.rb'
160 160
161 -# Offense count: 6  
162 -# Cop supports --auto-correct.  
163 -Style/Lambda:  
164 - Exclude:  
165 - - 'app/models/app.rb'  
166 - - 'app/models/problem.rb'  
167 - - 'config/load.rb'  
168 - - 'spec/models/notice_observer_spec.rb'  
169 -  
170 # Offense count: 17 161 # Offense count: 17
171 # Cop supports --auto-correct. 162 # Cop supports --auto-correct.
172 Style/LeadingCommentSpace: 163 Style/LeadingCommentSpace:
app/models/problem.rb
@@ -61,7 +61,7 @@ class Problem @@ -61,7 +61,7 @@ class Problem
61 scope :resolved, -> { where(:resolved => true) } 61 scope :resolved, -> { where(:resolved => true) }
62 scope :unresolved, -> { where(:resolved => false) } 62 scope :unresolved, -> { where(:resolved => false) }
63 scope :ordered, -> { order_by(:last_notice_at.desc) } 63 scope :ordered, -> { order_by(:last_notice_at.desc) }
64 - scope :for_apps, lambda { |apps| where(:app_id.in => apps.all.map(&:id)) } 64 + scope :for_apps, ->(apps) { where(:app_id.in => apps.all.map(&:id)) }
65 65
66 validates_presence_of :last_notice_at, :first_notice_at 66 validates_presence_of :last_notice_at, :first_notice_at
67 67
config/load.rb
@@ -29,7 +29,7 @@ Errbit::Config = Configurator.run({ @@ -29,7 +29,7 @@ Errbit::Config = Configurator.run({
29 mongo_url: %w(MONGOLAB_URI MONGOHQ_URL MONGODB_URL MONGO_URL), 29 mongo_url: %w(MONGOLAB_URI MONGOHQ_URL MONGODB_URL MONGO_URL),
30 30
31 # github 31 # github
32 - github_url: ['GITHUB_URL', ->(values) { 32 + github_url: ['GITHUB_URL', lambda { |values|
33 values[:github_url].gsub(%r{/*\z}, '') 33 values[:github_url].gsub(%r{/*\z}, '')
34 }], 34 }],
35 github_authentication: ['GITHUB_AUTHENTICATION'], 35 github_authentication: ['GITHUB_AUTHENTICATION'],
@@ -40,7 +40,7 @@ Errbit::Config = Configurator.run({ @@ -40,7 +40,7 @@ Errbit::Config = Configurator.run({
40 github_api_url: ['GITHUB_API_URL'], 40 github_api_url: ['GITHUB_API_URL'],
41 github_site_title: ['GITHUB_SITE_TITLE'], 41 github_site_title: ['GITHUB_SITE_TITLE'],
42 42
43 - email_delivery_method: ['EMAIL_DELIVERY_METHOD', -> (values) { 43 + email_delivery_method: ['EMAIL_DELIVERY_METHOD', lambda { |values|
44 values[:email_delivery_method] && values[:email_delivery_method].to_sym 44 values[:email_delivery_method] && values[:email_delivery_method].to_sym
45 }], 45 }],
46 46
@@ -50,7 +50,7 @@ Errbit::Config = Configurator.run({ @@ -50,7 +50,7 @@ Errbit::Config = Configurator.run({
50 smtp_authentication: ['SMTP_AUTHENTICATION'], 50 smtp_authentication: ['SMTP_AUTHENTICATION'],
51 smtp_user_name: %w(SMTP_USERNAME SENDGRID_USERNAME), 51 smtp_user_name: %w(SMTP_USERNAME SENDGRID_USERNAME),
52 smtp_password: %w(SMTP_PASSWORD SENDGRID_PASSWORD), 52 smtp_password: %w(SMTP_PASSWORD SENDGRID_PASSWORD),
53 - smtp_domain: ['SMTP_DOMAIN', 'SENDGRID_DOMAIN', ->(values) { 53 + smtp_domain: ['SMTP_DOMAIN', 'SENDGRID_DOMAIN', lambda { |values|
54 values[:smtp_domain] || 54 values[:smtp_domain] ||
55 (values[:email_from] && values[:email_from].split('@').last) || nil 55 (values[:email_from] && values[:email_from].split('@').last) || nil
56 }], 56 }],
spec/models/notice_observer_spec.rb
1 describe "Callback on Notice", type: 'model' do 1 describe "Callback on Notice", type: 'model' do
2 let(:notice_attrs_for) do 2 let(:notice_attrs_for) do
3 - ->(api_key) do 3 + lambda do |api_key|
4 { 4 {
5 error_class: "HoptoadTestingException", 5 error_class: "HoptoadTestingException",
6 message: "some message", 6 message: "some message",