From e2bbbb1a9aea72e4313cdc257460eb416fe8dc0b Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Wed, 22 Feb 2017 12:03:32 -0600 Subject: Fix new offenses --- app/controllers/concerns/spammable_actions.rb | 2 +- app/models/project_services/pushover_service.rb | 2 +- app/models/user.rb | 2 +- config/initializers/metrics.rb | 14 +++++----- lib/gitlab/ci/config/entry/global.rb | 2 +- lib/gitlab/ci/config/entry/jobs.rb | 2 +- spec/lib/expand_variables_spec.rb | 14 +++++----- spec/lib/gitlab/bitbucket_import/importer_spec.rb | 4 +-- spec/lib/gitlab/ci/config/entry/global_spec.rb | 4 +-- spec/lib/gitlab/ci/config/entry/job_spec.rb | 10 +++---- spec/lib/gitlab/ci/status/build/factory_spec.rb | 2 +- spec/lib/gitlab/import_sources_spec.rb | 32 ++++++++++++---------- spec/lib/gitlab/incoming_email_spec.rb | 4 +-- spec/requests/api/labels_spec.rb | 7 +++-- spec/requests/api/v3/labels_spec.rb | 7 +++-- .../merge_requests/resolve_service_spec.rb | 6 ++-- spec/support/repo_helpers.rb | 13 +++++---- spec/support/stub_gitlab_calls.rb | 2 +- 18 files changed, 67 insertions(+), 62 deletions(-) diff --git a/app/controllers/concerns/spammable_actions.rb b/app/controllers/concerns/spammable_actions.rb index da225d8f1c7..d0a692070d9 100644 --- a/app/controllers/concerns/spammable_actions.rb +++ b/app/controllers/concerns/spammable_actions.rb @@ -27,7 +27,7 @@ module SpammableActions render :verify else - fallback.call + yield end end diff --git a/app/models/project_services/pushover_service.rb b/app/models/project_services/pushover_service.rb index 689bf03f469..3e618a8dbf1 100644 --- a/app/models/project_services/pushover_service.rb +++ b/app/models/project_services/pushover_service.rb @@ -55,7 +55,7 @@ class PushoverService < Service ['Pushover Echo (long)', 'echo'], ['Up Down (long)', 'updown'], ['None (silent)', 'none'] - ]}, + ] }, ] end diff --git a/app/models/user.rb b/app/models/user.rb index 296bcc699a9..801c84dc011 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -581,7 +581,7 @@ class User < ActiveRecord::Base if project.repository.branch_exists?(event.branch_name) merge_requests = MergeRequest.where("created_at >= ?", event.created_at) .where(source_project_id: project.id, - source_branch: event.branch_name) + source_branch: event.branch_name) merge_requests.empty? end end diff --git a/config/initializers/metrics.rb b/config/initializers/metrics.rb index 76ce7479a41..f082495cd7d 100644 --- a/config/initializers/metrics.rb +++ b/config/initializers/metrics.rb @@ -20,13 +20,13 @@ def instrument_classes(instrumentation) # Path to search => prefix to strip from constant paths_to_instrument = { - %w(app finders) => %w(app finders), - %w(app mailers emails) => %w(app mailers), - ['app', 'services', '**'] => %w(app services), - %w(lib gitlab conflicts) => ['lib'], - %w(lib gitlab diff) => ['lib'], - %w(lib gitlab email message) => ['lib'], - %w(lib gitlab checks) => ['lib'] + %w(app finders) => %w(app finders), + %w(app mailers emails) => %w(app mailers), + %w(app services **) => %w(app services), + %w(lib gitlab conflicts) => ['lib'], + %w(lib gitlab diff) => ['lib'], + %w(lib gitlab email message) => ['lib'], + %w(lib gitlab checks) => ['lib'] } paths_to_instrument.each do |(path, prefix)| diff --git a/lib/gitlab/ci/config/entry/global.rb b/lib/gitlab/ci/config/entry/global.rb index ac771662b2f..a4ec8f0ff2f 100644 --- a/lib/gitlab/ci/config/entry/global.rb +++ b/lib/gitlab/ci/config/entry/global.rb @@ -49,7 +49,7 @@ module Gitlab factory = Entry::Factory.new(Entry::Jobs) .value(@config.except(*self.class.nodes.keys)) .with(key: :jobs, parent: self, - description: 'Jobs definition for this pipeline') + description: 'Jobs definition for this pipeline') @entries[:jobs] = factory.create! end diff --git a/lib/gitlab/ci/config/entry/jobs.rb b/lib/gitlab/ci/config/entry/jobs.rb index a487a3a06d6..5671a09480b 100644 --- a/lib/gitlab/ci/config/entry/jobs.rb +++ b/lib/gitlab/ci/config/entry/jobs.rb @@ -35,7 +35,7 @@ module Gitlab .value(config || {}) .metadata(name: name) .with(key: name, parent: self, - description: "#{name} job definition.") + description: "#{name} job definition.") @entries[name] = factory.create! end diff --git a/spec/lib/expand_variables_spec.rb b/spec/lib/expand_variables_spec.rb index 9fe15993a7d..730ca1f7c0a 100644 --- a/spec/lib/expand_variables_spec.rb +++ b/spec/lib/expand_variables_spec.rb @@ -15,41 +15,41 @@ describe ExpandVariables do result: 'keyvalue', variables: [ { key: 'variable', value: 'value' } - ]}, + ] }, { value: 'key${variable}', result: 'keyvalue', variables: [ { key: 'variable', value: 'value' } - ]}, + ] }, { value: 'key$variable$variable2', result: 'keyvalueresult', variables: [ { key: 'variable', value: 'value' }, { key: 'variable2', value: 'result' }, - ]}, + ] }, { value: 'key${variable}${variable2}', result: 'keyvalueresult', variables: [ { key: 'variable', value: 'value' }, { key: 'variable2', value: 'result' } - ]}, + ] }, { value: 'key$variable2$variable', result: 'keyresultvalue', variables: [ { key: 'variable', value: 'value' }, { key: 'variable2', value: 'result' }, - ]}, + ] }, { value: 'key${variable2}${variable}', result: 'keyresultvalue', variables: [ { key: 'variable', value: 'value' }, { key: 'variable2', value: 'result' } - ]}, + ] }, { value: 'review/$CI_BUILD_REF_NAME', result: 'review/feature/add-review-apps', variables: [ { key: 'CI_BUILD_REF_NAME', value: 'feature/add-review-apps' } - ]}, + ] }, ] tests.each do |test| diff --git a/spec/lib/gitlab/bitbucket_import/importer_spec.rb b/spec/lib/gitlab/bitbucket_import/importer_spec.rb index 9e557d06ef0..aceb6bf871c 100644 --- a/spec/lib/gitlab/bitbucket_import/importer_spec.rb +++ b/spec/lib/gitlab/bitbucket_import/importer_spec.rb @@ -89,8 +89,8 @@ describe Gitlab::BitbucketImport::Importer, lib: true do stub_request(:get, "https://api.bitbucket.org/2.0/repositories/namespace/repo?pagelen=50&sort=created_on") .with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer', 'User-Agent' => 'Faraday v0.9.2' }) .to_return(status: 200, - body: "", - headers: {}) + body: "", + headers: {}) sample_issues_statuses.each_with_index do |issue, index| stub_request( diff --git a/spec/lib/gitlab/ci/config/entry/global_spec.rb b/spec/lib/gitlab/ci/config/entry/global_spec.rb index d9e48715984..ebd80ac5e1d 100644 --- a/spec/lib/gitlab/ci/config/entry/global_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/global_spec.rb @@ -12,8 +12,8 @@ describe Gitlab::Ci::Config::Entry::Global do it 'contains the expected node names' do expect(described_class.nodes.keys) .to match_array(%i[before_script image services - after_script variables stages - types cache]) + after_script variables stages + types cache]) end end end diff --git a/spec/lib/gitlab/ci/config/entry/job_spec.rb b/spec/lib/gitlab/ci/config/entry/job_spec.rb index 7a733e6a4a7..d20f4ec207d 100644 --- a/spec/lib/gitlab/ci/config/entry/job_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/job_spec.rb @@ -140,11 +140,11 @@ describe Gitlab::Ci::Config::Entry::Job do it 'returns correct value' do expect(entry.value) .to eq(name: :rspec, - before_script: %w[ls pwd], - script: %w[rspec], - commands: "ls\npwd\nrspec", - stage: 'test', - after_script: %w[cleanup]) + before_script: %w[ls pwd], + script: %w[rspec], + commands: "ls\npwd\nrspec", + stage: 'test', + after_script: %w[cleanup]) end end end diff --git a/spec/lib/gitlab/ci/status/build/factory_spec.rb b/spec/lib/gitlab/ci/status/build/factory_spec.rb index 16f0a7b5388..0c40fca0c1a 100644 --- a/spec/lib/gitlab/ci/status/build/factory_spec.rb +++ b/spec/lib/gitlab/ci/status/build/factory_spec.rb @@ -69,7 +69,7 @@ describe Gitlab::Ci::Status::Build::Factory do it 'matches correct extended statuses' do expect(factory.extended_statuses) .to eq [Gitlab::Ci::Status::Build::Retryable, - Gitlab::Ci::Status::Build::FailedAllowed] + Gitlab::Ci::Status::Build::FailedAllowed] end it 'fabricates a failed but allowed build status' do diff --git a/spec/lib/gitlab/import_sources_spec.rb b/spec/lib/gitlab/import_sources_spec.rb index 962af8bdf42..b3b5e5e7e33 100644 --- a/spec/lib/gitlab/import_sources_spec.rb +++ b/spec/lib/gitlab/import_sources_spec.rb @@ -23,14 +23,15 @@ describe Gitlab::ImportSources do it 'returns an array' do expected = %w( -github -bitbucket -gitlab -google_code -fogbugz -git -gitlab_project -gitea) + github + bitbucket + gitlab + google_code + fogbugz + git + gitlab_project + gitea + ) expect(described_class.values).to eq(expected) end @@ -40,13 +41,14 @@ gitea) it 'returns an array of importer names' do expected = %w( -github -bitbucket -gitlab -google_code -fogbugz -gitlab_project -gitea) + github + bitbucket + gitlab + google_code + fogbugz + gitlab_project + gitea + ) expect(described_class.importer_names).to eq(expected) end diff --git a/spec/lib/gitlab/incoming_email_spec.rb b/spec/lib/gitlab/incoming_email_spec.rb index 66fc3ad0c3b..698bd72d0f8 100644 --- a/spec/lib/gitlab/incoming_email_spec.rb +++ b/spec/lib/gitlab/incoming_email_spec.rb @@ -101,8 +101,8 @@ describe Gitlab::IncomingEmail, lib: true do it 'returns reply key' do expect(described_class.scan_fallback_references(references)) .to eq(%w[issue_1@localhost - reply-59d8df8370b7e95c5a49fbf86aeb2c93@localhost - exchange@microsoft.com]) + reply-59d8df8370b7e95c5a49fbf86aeb2c93@localhost + exchange@microsoft.com]) end end end diff --git a/spec/requests/api/labels_spec.rb b/spec/requests/api/labels_spec.rb index eb3553d3b71..af271dbd4f5 100644 --- a/spec/requests/api/labels_spec.rb +++ b/spec/requests/api/labels_spec.rb @@ -22,9 +22,10 @@ describe API::Labels, api: true do create(:labeled_merge_request, labels: [priority_label], author: user, source_project: project ) expected_keys = %w( -id name color description -open_issues_count closed_issues_count open_merge_requests_count -subscribed priority) + id name color description + open_issues_count closed_issues_count open_merge_requests_count + subscribed priority + ) get api("/projects/#{project.id}/labels", user) diff --git a/spec/requests/api/v3/labels_spec.rb b/spec/requests/api/v3/labels_spec.rb index a0fc9215c6e..f44403374e9 100644 --- a/spec/requests/api/v3/labels_spec.rb +++ b/spec/requests/api/v3/labels_spec.rb @@ -22,9 +22,10 @@ describe API::V3::Labels, api: true do create(:labeled_merge_request, labels: [priority_label], author: user, source_project: project ) expected_keys = %w( -id name color description -open_issues_count closed_issues_count open_merge_requests_count -subscribed priority) + id name color description + open_issues_count closed_issues_count open_merge_requests_count + subscribed priority + ) get v3_api("/projects/#{project.id}/labels", user) diff --git a/spec/services/merge_requests/resolve_service_spec.rb b/spec/services/merge_requests/resolve_service_spec.rb index 26cf0bbffdf..b7f475597b4 100644 --- a/spec/services/merge_requests/resolve_service_spec.rb +++ b/spec/services/merge_requests/resolve_service_spec.rb @@ -60,7 +60,7 @@ describe MergeRequests::ResolveService do it 'creates a commit with the correct parents' do expect(merge_request.source_branch_head.parents.map(&:id)) .to eq(%w(1450cd639e0bc6721eb02800169e464f212cde06 -824be604a34828eb682305f0d963056cfac87b2d)) + 824be604a34828eb682305f0d963056cfac87b2d)) end end @@ -86,7 +86,7 @@ describe MergeRequests::ResolveService do it 'creates a commit with the correct parents' do expect(merge_request_from_fork.source_branch_head.parents.map(&:id)) .to eq(['404fa3fc7c2c9b5dacff102f353bdf55b1be2813', - target_head]) + target_head]) end end end @@ -126,7 +126,7 @@ describe MergeRequests::ResolveService do it 'creates a commit with the correct parents' do expect(merge_request.source_branch_head.parents.map(&:id)) .to eq(%w(1450cd639e0bc6721eb02800169e464f212cde06 -824be604a34828eb682305f0d963056cfac87b2d)) + 824be604a34828eb682305f0d963056cfac87b2d)) end it 'sets the content to the content given' do diff --git a/spec/support/repo_helpers.rb b/spec/support/repo_helpers.rb index aab5d32ff36..e9d5c7b12ae 100644 --- a/spec/support/repo_helpers.rb +++ b/spec/support/repo_helpers.rb @@ -42,7 +42,7 @@ Signed-off-by: Dmitriy Zaporozhets eos ) end - + def another_sample_commit OpenStruct.new( id: "e56497bb5f03a90a51293fc6d516788730953899", @@ -101,11 +101,12 @@ eos ] commits = %w( -5937ac0a7beb003549fc5fd26fc247adbce4a52e -570e7b2abdd848b95f2f578043fc23bd6f6fd24d -6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9 -d14d6c0abdd253381df51a723d58691b2ee1ab08 -c1acaa58bbcbc3eafe538cb8274ba387047b69f8).reverse # last commit is recent one + 5937ac0a7beb003549fc5fd26fc247adbce4a52e + 570e7b2abdd848b95f2f578043fc23bd6f6fd24d + 6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9 + d14d6c0abdd253381df51a723d58691b2ee1ab08 + c1acaa58bbcbc3eafe538cb8274ba387047b69f8 + ).reverse # last commit is recent one OpenStruct.new( source_branch: 'master', diff --git a/spec/support/stub_gitlab_calls.rb b/spec/support/stub_gitlab_calls.rb index 641b11d51bf..69e1ad18b15 100644 --- a/spec/support/stub_gitlab_calls.rb +++ b/spec/support/stub_gitlab_calls.rb @@ -53,7 +53,7 @@ module StubGitlabCalls stub_request(:post, "#{gitlab_url}api/v3/session.json") .with(body: "{\"email\":\"test@test.com\",\"password\":\"123456\"}", - headers: { 'Content-Type' => 'application/json' }) + headers: { 'Content-Type' => 'application/json' }) .to_return(status: 201, body: f, headers: { 'Content-Type' => 'application/json' }) end -- cgit v1.2.1