Commit ba9c1cb2306ff4f173872f26e7ce7f877f7a51f4

Authored by Laust Rud Jacobsen
1 parent 4bdcb547
Exists in master and in 1 other branch production

Rubocop: use word-arrays

.rubocop_todo.yml
@@ -576,9 +576,3 @@ Style/UnlessElse: @@ -576,9 +576,3 @@ Style/UnlessElse:
576 Style/UnneededPercentQ: 576 Style/UnneededPercentQ:
577 Exclude: 577 Exclude:
578 - 'spec/models/notice_spec.rb' 578 - 'spec/models/notice_spec.rb'
579 -  
580 -# Offense count: 10  
581 -# Cop supports --auto-correct.  
582 -# Configuration parameters: WordRegex.  
583 -Style/WordArray:  
584 - MinSize: 11  
app/models/notification_services/hipchat_service.rb
@@ -20,7 +20,7 @@ if defined? HipChat @@ -20,7 +20,7 @@ if defined? HipChat
20 }], 20 }],
21 ] 21 ]
22 Mandatory_fields = [:service, :api_token, :room_id] 22 Mandatory_fields = [:service, :api_token, :room_id]
23 - API_versions = ['v1', 'v2'] 23 + API_versions = %w(v1 v2)
24 24
25 def check_params 25 def check_params
26 Fields.each do |field, hash| 26 Fields.each do |field, hash|
config/load.rb
@@ -26,7 +26,7 @@ Errbit::Config = Configurator.run({ @@ -26,7 +26,7 @@ Errbit::Config = Configurator.run({
26 26
27 serve_static_assets: ['SERVE_STATIC_ASSETS'], 27 serve_static_assets: ['SERVE_STATIC_ASSETS'],
28 secret_key_base: ['SECRET_KEY_BASE'], 28 secret_key_base: ['SECRET_KEY_BASE'],
29 - mongo_url: ['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', ->(values) {
@@ -48,8 +48,8 @@ Errbit::Config = Configurator.run({ @@ -48,8 +48,8 @@ Errbit::Config = Configurator.run({
48 smtp_address: ['SMTP_SERVER'], 48 smtp_address: ['SMTP_SERVER'],
49 smtp_port: ['SMTP_PORT'], 49 smtp_port: ['SMTP_PORT'],
50 smtp_authentication: ['SMTP_AUTHENTICATION'], 50 smtp_authentication: ['SMTP_AUTHENTICATION'],
51 - smtp_user_name: ['SMTP_USERNAME', 'SENDGRID_USERNAME'],  
52 - smtp_password: ['SMTP_PASSWORD', 'SENDGRID_PASSWORD'], 51 + smtp_user_name: %w(SMTP_USERNAME SENDGRID_USERNAME),
  52 + smtp_password: %w(SMTP_PASSWORD SENDGRID_PASSWORD),
53 smtp_domain: ['SMTP_DOMAIN', 'SENDGRID_DOMAIN', ->(values) { 53 smtp_domain: ['SMTP_DOMAIN', 'SENDGRID_DOMAIN', ->(values) {
54 values[:smtp_domain] || 54 values[:smtp_domain] ||
55 (values[:email_from] && values[:email_from].split('@').last)|| 55 (values[:email_from] && values[:email_from].split('@').last)||
spec/controllers/api/v1/problems_controller_spec.rb
@@ -37,19 +37,18 @@ describe Api::V1::ProblemsController, type: 'controller' do @@ -37,19 +37,18 @@ describe Api::V1::ProblemsController, type: 'controller' do
37 get :show, :auth_token => @user.authentication_token, :format => "json", :id => @problem.id 37 get :show, :auth_token => @user.authentication_token, :format => "json", :id => @problem.id
38 returned_problem = JSON.parse(response.body) 38 returned_problem = JSON.parse(response.body)
39 39
40 - expect( returned_problem.keys ).to match_array([  
41 - "app_name",  
42 - "first_notice_at",  
43 - "message",  
44 - "app_id",  
45 - "last_notice_at",  
46 - "_id",  
47 - "resolved",  
48 - "resolved_at",  
49 - "where",  
50 - "notices_count",  
51 - "environment"  
52 - ]) 40 + expect( returned_problem.keys ).to match_array(%w(
  41 + app_name
  42 + first_notice_at
  43 + message
  44 + app_id
  45 + last_notice_at
  46 + _id
  47 + resolved
  48 + resolved_at
  49 + where
  50 + notices_count
  51 + environment))
53 end 52 end
54 53
55 it "returns a 404 if the problem cannot be found" do 54 it "returns a 404 if the problem cannot be found" do
spec/controllers/apps_controller_spec.rb
@@ -118,7 +118,7 @@ describe AppsController, type: 'controller' do @@ -118,7 +118,7 @@ describe AppsController, type: 'controller' do
118 118
119 context 'with environment filters' do 119 context 'with environment filters' do
120 before(:each) do 120 before(:each) do
121 - environments = ['production', 'test', 'development', 'staging'] 121 + environments = %w(production test development staging)
122 20.times do |i| 122 20.times do |i|
123 Fabricate(:problem, :app => app, :environment => environments[i % environments.length]) 123 Fabricate(:problem, :app => app, :environment => environments[i % environments.length])
124 end 124 end
spec/controllers/problems_controller_spec.rb
@@ -34,7 +34,7 @@ describe ProblemsController, type: 'controller' do @@ -34,7 +34,7 @@ describe ProblemsController, type: 'controller' do
34 34
35 context 'with environment filters' do 35 context 'with environment filters' do
36 before(:each) do 36 before(:each) do
37 - environments = ['production', 'test', 'development', 'staging'] 37 + environments = %w(production test development staging)
38 20.times do |i| 38 20.times do |i|
39 Fabricate(:problem, :environment => environments[i % environments.length]) 39 Fabricate(:problem, :environment => environments[i % environments.length])
40 end 40 end
spec/lib/configurator_spec.rb
@@ -6,12 +6,12 @@ describe Configurator do @@ -6,12 +6,12 @@ describe Configurator do
6 end 6 end
7 7
8 it 'takes the first existing env, second item' do 8 it 'takes the first existing env, second item' do
9 - result = Configurator.run({ two: ['VARTWO', 'VARTHREE'] }) 9 + result = Configurator.run({ two: %w(VARTWO VARTHREE) })
10 expect(result.two).to eq('zipp') 10 expect(result.two).to eq('zipp')
11 end 11 end
12 12
13 it 'takes the first existing env, first item' do 13 it 'takes the first existing env, first item' do
14 - result = Configurator.run({ three: ['VARTHREE', 'VARONE'] }) 14 + result = Configurator.run({ three: %w(VARTHREE VARONE) })
15 expect(result.three).to eq('zipp') 15 expect(result.three).to eq('zipp')
16 end 16 end
17 17
@@ -44,7 +44,7 @@ describe Configurator do @@ -44,7 +44,7 @@ describe Configurator do
44 it 'extracts array values' do 44 it 'extracts array values' do
45 allow(ENV).to receive(:[]).with('MYARRAY').and_return('[one,two,three]') 45 allow(ENV).to receive(:[]).with('MYARRAY').and_return('[one,two,three]')
46 result = Configurator.run({ myarray: ['MYARRAY'] }) 46 result = Configurator.run({ myarray: ['MYARRAY'] })
47 - expect(result.myarray).to eq(['one', 'two', 'three']) 47 + expect(result.myarray).to eq(%w(one two three))
48 end 48 end
49 49
50 it 'extracts booleans' do 50 it 'extracts booleans' do