Skip to content

Commit

Permalink
Enable the Layout/SpaceBeforeBlockBraces cop
Browse files Browse the repository at this point in the history
Signed-off-by: Rémy Coutable <remy@rymai.me>
  • Loading branch information
rymai committed Aug 9, 2017
1 parent 932a6e6 commit c946ee1
Show file tree
Hide file tree
Showing 81 changed files with 166 additions and 166 deletions.
7 changes: 7 additions & 0 deletions .rubocop.yml
Expand Up @@ -207,6 +207,13 @@ Layout/SpaceAroundKeyword:
Layout/SpaceAroundOperators:
Enabled: true

# Checks that block braces have or don't have a space before the opening
# brace depending on configuration.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: space, no_space
Layout/SpaceBeforeBlockBraces:
Enabled: true

# No spaces before commas.
Layout/SpaceBeforeComma:
Enabled: true
Expand Down
7 changes: 0 additions & 7 deletions .rubocop_todo.yml
Expand Up @@ -26,13 +26,6 @@ Layout/IndentArray:
Layout/IndentHash:
Enabled: false

# Offense count: 174
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: space, no_space
Layout/SpaceBeforeBlockBraces:
Enabled: false

# Offense count: 8
# Cop supports --auto-correct.
# Configuration parameters: AllowForAlignment.
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Expand Up @@ -117,7 +117,7 @@ def log_exception(exception)
Raven.capture_exception(exception) if sentry_enabled?

application_trace = ActionDispatch::ExceptionWrapper.new(env, exception).application_trace
application_trace.map!{ |t| " #{t}\n" }
application_trace.map! { |t| " #{t}\n" }
logger.error "\n#{exception.class.name} (#{exception.message}):\n#{application_trace.join}"
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/import/gitlab_controller.rb
Expand Up @@ -15,7 +15,7 @@ def status
@already_added_projects = current_user.created_projects.where(import_type: "gitlab")
already_added_projects_names = @already_added_projects.pluck(:import_source)

@repos = @repos.to_a.reject{ |repo| already_added_projects_names.include? repo["path_with_namespace"] }
@repos = @repos.to_a.reject { |repo| already_added_projects_names.include? repo["path_with_namespace"] }
end

def jobs
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/graph_helper.rb
Expand Up @@ -3,7 +3,7 @@ def get_refs(repo, commit)
refs = ""
# Commit::ref_names already strips the refs/XXX from important refs (e.g. refs/heads/XXX)
# so anything leftover is internally used by GitLab
commit_refs = commit.ref_names(repo).reject{ |name| name.starts_with?('refs/') }
commit_refs = commit.ref_names(repo).reject { |name| name.starts_with?('refs/') }
refs << commit_refs.join(' ')

# append note count
Expand Down
4 changes: 2 additions & 2 deletions app/helpers/issuables_helper.rb
Expand Up @@ -151,7 +151,7 @@ def issuable_todo(issuable)
end

def issuable_labels_tooltip(labels, limit: 5)
first, last = labels.partition.with_index{ |_, i| i < limit }
first, last = labels.partition.with_index { |_, i| i < limit }

label_names = first.collect(&:name)
label_names << "and #{last.size} more" unless last.empty?
Expand Down Expand Up @@ -329,7 +329,7 @@ def issue_template_names
end

def selected_template(issuable)
params[:issuable_template] if issuable_templates(issuable).any?{ |template| template[:name] == params[:issuable_template] }
params[:issuable_template] if issuable_templates(issuable).any? { |template| template[:name] == params[:issuable_template] }
end

def issuable_todo_button_data(issuable, todo, is_collapsed)
Expand Down
2 changes: 1 addition & 1 deletion app/models/network/graph.rb
Expand Up @@ -206,7 +206,7 @@ def place_chain(commit, parent_time = nil)

# Visit branching chains
leaves.each do |l|
parents = l.parents(@map).select{|p| p.space.zero?}
parents = l.parents(@map).select {|p| p.space.zero?}
parents.each do |p|
place_chain(p, l.time)
end
Expand Down
20 changes: 10 additions & 10 deletions app/models/note.rb
Expand Up @@ -77,20 +77,20 @@ class Note < ActiveRecord::Base

# Scopes
scope :for_commit_id, ->(commit_id) { where(noteable_type: "Commit", commit_id: commit_id) }
scope :system, ->{ where(system: true) }
scope :user, ->{ where(system: false) }
scope :common, ->{ where(noteable_type: ["", nil]) }
scope :fresh, ->{ order(created_at: :asc, id: :asc) }
scope :updated_after, ->(time){ where('updated_at > ?', time) }
scope :inc_author_project, ->{ includes(:project, :author) }
scope :inc_author, ->{ includes(:author) }
scope :system, -> { where(system: true) }
scope :user, -> { where(system: false) }
scope :common, -> { where(noteable_type: ["", nil]) }
scope :fresh, -> { order(created_at: :asc, id: :asc) }
scope :updated_after, ->(time) { where('updated_at > ?', time) }
scope :inc_author_project, -> { includes(:project, :author) }
scope :inc_author, -> { includes(:author) }
scope :inc_relations_for_view, -> do
includes(:project, :author, :updated_by, :resolved_by, :award_emoji, :system_note_metadata)
end

scope :diff_notes, ->{ where(type: %w(LegacyDiffNote DiffNote)) }
scope :new_diff_notes, ->{ where(type: 'DiffNote') }
scope :non_diff_notes, ->{ where(type: ['Note', 'DiscussionNote', nil]) }
scope :diff_notes, -> { where(type: %w(LegacyDiffNote DiffNote)) }
scope :new_diff_notes, -> { where(type: 'DiffNote') }
scope :non_diff_notes, -> { where(type: ['Note', 'DiscussionNote', nil]) }

scope :with_associations, -> do
# FYI noteable cannot be loaded for LegacyDiffNote for commits
Expand Down
2 changes: 1 addition & 1 deletion config/initializers/1_settings.rb
Expand Up @@ -71,7 +71,7 @@ def verify_constant_array(modul, current, default)

# check that `current` (string or integer) is a contant in `modul`.
def verify_constant(modul, current, default)
constant = modul.constants.find{ |name| modul.const_get(name) == current }
constant = modul.constants.find { |name| modul.const_get(name) == current }
value = constant.nil? ? default : modul.const_get(constant)
if current.is_a? String
value = modul.const_get(current.upcase) rescue default
Expand Down
2 changes: 1 addition & 1 deletion db/migrate/20161017125927_add_unique_index_to_labels.rb
Expand Up @@ -10,7 +10,7 @@ class AddUniqueIndexToLabels < ActiveRecord::Migration
def up
select_all('SELECT title, project_id, COUNT(id) as cnt FROM labels GROUP BY project_id, title HAVING COUNT(id) > 1').each do |label|
label_title = quote_string(label['title'])
duplicated_ids = select_all("SELECT id FROM labels WHERE project_id = #{label['project_id']} AND title = '#{label_title}' ORDER BY id ASC").map{ |label| label['id'] }
duplicated_ids = select_all("SELECT id FROM labels WHERE project_id = #{label['project_id']} AND title = '#{label_title}' ORDER BY id ASC").map { |label| label['id'] }
label_id = duplicated_ids.first
duplicated_ids.delete(label_id)

Expand Down
Expand Up @@ -30,7 +30,7 @@ def down
private

def pending_delete_batch
connection.exec_query(find_batch).map{ |row| row['id'].to_i }
connection.exec_query(find_batch).map { |row| row['id'].to_i }
end

BATCH_SIZE = 5000
Expand Down
2 changes: 1 addition & 1 deletion lib/api/entities.rb
Expand Up @@ -132,7 +132,7 @@ class Project < BasicProjectDetails
expose :lfs_enabled?, as: :lfs_enabled
expose :creator_id
expose :namespace, using: 'API::Entities::Namespace'
expose :forked_from_project, using: Entities::BasicProjectDetails, if: lambda{ |project, options| project.forked? }
expose :forked_from_project, using: Entities::BasicProjectDetails, if: lambda { |project, options| project.forked? }
expose :import_status
expose :import_error, if: lambda { |_project, options| options[:user_can_admin_project] }
expose :avatar_url do |user, options|
Expand Down
2 changes: 1 addition & 1 deletion lib/api/v3/entities.rb
Expand Up @@ -68,7 +68,7 @@ class Project < Grape::Entity
expose :lfs_enabled?, as: :lfs_enabled
expose :creator_id
expose :namespace, using: 'API::Entities::Namespace'
expose :forked_from_project, using: ::API::Entities::BasicProjectDetails, if: lambda{ |project, options| project.forked? }
expose :forked_from_project, using: ::API::Entities::BasicProjectDetails, if: lambda { |project, options| project.forked? }
expose :avatar_url do |user, options|
user.avatar_url(only_path: false)
end
Expand Down
4 changes: 2 additions & 2 deletions lib/backup/manager.rb
Expand Up @@ -198,11 +198,11 @@ def backup_contents
end

def archives_to_backup
ARCHIVES_TO_BACKUP.map{ |name| (name + ".tar.gz") unless skipped?(name) }.compact
ARCHIVES_TO_BACKUP.map { |name| (name + ".tar.gz") unless skipped?(name) }.compact
end

def folders_to_backup
FOLDERS_TO_BACKUP.reject{ |name| skipped?(name) }
FOLDERS_TO_BACKUP.reject { |name| skipped?(name) }
end

def disabled_features
Expand Down
2 changes: 1 addition & 1 deletion lib/gitlab/gitlab_import/client.rb
Expand Up @@ -71,7 +71,7 @@ def lazy_page_iterator(per_page)
end

def config
Gitlab.config.omniauth.providers.find{|provider| provider.name == "gitlab"}
Gitlab.config.omniauth.providers.find {|provider| provider.name == "gitlab"}
end

def gitlab_options
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/admin/users_controller_spec.rb
Expand Up @@ -127,7 +127,7 @@ def go

describe 'POST create' do
it 'creates the user' do
expect{ post :create, user: attributes_for(:user) }.to change{ User.count }.by(1)
expect { post :create, user: attributes_for(:user) }.to change { User.count }.by(1)
end

it 'shows only one error message for an invalid email' do
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/invites_controller_spec.rb
Expand Up @@ -24,7 +24,7 @@
describe 'GET #decline' do
it 'declines user' do
get :decline, id: token
expect{member.reload}.to raise_error ActiveRecord::RecordNotFound
expect {member.reload}.to raise_error ActiveRecord::RecordNotFound

expect(response).to have_http_status(302)
expect(flash[:notice]).to include 'You have declined the invitation to join'
Expand Down
6 changes: 3 additions & 3 deletions spec/controllers/projects/issues_controller_spec.rb
Expand Up @@ -292,13 +292,13 @@ def update_spam_issue

it 'rejects an issue recognized as a spam' do
expect(Gitlab::Recaptcha).to receive(:load_configurations!).and_return(true)
expect { update_spam_issue }.not_to change{ issue.reload.title }
expect { update_spam_issue }.not_to change { issue.reload.title }
end

it 'rejects an issue recognized as a spam when recaptcha disabled' do
stub_application_setting(recaptcha_enabled: false)

expect { update_spam_issue }.not_to change{ issue.reload.title }
expect { update_spam_issue }.not_to change { issue.reload.title }
end

it 'creates a spam log' do
Expand Down Expand Up @@ -358,7 +358,7 @@ def update_verified_issue
end

it 'accepts an issue after recaptcha is verified' do
expect{ update_verified_issue }.to change{ issue.reload.title }.to(spammy_title)
expect { update_verified_issue }.to change { issue.reload.title }.to(spammy_title)
end

it 'marks spam log as recaptcha_verified' do
Expand Down
4 changes: 2 additions & 2 deletions spec/controllers/projects/todos_controller_spec.rb
Expand Up @@ -67,7 +67,7 @@ def go
end

it "doesn't create todo" do
expect{ go }.not_to change { user.todos.count }
expect { go }.not_to change { user.todos.count }
expect(response).to have_http_status(404)
end
end
Expand Down Expand Up @@ -135,7 +135,7 @@ def go
end

it "doesn't create todo" do
expect{ go }.not_to change { user.todos.count }
expect { go }.not_to change { user.todos.count }
expect(response).to have_http_status(404)
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/registrations_controller_spec.rb
Expand Up @@ -15,7 +15,7 @@
it 'signs the user in' do
allow_any_instance_of(ApplicationSetting).to receive(:send_user_confirmation_email).and_return(false)

expect { post(:create, user_params) }.not_to change{ ActionMailer::Base.deliveries.size }
expect { post(:create, user_params) }.not_to change { ActionMailer::Base.deliveries.size }
expect(subject.current_user).not_to be_nil
end
end
Expand Down
6 changes: 3 additions & 3 deletions spec/controllers/snippets/notes_controller_spec.rb
Expand Up @@ -138,7 +138,7 @@
end

it "deletes the note" do
expect{ delete :destroy, request_params }.to change{ Note.count }.from(1).to(0)
expect { delete :destroy, request_params }.to change { Note.count }.from(1).to(0)
end

context 'system note' do
Expand All @@ -147,7 +147,7 @@
end

it "does not delete the note" do
expect{ delete :destroy, request_params }.not_to change{ Note.count }
expect { delete :destroy, request_params }.not_to change { Note.count }
end
end
end
Expand All @@ -166,7 +166,7 @@
end

it "does not update the note" do
expect{ delete :destroy, request_params }.not_to change{ Note.count }
expect { delete :destroy, request_params }.not_to change { Note.count }
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/features/password_reset_spec.rb
Expand Up @@ -16,7 +16,7 @@
user.send_reset_password_instructions
user.update_attribute(:reset_password_sent_at, 5.minutes.ago)

expect{ forgot_password(user) }.to change{ user.reset_password_sent_at }
expect { forgot_password(user) }.to change { user.reset_password_sent_at }
expect(page).to have_content(I18n.t('devise.passwords.send_paranoid_instructions'))
expect(current_path).to eq new_user_session_path
end
Expand All @@ -27,7 +27,7 @@
# Reload because PG handles datetime less precisely than Ruby/Rails
user.reload

expect{ forgot_password(user) }.not_to change{ user.reset_password_sent_at }
expect { forgot_password(user) }.not_to change { user.reset_password_sent_at }
expect(page).to have_content(I18n.t('devise.passwords.send_paranoid_instructions'))
expect(current_path).to eq new_user_session_path
end
Expand Down
2 changes: 1 addition & 1 deletion spec/features/users_spec.rb
Expand Up @@ -104,7 +104,7 @@
end

def errors_on_page(page)
page.find('#error_explanation').find('ul').all('li').map{ |item| item.text }.join("\n")
page.find('#error_explanation').find('ul').all('li').map { |item| item.text }.join("\n")
end

def number_of_errors_on_page(page)
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/bitbucket/paginator_spec.rb
Expand Up @@ -15,7 +15,7 @@
expect(paginator.items).to match(['item_2'])

allow(paginator).to receive(:fetch_next_page).and_return(nil)
expect{ paginator.items }.to raise_error(StopIteration)
expect { paginator.items }.to raise_error(StopIteration)
end
end
end
4 changes: 2 additions & 2 deletions spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
Expand Up @@ -1323,11 +1323,11 @@ module Ci

describe "Error handling" do
it "fails to parse YAML" do
expect{GitlabCiYamlProcessor.new("invalid: yaml: test")}.to raise_error(Psych::SyntaxError)
expect {GitlabCiYamlProcessor.new("invalid: yaml: test")}.to raise_error(Psych::SyntaxError)
end

it "indicates that object is invalid" do
expect{GitlabCiYamlProcessor.new("invalid_yaml")}.to raise_error(GitlabCiYamlProcessor::ValidationError)
expect {GitlabCiYamlProcessor.new("invalid_yaml")}.to raise_error(GitlabCiYamlProcessor::ValidationError)
end

it "returns errors if tags parameter is invalid" do
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/extracts_path_spec.rb
Expand Up @@ -56,7 +56,7 @@

context 'subclass overrides get_id' do
it 'uses ref returned by get_id' do
allow_any_instance_of(self.class).to receive(:get_id){ '38008cb17ce1466d8fec2dfa6f6ab8dcfe5cf49e' }
allow_any_instance_of(self.class).to receive(:get_id) { '38008cb17ce1466d8fec2dfa6f6ab8dcfe5cf49e' }

assign_ref_vars

Expand Down
2 changes: 1 addition & 1 deletion spec/lib/gitlab/bitbucket_import/project_creator_spec.rb
Expand Up @@ -15,7 +15,7 @@
has_wiki?: false)
end

let(:namespace){ create(:group, owner: user) }
let(:namespace) { create(:group, owner: user) }
let(:token) { "asdasd12345" }
let(:secret) { "sekrettt" }
let(:access_params) { { bitbucket_access_token: token, bitbucket_access_token_secret: secret } }
Expand Down
4 changes: 2 additions & 2 deletions spec/lib/gitlab/git/repository_spec.rb
Expand Up @@ -422,11 +422,11 @@ def submodule_url(path)

it "should fail if we create an existing branch" do
@repo.create_branch('duplicated_branch', 'master')
expect{@repo.create_branch('duplicated_branch', 'master')}.to raise_error("Branch duplicated_branch already exists")
expect {@repo.create_branch('duplicated_branch', 'master')}.to raise_error("Branch duplicated_branch already exists")
end

it "should fail if we create a branch from a non existing ref" do
expect{@repo.create_branch('branch_based_in_wrong_ref', 'master_2_the_revenge')}.to raise_error("Invalid reference master_2_the_revenge")
expect {@repo.create_branch('branch_based_in_wrong_ref', 'master_2_the_revenge')}.to raise_error("Invalid reference master_2_the_revenge")
end

after(:all) do
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/gitlab/gitlab_import/project_creator_spec.rb
Expand Up @@ -12,7 +12,7 @@
owner: { name: "john" }
}.with_indifferent_access
end
let(:namespace){ create(:group, owner: user) }
let(:namespace) { create(:group, owner: user) }
let(:token) { "asdffg" }
let(:access_params) { { gitlab_access_token: token } }

Expand Down
2 changes: 1 addition & 1 deletion spec/lib/gitlab/google_code_import/project_creator_spec.rb
Expand Up @@ -9,7 +9,7 @@
"repositoryUrls" => ["https://vim.googlecode.com/git/"]
)
end
let(:namespace){ create(:group, owner: user) }
let(:namespace) { create(:group, owner: user) }

before do
namespace.add_owner(user)
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/gitlab/import_export/attribute_cleaner_spec.rb
@@ -1,7 +1,7 @@
require 'spec_helper'

describe Gitlab::ImportExport::AttributeCleaner do
let(:relation_class){ double('relation_class').as_null_object }
let(:relation_class) { double('relation_class').as_null_object }
let(:unsafe_hash) do
{
'id' => 101,
Expand Down

0 comments on commit c946ee1

Please sign in to comment.