Skip to content

Commit 7d4b52b

Browse files
committed
Enable Style/WordArray
1 parent eacae00 commit 7d4b52b

File tree

69 files changed

+159
-164
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+159
-164
lines changed

.rubocop.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ Style/WhileUntilModifier:
491491

492492
# Use %w or %W for arrays of words.
493493
Style/WordArray:
494-
Enabled: false
494+
Enabled: true
495495

496496
# Metrics #####################################################################
497497

app/finders/todos_finder.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def projects(items)
9999
end
100100

101101
def type?
102-
type.present? && ['Issue', 'MergeRequest'].include?(type)
102+
type.present? && %w(Issue MergeRequest).include?(type)
103103
end
104104

105105
def type

app/helpers/emails_helper.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def email_action(url)
2424

2525
def action_title(url)
2626
return unless url
27-
["merge_requests", "issues", "commit"].each do |action|
27+
%w(merge_requests issues commit).each do |action|
2828
if url.split("/").include?(action)
2929
return "View #{action.humanize.singularize}"
3030
end

app/helpers/tab_helper.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def project_tab_class
9999
return 'active'
100100
end
101101

102-
if ['services', 'hooks', 'deploy_keys', 'protected_branches'].include? controller.controller_name
102+
if %w(services hooks deploy_keys protected_branches).include? controller.controller_name
103103
"active"
104104
end
105105
end

app/helpers/todos_helper.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,6 @@ def todo_due_date(todo)
150150
private
151151

152152
def show_todo_state?(todo)
153-
(todo.target.is_a?(MergeRequest) || todo.target.is_a?(Issue)) && ['closed', 'merged'].include?(todo.target.state)
153+
(todo.target.is_a?(MergeRequest) || todo.target.is_a?(Issue)) && %w(closed merged).include?(todo.target.state)
154154
end
155155
end

app/models/concerns/issuable.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def with_label(title, sort = nil)
182182
def grouping_columns(sort)
183183
grouping_columns = [arel_table[:id]]
184184

185-
if ["milestone_due_desc", "milestone_due_asc"].include?(sort)
185+
if %w(milestone_due_desc milestone_due_asc).include?(sort)
186186
milestone_table = Milestone.arel_table
187187
grouping_columns << milestone_table[:id]
188188
grouping_columns << milestone_table[:due_date]

app/models/diff_note.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class DiffNote < Note
88
validates :position, presence: true
99
validates :diff_line, presence: true
1010
validates :line_code, presence: true, line_code: true
11-
validates :noteable_type, inclusion: { in: ['Commit', 'MergeRequest'] }
11+
validates :noteable_type, inclusion: { in: %w(Commit MergeRequest) }
1212
validates :resolved_by, presence: true, if: :resolved?
1313
validate :positions_complete
1414
validate :verify_supported

app/models/event.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class << self
4747
def contributions
4848
where("action = ? OR (target_type IN (?) AND action IN (?)) OR (target_type = ? AND action = ?)",
4949
Event::PUSHED,
50-
["MergeRequest", "Issue"], [Event::CREATED, Event::CLOSED, Event::MERGED],
50+
%w(MergeRequest Issue), [Event::CREATED, Event::CLOSED, Event::MERGED],
5151
"Note", Event::COMMENTED)
5252
end
5353

app/models/note.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class Note < ActiveRecord::Base
7272
scope :inc_author, ->{ includes(:author) }
7373
scope :inc_relations_for_view, ->{ includes(:project, :author, :updated_by, :resolved_by, :award_emoji) }
7474

75-
scope :diff_notes, ->{ where(type: ['LegacyDiffNote', 'DiffNote']) }
75+
scope :diff_notes, ->{ where(type: %w(LegacyDiffNote DiffNote)) }
7676
scope :non_diff_notes, ->{ where(type: ['Note', nil]) }
7777

7878
scope :with_associations, -> do

app/models/project_services/drone_ci_service.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def push_valid?(data)
114114
end
115115

116116
def merge_request_valid?(data)
117-
['opened', 'reopened'].include?(data[:object_attributes][:state]) &&
117+
%w(opened reopened).include?(data[:object_attributes][:state]) &&
118118
data[:object_attributes][:merge_status] == 'unchecked'
119119
end
120120
end

app/models/project_services/hipchat_service.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def fields
3636
{ type: 'text', name: 'token', placeholder: 'Room token' },
3737
{ type: 'text', name: 'room', placeholder: 'Room name or ID' },
3838
{ type: 'checkbox', name: 'notify' },
39-
{ type: 'select', name: 'color', choices: ['yellow', 'red', 'green', 'purple', 'gray', 'random'] },
39+
{ type: 'select', name: 'color', choices: %w(yellow red green purple gray random) },
4040
{ type: 'text', name: 'api_version',
4141
placeholder: 'Leave blank for default (v2)' },
4242
{ type: 'text', name: 'server',

app/models/project_services/pushover_service.rb

+11-11
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,19 @@ def fields
3434
[
3535
['Device default sound', nil],
3636
['Pushover (default)', 'pushover'],
37-
['Bike', 'bike'],
38-
['Bugle', 'bugle'],
37+
%w(Bike bike),
38+
%w(Bugle bugle),
3939
['Cash Register', 'cashregister'],
40-
['Classical', 'classical'],
41-
['Cosmic', 'cosmic'],
42-
['Falling', 'falling'],
43-
['Gamelan', 'gamelan'],
44-
['Incoming', 'incoming'],
45-
['Intermission', 'intermission'],
46-
['Magic', 'magic'],
47-
['Mechanical', 'mechanical'],
40+
%w(Classical classical),
41+
%w(Cosmic cosmic),
42+
%w(Falling falling),
43+
%w(Gamelan gamelan),
44+
%w(Incoming incoming),
45+
%w(Intermission intermission),
46+
%w(Magic magic),
47+
%w(Mechanical mechanical),
4848
['Piano Bar', 'pianobar'],
49-
['Siren', 'siren'],
49+
%w(Siren siren),
5050
['Space Alarm', 'spacealarm'],
5151
['Tug Boat', 'tugboat'],
5252
['Alien Alarm (long)', 'alien'],

app/services/projects/download_service.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def valid_url?(url)
2525
end
2626

2727
def http?(url)
28-
url =~ /\A#{URI.regexp(['http', 'https'])}\z/
28+
url =~ /\A#{URI.regexp(%w(http https))}\z/
2929
end
3030

3131
def valid_domain?(url)

config/initializers/health_check.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
HealthCheck.setup do |config|
2-
config.standard_checks = ['database', 'migrations', 'cache']
3-
config.full_checks = ['database', 'migrations', 'cache']
2+
config.standard_checks = %w(database migrations cache)
3+
config.full_checks = %w(database migrations cache)
44
end

config/initializers/metrics.rb

+7-7
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ def instrument_classes(instrumentation)
2020

2121
# Path to search => prefix to strip from constant
2222
paths_to_instrument = {
23-
['app', 'finders'] => ['app', 'finders'],
24-
['app', 'mailers', 'emails'] => ['app', 'mailers'],
25-
['app', 'services', '**'] => ['app', 'services'],
26-
['lib', 'gitlab', 'conflicts'] => ['lib'],
27-
['lib', 'gitlab', 'diff'] => ['lib'],
28-
['lib', 'gitlab', 'email', 'message'] => ['lib'],
29-
['lib', 'gitlab', 'checks'] => ['lib']
23+
%w(app finders) => %w(app finders),
24+
%w(app mailers emails) => %w(app mailers),
25+
['app', 'services', '**'] => %w(app services),
26+
%w(lib gitlab conflicts) => ['lib'],
27+
%w(lib gitlab diff) => ['lib'],
28+
%w(lib gitlab email message) => ['lib'],
29+
%w(lib gitlab checks) => ['lib']
3030
}
3131

3232
paths_to_instrument.each do |(path, prefix)|

db/migrate/20161128142110_remove_unnecessary_indexes.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def up
1212
remove_index :award_emoji, column: :user_id if index_exists?(:award_emoji, :user_id)
1313
remove_index :ci_builds, column: :commit_id if index_exists?(:ci_builds, :commit_id)
1414
remove_index :deployments, column: :project_id if index_exists?(:deployments, :project_id)
15-
remove_index :deployments, column: ["project_id", "environment_id"] if index_exists?(:deployments, ["project_id", "environment_id"])
15+
remove_index :deployments, column: %w(project_id environment_id) if index_exists?(:deployments, %w(project_id environment_id))
1616
remove_index :lists, column: :board_id if index_exists?(:lists, :board_id)
1717
remove_index :milestones, column: :project_id if index_exists?(:milestones, :project_id)
1818
remove_index :notes, column: :project_id if index_exists?(:notes, :project_id)
@@ -24,7 +24,7 @@ def down
2424
add_concurrent_index :award_emoji, :user_id
2525
add_concurrent_index :ci_builds, :commit_id
2626
add_concurrent_index :deployments, :project_id
27-
add_concurrent_index :deployments, ["project_id", "environment_id"]
27+
add_concurrent_index :deployments, %w(project_id environment_id)
2828
add_concurrent_index :lists, :board_id
2929
add_concurrent_index :milestones, :project_id
3030
add_concurrent_index :notes, :project_id

features/steps/project/builds/artifacts.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class Spinach::Features::ProjectBuildsArtifacts < Spinach::FeatureSteps
7676
base64_params = send_data.sub(/\Aartifacts\-entry:/, '')
7777
params = JSON.parse(Base64.urlsafe_decode64(base64_params))
7878

79-
expect(params.keys).to eq(['Archive', 'Entry'])
79+
expect(params.keys).to eq(%w(Archive Entry))
8080
expect(params['Archive']).to end_with('build_artifacts.zip')
8181
expect(params['Entry']).to eq(Base64.encode64('ci_artifacts.txt'))
8282
end

lib/api/commit_statuses.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class CommitStatuses < Grape::API
4040
requires :id, type: String, desc: 'The ID of a project'
4141
requires :sha, type: String, desc: 'The commit hash'
4242
requires :state, type: String, desc: 'The state of the status',
43-
values: ['pending', 'running', 'success', 'failed', 'canceled']
43+
values: %w(pending running success failed canceled)
4444
optional :ref, type: String, desc: 'The ref'
4545
optional :target_url, type: String, desc: 'The target URL to associate with this status'
4646
optional :description, type: String, desc: 'A short description of the status'

lib/api/commits.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ class Commits < Grape::API
157157
optional :path, type: String, desc: 'The file path'
158158
given :path do
159159
requires :line, type: Integer, desc: 'The line number'
160-
requires :line_type, type: String, values: ['new', 'old'], default: 'new', desc: 'The type of the line'
160+
requires :line_type, type: String, values: %w(new old), default: 'new', desc: 'The type of the line'
161161
end
162162
end
163163
post ':id/repository/commits/:sha/comments' do

lib/api/pipelines.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Pipelines < Grape::API
1414
end
1515
params do
1616
use :pagination
17-
optional :scope, type: String, values: ['running', 'branches', 'tags'],
17+
optional :scope, type: String, values: %w(running branches tags),
1818
desc: 'Either running, branches, or tags'
1919
end
2020
get ':id/pipelines' do

lib/api/runners.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Runners < Grape::API
1414
use :pagination
1515
end
1616
get do
17-
runners = filter_runners(current_user.ci_authorized_runners, params[:scope], without: ['specific', 'shared'])
17+
runners = filter_runners(current_user.ci_authorized_runners, params[:scope], without: %w(specific shared))
1818
present paginate(runners), with: Entities::Runner
1919
end
2020

lib/api/v3/commits.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ class Commits < Grape::API
162162
optional :path, type: String, desc: 'The file path'
163163
given :path do
164164
requires :line, type: Integer, desc: 'The line number'
165-
requires :line_type, type: String, values: ['new', 'old'], default: 'new', desc: 'The type of the line'
165+
requires :line_type, type: String, values: %w(new old), default: 'new', desc: 'The type of the line'
166166
end
167167
end
168168
post ':id/repository/commits/:sha/comments' do

lib/ci/api/helpers.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def current_runner
7373

7474
def get_runner_version_from_params
7575
return unless params["info"].present?
76-
attributes_for_keys(["name", "version", "revision", "platform", "architecture"], params["info"])
76+
attributes_for_keys(%w(name version revision platform architecture), params["info"])
7777
end
7878

7979
def max_artifacts_size

lib/gitlab/template/gitlab_ci_yml_template.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def finder(project = nil)
2828
end
2929

3030
def dropdown_names(context)
31-
categories = context == 'autodeploy' ? ['Auto deploy'] : ['General', 'Pages']
31+
categories = context == 'autodeploy' ? ['Auto deploy'] : %w(General Pages)
3232
super().slice(*categories)
3333
end
3434
end

lib/gitlab/url_sanitizer.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module Gitlab
22
class UrlSanitizer
33
def self.sanitize(content)
4-
regexp = URI::Parser.new.make_regexp(['http', 'https', 'ssh', 'git'])
4+
regexp = URI::Parser.new.make_regexp(%w(http https ssh git))
55

66
content.gsub(regexp) { |url| new(url).masked_url }
77
rescue Addressable::URI::InvalidURIError

spec/controllers/profiles/personal_access_tokens_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ def created_token
3232

3333
context "scopes" do
3434
it "allows creation of a token with scopes" do
35-
post :create, personal_access_token: { name: FFaker::Product.brand, scopes: ['api', 'read_user'] }
35+
post :create, personal_access_token: { name: FFaker::Product.brand, scopes: %w(api read_user) }
3636

3737
expect(created_token).not_to be_nil
38-
expect(created_token.scopes).to eq(['api', 'read_user'])
38+
expect(created_token.scopes).to eq(%w(api read_user))
3939
end
4040

4141
it "allows creation of a token with no scopes" do

spec/controllers/projects/merge_requests_controller_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,7 @@ def go(format: 'html')
773773

774774
section['lines'].each do |line|
775775
if section['conflict']
776-
expect(line['type']).to be_in(['old', 'new'])
776+
expect(line['type']).to be_in(%w(old new))
777777
expect(line.values_at('old_line', 'new_line')).to contain_exactly(nil, a_kind_of(Integer))
778778
else
779779
if line['type'].nil?

spec/features/issues/bulk_assignment_labels_spec.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
context 'to all issues' do
5656
before do
5757
check 'check_all_issues'
58-
open_labels_dropdown ['bug', 'feature']
58+
open_labels_dropdown %w(bug feature)
5959
update_issues
6060
end
6161

@@ -70,7 +70,7 @@
7070
context 'to a issue' do
7171
before do
7272
check "selected_issue_#{issue1.id}"
73-
open_labels_dropdown ['bug', 'feature']
73+
open_labels_dropdown %w(bug feature)
7474
update_issues
7575
end
7676

@@ -112,7 +112,7 @@
112112
visit namespace_project_issues_path(project.namespace, project)
113113

114114
check 'check_all_issues'
115-
unmark_labels_in_dropdown ['bug', 'feature']
115+
unmark_labels_in_dropdown %w(bug feature)
116116
update_issues
117117
end
118118

spec/features/issues_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@
150150

151151
describe 'Filter issue' do
152152
before do
153-
['foobar', 'barbaz', 'gitlab'].each do |title|
153+
%w(foobar barbaz gitlab).each do |title|
154154
create(:issue,
155155
author: @user,
156156
assignee: @user,

spec/features/projects/labels/issues_sorted_by_priority_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
page.within('.issues-holder') do
3838
issue_titles = all('.issues-list .issue-title-text').map(&:text)
3939

40-
expect(issue_titles).to eq(['issue_4', 'issue_3', 'issue_5', 'issue_2', 'issue_1'])
40+
expect(issue_titles).to eq(%w(issue_4 issue_3 issue_5 issue_2 issue_1))
4141
end
4242
end
4343
end
@@ -77,7 +77,7 @@
7777

7878
expect(issue_titles[0..1]).to contain_exactly('issue_5', 'issue_8')
7979
expect(issue_titles[2..4]).to contain_exactly('issue_1', 'issue_3', 'issue_7')
80-
expect(issue_titles[5..-1]).to eq(['issue_2', 'issue_4', 'issue_6'])
80+
expect(issue_titles[5..-1]).to eq(%w(issue_2 issue_4 issue_6))
8181
end
8282
end
8383
end

spec/helpers/auth_helper_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
context 'all the button based providers are disabled via application_setting' do
5656
it 'returns false' do
5757
stub_application_setting(
58-
disabled_oauth_sign_in_sources: ['github', 'twitter']
58+
disabled_oauth_sign_in_sources: %w(github twitter)
5959
)
6060

6161
expect(helper.button_based_providers_enabled?).to be false

spec/helpers/issuables_helper_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
utf8: '✓',
5252
author_id: '11',
5353
assignee_id: '18',
54-
label_name: ['bug', 'discussion', 'documentation'],
54+
label_name: %w(bug discussion documentation),
5555
milestone_title: 'v4.0',
5656
sort: 'due_date_asc',
5757
namespace_id: 'gitlab-org',

spec/helpers/issues_helper_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@
113113
describe "awards_sort" do
114114
it "sorts a hash so thumbsup and thumbsdown are always on top" do
115115
data = { "thumbsdown" => "some value", "lifter" => "some value", "thumbsup" => "some value" }
116-
expect(awards_sort(data).keys).to eq(["thumbsup", "thumbsdown", "lifter"])
116+
expect(awards_sort(data).keys).to eq(%w(thumbsup thumbsdown lifter))
117117
end
118118
end
119119

spec/lib/bitbucket/collection_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ def items
1919
it "iterates paginator" do
2020
collection = described_class.new(TestPaginator.new)
2121

22-
expect(collection.to_a).to match(["result_1_page_1", "result_2_page_1", "result_1_page_2", "result_2_page_2"])
22+
expect(collection.to_a).to match(%w(result_1_page_1 result_2_page_1 result_1_page_2 result_2_page_2))
2323
end
2424
end

spec/lib/bitbucket/representation/repo_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
end
3030

3131
describe '#owner_and_slug' do
32-
it { expect(described_class.new({ 'full_name' => 'ben/test' }).owner_and_slug).to eq(['ben', 'test']) }
32+
it { expect(described_class.new({ 'full_name' => 'ben/test' }).owner_and_slug).to eq(%w(ben test)) }
3333
end
3434

3535
describe '#owner' do

0 commit comments

Comments
 (0)