Commit 84113d7e authored by Robert Speicher's avatar Robert Speicher

Merge branch 'rubocop/enable-space-after-cops' into 'master'

Enable Style/SpaceAfterComma and Colon Rubocop cops

See #17478

See merge request !4991
parents 722a6c53 28bafd53
...@@ -534,11 +534,11 @@ Style/SingleLineMethods: ...@@ -534,11 +534,11 @@ Style/SingleLineMethods:
# Use spaces after colons. # Use spaces after colons.
Style/SpaceAfterColon: Style/SpaceAfterColon:
Enabled: false Enabled: true
# Use spaces after commas. # Use spaces after commas.
Style/SpaceAfterComma: Style/SpaceAfterComma:
Enabled: false Enabled: true
# Do not put a space between a method name and the opening parenthesis in a # Do not put a space between a method name and the opening parenthesis in a
# method definition. # method definition.
......
...@@ -25,7 +25,7 @@ module Ci ...@@ -25,7 +25,7 @@ module Ci
return render_404 unless @project return render_404 unless @project
image = Ci::ImageForBuildService.new.execute(@project, params) image = Ci::ImageForBuildService.new.execute(@project, params)
send_file image.path, filename: image.name, disposition: 'inline', type:"image/svg+xml" send_file image.path, filename: image.name, disposition: 'inline', type: "image/svg+xml"
end end
protected protected
......
...@@ -52,7 +52,7 @@ module PageLayoutHelper ...@@ -52,7 +52,7 @@ module PageLayoutHelper
raise ArgumentError, 'cannot provide more than two attributes' if map.length > 2 raise ArgumentError, 'cannot provide more than two attributes' if map.length > 2
@page_card_attributes ||= {} @page_card_attributes ||= {}
@page_card_attributes = map.reject { |_,v| v.blank? } if map.present? @page_card_attributes = map.reject { |_, v| v.blank? } if map.present?
@page_card_attributes @page_card_attributes
end end
......
...@@ -15,7 +15,7 @@ module ProjectsHelper ...@@ -15,7 +15,7 @@ module ProjectsHelper
def link_to_member_avatar(author, opts = {}) def link_to_member_avatar(author, opts = {})
default_opts = { avatar: true, name: true, size: 16, author_class: 'author', title: ":name" } default_opts = { avatar: true, name: true, size: 16, author_class: 'author', title: ":name" }
opts = default_opts.merge(opts) opts = default_opts.merge(opts)
image_tag(avatar_icon(author, opts[:size]), width: opts[:size], class: "avatar avatar-inline #{"s#{opts[:size]}" if opts[:size]}", alt:'') if opts[:avatar] image_tag(avatar_icon(author, opts[:size]), width: opts[:size], class: "avatar avatar-inline #{"s#{opts[:size]}" if opts[:size]}", alt: '') if opts[:avatar]
end end
def link_to_member(project, author, opts = {}, &block) def link_to_member(project, author, opts = {}, &block)
...@@ -27,7 +27,7 @@ module ProjectsHelper ...@@ -27,7 +27,7 @@ module ProjectsHelper
author_html = "" author_html = ""
# Build avatar image tag # Build avatar image tag
author_html << image_tag(avatar_icon(author, opts[:size]), width: opts[:size], class: "avatar avatar-inline #{"s#{opts[:size]}" if opts[:size]}", alt:'') if opts[:avatar] author_html << image_tag(avatar_icon(author, opts[:size]), width: opts[:size], class: "avatar avatar-inline #{"s#{opts[:size]}" if opts[:size]}", alt: '') if opts[:avatar]
# Build name span tag # Build name span tag
if opts[:by_username] if opts[:by_username]
......
...@@ -54,7 +54,7 @@ module Network ...@@ -54,7 +54,7 @@ module Network
@map = {} @map = {}
@reserved = {} @reserved = {}
@commits.each_with_index do |c,i| @commits.each_with_index do |c, i|
c.time = i c.time = i
days[i] = c.committed_date days[i] = c.committed_date
@map[c.id] = c @map[c.id] = c
...@@ -116,7 +116,7 @@ module Network ...@@ -116,7 +116,7 @@ module Network
end end
def commits_sort_by_ref def commits_sort_by_ref
@commits.sort do |a,b| @commits.sort do |a, b|
if include_ref?(a) if include_ref?(a)
-1 -1
elsif include_ref?(b) elsif include_ref?(b)
......
...@@ -106,7 +106,7 @@ class HipchatService < Service ...@@ -106,7 +106,7 @@ class HipchatService < Service
else else
message << "pushed to #{ref_type} <a href=\""\ message << "pushed to #{ref_type} <a href=\""\
"#{project.web_url}/commits/#{CGI.escape(ref)}\">#{ref}</a> " "#{project.web_url}/commits/#{CGI.escape(ref)}\">#{ref}</a> "
message << "of <a href=\"#{project.web_url}\">#{project.name_with_namespace.gsub!(/\s/,'')}</a> " message << "of <a href=\"#{project.web_url}\">#{project.name_with_namespace.gsub!(/\s/, '')}</a> "
message << "(<a href=\"#{project.web_url}/compare/#{before}...#{after}\">Compare changes</a>)" message << "(<a href=\"#{project.web_url}/compare/#{before}...#{after}\">Compare changes</a>)"
push[:commits].take(MAX_COMMITS).each do |commit| push[:commits].take(MAX_COMMITS).each do |commit|
......
...@@ -124,7 +124,7 @@ class JiraService < IssueTrackerService ...@@ -124,7 +124,7 @@ class JiraService < IssueTrackerService
def build_api_url_from_project_url def build_api_url_from_project_url
server = URI(project_url) server = URI(project_url)
default_ports = [["http",80],["https",443]].include?([server.scheme,server.port]) default_ports = [["http", 80], ["https", 443]].include?([server.scheme, server.port])
server_url = "#{server.scheme}://#{server.host}" server_url = "#{server.scheme}://#{server.host}"
server_url.concat(":#{server.port}") unless default_ports server_url.concat(":#{server.port}") unless default_ports
"#{server_url}/rest/api/#{DEFAULT_API_VERSION}" "#{server_url}/rest/api/#{DEFAULT_API_VERSION}"
......
...@@ -764,7 +764,7 @@ class User < ActiveRecord::Base ...@@ -764,7 +764,7 @@ class User < ActiveRecord::Base
unless email_domains.blank? unless email_domains.blank?
match_found = email_domains.any? do |domain| match_found = email_domains.any? do |domain|
escaped = Regexp.escape(domain).gsub('\*','.*?') escaped = Regexp.escape(domain).gsub('\*', '.*?')
regexp = Regexp.new "^#{escaped}$", Regexp::IGNORECASE regexp = Regexp.new "^#{escaped}$", Regexp::IGNORECASE
email_domain = Mail::Address.new(self.email).domain email_domain = Mail::Address.new(self.email).domain
email_domain =~ regexp email_domain =~ regexp
......
...@@ -4,7 +4,7 @@ class LfsObjectUploader < CarrierWave::Uploader::Base ...@@ -4,7 +4,7 @@ class LfsObjectUploader < CarrierWave::Uploader::Base
storage :file storage :file
def store_dir def store_dir
"#{Gitlab.config.lfs.storage_path}/#{model.oid[0,2]}/#{model.oid[2,2]}" "#{Gitlab.config.lfs.storage_path}/#{model.oid[0, 2]}/#{model.oid[2, 2]}"
end end
def cache_dir def cache_dir
......
...@@ -212,7 +212,7 @@ Devise.setup do |config| ...@@ -212,7 +212,7 @@ Devise.setup do |config|
if Gitlab::LDAP::Config.enabled? if Gitlab::LDAP::Config.enabled?
Gitlab.config.ldap.servers.values.each do |server| Gitlab.config.ldap.servers.values.each do |server|
if server['allow_username_or_email_login'] if server['allow_username_or_email_login']
email_stripping_proc = ->(name) {name.gsub(/@.*\z/,'')} email_stripping_proc = ->(name) {name.gsub(/@.*\z/, '')}
else else
email_stripping_proc = ->(name) {name} email_stripping_proc = ->(name) {name}
end end
......
...@@ -13,7 +13,7 @@ Sidekiq.configure_server do |config| ...@@ -13,7 +13,7 @@ Sidekiq.configure_server do |config|
# UGLY Hack to get nested hash from settingslogic # UGLY Hack to get nested hash from settingslogic
cron_jobs = JSON.parse(Gitlab.config.cron_jobs.to_json) cron_jobs = JSON.parse(Gitlab.config.cron_jobs.to_json)
# UGLY hack: Settingslogic doesn't allow 'class' key # UGLY hack: Settingslogic doesn't allow 'class' key
cron_jobs.each { |k,v| cron_jobs[k]['class'] = cron_jobs[k].delete('job_class') } cron_jobs.each { |k, v| cron_jobs[k]['class'] = cron_jobs[k].delete('job_class') }
Sidekiq::Cron::Job.load_from_hash! cron_jobs Sidekiq::Cron::Job.load_from_hash! cron_jobs
# Database pool should be at least `sidekiq_concurrency` + 2 # Database pool should be at least `sidekiq_concurrency` + 2
......
...@@ -653,7 +653,7 @@ Rails.application.routes.draw do ...@@ -653,7 +653,7 @@ Rails.application.routes.draw do
get '/wikis/*id', to: 'wikis#show', as: 'wiki', constraints: WIKI_SLUG_ID get '/wikis/*id', to: 'wikis#show', as: 'wiki', constraints: WIKI_SLUG_ID
delete '/wikis/*id', to: 'wikis#destroy', constraints: WIKI_SLUG_ID delete '/wikis/*id', to: 'wikis#destroy', constraints: WIKI_SLUG_ID
put '/wikis/*id', to: 'wikis#update', constraints: WIKI_SLUG_ID put '/wikis/*id', to: 'wikis#update', constraints: WIKI_SLUG_ID
post '/wikis/*id/markdown_preview', to:'wikis#markdown_preview', constraints: WIKI_SLUG_ID, as: 'wiki_markdown_preview' post '/wikis/*id/markdown_preview', to: 'wikis#markdown_preview', constraints: WIKI_SLUG_ID, as: 'wiki_markdown_preview'
end end
resource :repository, only: [:show, :create] do resource :repository, only: [:show, :create] do
......
...@@ -93,7 +93,7 @@ class Spinach::Features::Groups < Spinach::FeatureSteps ...@@ -93,7 +93,7 @@ class Spinach::Features::Groups < Spinach::FeatureSteps
step 'I should see new group "Owned" avatar' do step 'I should see new group "Owned" avatar' do
expect(owned_group.avatar).to be_instance_of AvatarUploader expect(owned_group.avatar).to be_instance_of AvatarUploader
expect(owned_group.avatar.url).to eq "/uploads/group/avatar/#{Group.find_by(name:"Owned").id}/banana_sample.gif" expect(owned_group.avatar.url).to eq "/uploads/group/avatar/#{Group.find_by(name: "Owned").id}/banana_sample.gif"
end end
step 'I should see the "Remove avatar" button' do step 'I should see the "Remove avatar" button' do
......
...@@ -153,6 +153,6 @@ class Spinach::Features::ProjectForkedMergeRequests < Spinach::FeatureSteps ...@@ -153,6 +153,6 @@ class Spinach::Features::ProjectForkedMergeRequests < Spinach::FeatureSteps
# Verify a link is generated against the correct project # Verify a link is generated against the correct project
def verify_commit_link(container_div, container_project) def verify_commit_link(container_div, container_project)
# This should force a wait for the javascript to execute # This should force a wait for the javascript to execute
expect(find(:div,container_div).find(".commit_short_id")['href']).to have_content "#{container_project.path_with_namespace}/commit" expect(find(:div, container_div).find(".commit_short_id")['href']).to have_content "#{container_project.path_with_namespace}/commit"
end end
end end
...@@ -77,7 +77,7 @@ module API ...@@ -77,7 +77,7 @@ module API
member = group.group_members.find_by(user_id: params[:user_id]) member = group.group_members.find_by(user_id: params[:user_id])
if member.nil? if member.nil?
render_api_error!("404 Not Found - user_id:#{params[:user_id]} not a member of group #{group.name}",404) render_api_error!("404 Not Found - user_id:#{params[:user_id]} not a member of group #{group.name}", 404)
else else
member.destroy member.destroy
end end
......
...@@ -22,7 +22,7 @@ module Grack ...@@ -22,7 +22,7 @@ module Grack
# Need this if under RELATIVE_URL_ROOT # Need this if under RELATIVE_URL_ROOT
unless Gitlab.config.gitlab.relative_url_root.empty? unless Gitlab.config.gitlab.relative_url_root.empty?
# If website is mounted using relative_url_root need to remove it first # If website is mounted using relative_url_root need to remove it first
@env['PATH_INFO'] = @request.path.sub(Gitlab.config.gitlab.relative_url_root,'') @env['PATH_INFO'] = @request.path.sub(Gitlab.config.gitlab.relative_url_root, '')
else else
@env['PATH_INFO'] = @request.path @env['PATH_INFO'] = @request.path
end end
......
...@@ -66,7 +66,7 @@ module Gitlab ...@@ -66,7 +66,7 @@ module Gitlab
# Get the first part of the email address (before @) # Get the first part of the email address (before @)
# In addtion in removes illegal characters # In addtion in removes illegal characters
def generate_username(email) def generate_username(email)
email.match(/^[^@]*/)[0].mb_chars.normalize(:kd).gsub(/[^\x00-\x7F]/,'').to_s email.match(/^[^@]*/)[0].mb_chars.normalize(:kd).gsub(/[^\x00-\x7F]/, '').to_s
end end
def generate_temporarily_email(username) def generate_temporarily_email(username)
......
...@@ -92,7 +92,7 @@ describe 'Issues', feature: true do ...@@ -92,7 +92,7 @@ describe 'Issues', feature: true do
end end
context 'on edit form' do context 'on edit form' do
let(:issue) { create(:issue, author: @user,project: project, due_date: Date.today.at_beginning_of_month.to_s) } let(:issue) { create(:issue, author: @user, project: project, due_date: Date.today.at_beginning_of_month.to_s) }
before do before do
visit edit_namespace_project_issue_path(project.namespace, project, issue) visit edit_namespace_project_issue_path(project.namespace, project, issue)
......
...@@ -24,7 +24,7 @@ feature 'project import', feature: true, js: true do ...@@ -24,7 +24,7 @@ feature 'project import', feature: true, js: true do
visit new_project_path visit new_project_path
select2('2', from: '#project_namespace_id') select2('2', from: '#project_namespace_id')
fill_in :project_path, with:'test-project-path', visible: true fill_in :project_path, with: 'test-project-path', visible: true
click_link 'GitLab export' click_link 'GitLab export'
expect(page).to have_content('GitLab project export') expect(page).to have_content('GitLab project export')
......
require 'spec_helper' require 'spec_helper'
describe Gitlab::ImportExport::Reader, lib: true do describe Gitlab::ImportExport::Reader, lib: true do
let(:shared) { Gitlab::ImportExport::Shared.new(relative_path:'') } let(:shared) { Gitlab::ImportExport::Shared.new(relative_path: '') }
let(:test_config) { 'spec/support/import_export/import_export.yml' } let(:test_config) { 'spec/support/import_export/import_export.yml' }
let(:project_tree_hash) do let(:project_tree_hash) do
{ {
......
...@@ -122,7 +122,7 @@ describe Gitlab::OAuth::User, lib: true do ...@@ -122,7 +122,7 @@ describe Gitlab::OAuth::User, lib: true do
before do before do
allow(ldap_user).to receive(:uid) { uid } allow(ldap_user).to receive(:uid) { uid }
allow(ldap_user).to receive(:username) { uid } allow(ldap_user).to receive(:username) { uid }
allow(ldap_user).to receive(:email) { ['johndoe@example.com','john2@example.com'] } allow(ldap_user).to receive(:email) { ['johndoe@example.com', 'john2@example.com'] }
allow(ldap_user).to receive(:dn) { 'uid=user1,ou=People,dc=example' } allow(ldap_user).to receive(:dn) { 'uid=user1,ou=People,dc=example' }
allow(Gitlab::LDAP::Person).to receive(:find_by_uid).and_return(ldap_user) allow(Gitlab::LDAP::Person).to receive(:find_by_uid).and_return(ldap_user)
end end
...@@ -203,7 +203,7 @@ describe Gitlab::OAuth::User, lib: true do ...@@ -203,7 +203,7 @@ describe Gitlab::OAuth::User, lib: true do
stub_omniauth_config(auto_link_ldap_user: true) stub_omniauth_config(auto_link_ldap_user: true)
allow(ldap_user).to receive(:uid) { uid } allow(ldap_user).to receive(:uid) { uid }
allow(ldap_user).to receive(:username) { uid } allow(ldap_user).to receive(:username) { uid }
allow(ldap_user).to receive(:email) { ['johndoe@example.com','john2@example.com'] } allow(ldap_user).to receive(:email) { ['johndoe@example.com', 'john2@example.com'] }
allow(ldap_user).to receive(:dn) { 'uid=user1,ou=People,dc=example' } allow(ldap_user).to receive(:dn) { 'uid=user1,ou=People,dc=example' }
allow(oauth_user).to receive(:ldap_person).and_return(ldap_user) allow(oauth_user).to receive(:ldap_person).and_return(ldap_user)
end end
......
...@@ -217,7 +217,7 @@ describe API::API, api: true do ...@@ -217,7 +217,7 @@ describe API::API, api: true do
post api('/projects', user), project post api('/projects', user), project
project.each_pair do |k,v| project.each_pair do |k, v|
expect(json_response[k.to_s]).to eq(v) expect(json_response[k.to_s]).to eq(v)
end end
end end
...@@ -325,7 +325,7 @@ describe API::API, api: true do ...@@ -325,7 +325,7 @@ describe API::API, api: true do
post api("/projects/user/#{user.id}", admin), project post api("/projects/user/#{user.id}", admin), project
project.each_pair do |k,v| project.each_pair do |k, v|
next if k == :path next if k == :path
expect(json_response[k.to_s]).to eq(v) expect(json_response[k.to_s]).to eq(v)
end end
...@@ -805,7 +805,7 @@ describe API::API, api: true do ...@@ -805,7 +805,7 @@ describe API::API, api: true do
context 'when authenticated' do context 'when authenticated' do
it 'should return an array of projects' do it 'should return an array of projects' do
get api("/projects/search/#{query}",user) get api("/projects/search/#{query}", user)
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.size).to eq(6) expect(json_response.size).to eq(6)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment