diff options
author | Douwe Maan <douwe@selenight.nl> | 2017-02-22 09:10:32 -0600 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2017-02-23 09:31:57 -0600 |
commit | 5c7f9d69e3db27921acf6d8259245f2b4babcc2b (patch) | |
tree | b90334ce234ddd3921e0f1780cf3bb0848adff7b /app | |
parent | 02494f7ce86fbf1276b384f45f58558c427eff63 (diff) | |
download | gitlab-ce-5c7f9d69e3db27921acf6d8259245f2b4babcc2b.tar.gz |
Fix code for cops
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/concerns/creates_commit.rb | 15 | ||||
-rw-r--r-- | app/controllers/projects/git_http_client_controller.rb | 11 | ||||
-rw-r--r-- | app/controllers/projects/merge_requests_controller.rb | 17 | ||||
-rw-r--r-- | app/controllers/sessions_controller.rb | 11 | ||||
-rw-r--r-- | app/finders/notes_finder.rb | 11 | ||||
-rw-r--r-- | app/helpers/application_helper.rb | 11 | ||||
-rw-r--r-- | app/helpers/blob_helper.rb | 21 | ||||
-rw-r--r-- | app/helpers/submodule_helper.rb | 2 | ||||
-rw-r--r-- | app/mailers/repository_check_mailer.rb | 11 | ||||
-rw-r--r-- | app/models/commit.rb | 11 | ||||
-rw-r--r-- | app/models/concerns/case_sensitivity.rb | 11 | ||||
-rw-r--r-- | app/models/concerns/sortable.rb | 11 | ||||
-rw-r--r-- | app/models/network/graph.rb | 11 | ||||
-rw-r--r-- | app/models/project.rb | 15 | ||||
-rw-r--r-- | app/models/project_services/pushover_service.rb | 15 | ||||
-rw-r--r-- | app/services/system_note_service.rb | 13 |
16 files changed, 106 insertions, 91 deletions
diff --git a/app/controllers/concerns/creates_commit.rb b/app/controllers/concerns/creates_commit.rb index a6cf2b274a2..2fe03020d2d 100644 --- a/app/controllers/concerns/creates_commit.rb +++ b/app/controllers/concerns/creates_commit.rb @@ -101,13 +101,14 @@ module CreatesCommit # TODO: We should really clean this up def set_commit_variables - @mr_source_project = if can?(current_user, :push_code, @project) - # Edit file in this project - @project - else - # Merge request from fork to this project - current_user.fork_of(@project) - end + @mr_source_project = + if can?(current_user, :push_code, @project) + # Edit file in this project + @project + else + # Merge request from fork to this project + current_user.fork_of(@project) + end # Merge request to this project @mr_target_project = @project diff --git a/app/controllers/projects/git_http_client_controller.rb b/app/controllers/projects/git_http_client_controller.rb index 0305dafe8da..9a1bf037a95 100644 --- a/app/controllers/projects/git_http_client_controller.rb +++ b/app/controllers/projects/git_http_client_controller.rb @@ -76,11 +76,12 @@ class Projects::GitHttpClientController < Projects::ApplicationController return @project if defined?(@project) project_id, _ = project_id_with_suffix - @project = if project_id.blank? - nil - else - Project.find_by_full_path("#{params[:namespace_id]}/#{project_id}") - end + @project = + if project_id.blank? + nil + else + Project.find_by_full_path("#{params[:namespace_id]}/#{project_id}") + end end # This method returns two values so that we can parse diff --git a/app/controllers/projects/merge_requests_controller.rb b/app/controllers/projects/merge_requests_controller.rb index ff77c2b5e01..5ee7972e29e 100644 --- a/app/controllers/projects/merge_requests_controller.rb +++ b/app/controllers/projects/merge_requests_controller.rb @@ -381,14 +381,15 @@ class Projects::MergeRequestsController < Projects::ApplicationController end def merge_widget_refresh - @status = if merge_request.merge_when_build_succeeds - :merge_when_build_succeeds - else - # Only MRs that can be merged end in this action - # MR can be already picked up for merge / merged already or can be waiting for worker to be picked up - # in last case it does not have any special status. Possible error is handled inside widget js function - :success - end + @status = + if merge_request.merge_when_build_succeeds + :merge_when_build_succeeds + else + # Only MRs that can be merged end in this action + # MR can be already picked up for merge / merged already or can be waiting for worker to be picked up + # in last case it does not have any special status. Possible error is handled inside widget js function + :success + end render 'merge' end diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 529a8c9b4b4..7d81c96262f 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -15,11 +15,12 @@ class SessionsController < Devise::SessionsController def new set_minimum_password_length - @ldap_servers = if Gitlab.config.ldap.enabled - Gitlab::LDAP::Config.servers - else - [] - end + @ldap_servers = + if Gitlab.config.ldap.enabled + Gitlab::LDAP::Config.servers + else + [] + end super end diff --git a/app/finders/notes_finder.rb b/app/finders/notes_finder.rb index 3279cd4a941..6630c6384f2 100644 --- a/app/finders/notes_finder.rb +++ b/app/finders/notes_finder.rb @@ -28,11 +28,12 @@ class NotesFinder private def init_collection - @notes = if @params[:target_id] - on_target(@params[:target_type], @params[:target_id]) - else - notes_of_any_type - end + @notes = + if @params[:target_id] + on_target(@params[:target_type], @params[:target_id]) + else + notes_of_any_type + end end def notes_of_any_type diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index ed4be180f04..70419eb4bde 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -69,11 +69,12 @@ module ApplicationHelper end def avatar_icon(user_or_email = nil, size = nil, scale = 2) - user = if user_or_email.is_a?(User) - user_or_email - else - User.find_by_any_email(user_or_email.try(:downcase)) - end + user = + if user_or_email.is_a?(User) + user_or_email + else + User.find_by_any_email(user_or_email.try(:downcase)) + end if user user.avatar_url(size) || default_avatar diff --git a/app/helpers/blob_helper.rb b/app/helpers/blob_helper.rb index 6cba11f1b63..7f32c1b5300 100644 --- a/app/helpers/blob_helper.rb +++ b/app/helpers/blob_helper.rb @@ -153,16 +153,17 @@ module BlobHelper # Because we are opionated we set the cache headers ourselves. response.cache_control[:public] = @project.public? - response.cache_control[:max_age] = if @ref && @commit && @ref == @commit.id - # This is a link to a commit by its commit SHA. That means that the blob - # is immutable. The only reason to invalidate the cache is if the commit - # was deleted or if the user lost access to the repository. - Blob::CACHE_TIME_IMMUTABLE - else - # A branch or tag points at this blob. That means that the expected blob - # value may change over time. - Blob::CACHE_TIME - end + response.cache_control[:max_age] = + if @ref && @commit && @ref == @commit.id + # This is a link to a commit by its commit SHA. That means that the blob + # is immutable. The only reason to invalidate the cache is if the commit + # was deleted or if the user lost access to the repository. + Blob::CACHE_TIME_IMMUTABLE + else + # A branch or tag points at this blob. That means that the expected blob + # value may change over time. + Blob::CACHE_TIME + end response.etag = @blob.id !stale diff --git a/app/helpers/submodule_helper.rb b/app/helpers/submodule_helper.rb index 97d8cde4b3d..fb95f2b565e 100644 --- a/app/helpers/submodule_helper.rb +++ b/app/helpers/submodule_helper.rb @@ -38,7 +38,7 @@ module SubmoduleHelper def self_url?(url, namespace, project) return true if url == [Gitlab.config.gitlab.url, '/', namespace, '/', - project, '.git'].join('') + project, '.git'].join('') url == gitlab_shell.url_to_repo([namespace, '/', project].join('')) end diff --git a/app/mailers/repository_check_mailer.rb b/app/mailers/repository_check_mailer.rb index 11a0c0b7700..22a9f5da646 100644 --- a/app/mailers/repository_check_mailer.rb +++ b/app/mailers/repository_check_mailer.rb @@ -1,10 +1,11 @@ class RepositoryCheckMailer < BaseMailer def notify(failed_count) - @message = if failed_count == 1 - "One project failed its last repository check" - else - "#{failed_count} projects failed their last repository check" - end + @message = + if failed_count == 1 + "One project failed its last repository check" + else + "#{failed_count} projects failed their last repository check" + end mail( to: User.admins.pluck(:email), diff --git a/app/models/commit.rb b/app/models/commit.rb index feb35bb3e92..8f6179f183e 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -122,11 +122,12 @@ class Commit def full_title return @full_title if @full_title - @full_title = if safe_message.blank? - no_commit_message - else - safe_message.split("\n", 2).first - end + @full_title = + if safe_message.blank? + no_commit_message + else + safe_message.split("\n", 2).first + end end # Returns the commits description diff --git a/app/models/concerns/case_sensitivity.rb b/app/models/concerns/case_sensitivity.rb index 2cfb6127c96..034e9f40ff0 100644 --- a/app/models/concerns/case_sensitivity.rb +++ b/app/models/concerns/case_sensitivity.rb @@ -13,11 +13,12 @@ module CaseSensitivity params.each do |key, value| column = ActiveRecord::Base.connection.quote_table_name(key) - condition = if cast_lower - "LOWER(#{column}) = LOWER(:value)" - else - "#{column} = :value" - end + condition = + if cast_lower + "LOWER(#{column}) = LOWER(:value)" + else + "#{column} = :value" + end criteria = criteria.where(condition, value: value) end diff --git a/app/models/concerns/sortable.rb b/app/models/concerns/sortable.rb index fdcb4f3ba64..b9a2d812edd 100644 --- a/app/models/concerns/sortable.rb +++ b/app/models/concerns/sortable.rb @@ -46,11 +46,12 @@ module Sortable where("label_links.target_id = #{target_column}"). reorder(nil) - query = if target_type_column - query.where("label_links.target_type = #{target_type_column}") - else - query.where(label_links: { target_type: target_type }) - end + query = + if target_type_column + query.where("label_links.target_type = #{target_type_column}") + else + query.where(label_links: { target_type: target_type }) + end query = query.where.not(title: excluded_labels) if excluded_labels.present? diff --git a/app/models/network/graph.rb b/app/models/network/graph.rb index b859d40da24..2a7fa7d0607 100644 --- a/app/models/network/graph.rb +++ b/app/models/network/graph.rb @@ -188,11 +188,12 @@ module Network end # and mark it as reserved - min_time = if parent_time.nil? - leaves.first.time - else - parent_time + 1 - end + min_time = + if parent_time.nil? + leaves.first.time + else + parent_time + 1 + end max_time = leaves.last.time leaves.last.parents(@map).each do |parent| diff --git a/app/models/project.rb b/app/models/project.rb index a0bc82af7d5..e75ba3abb98 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -453,13 +453,14 @@ class Project < ActiveRecord::Base end def add_import_job - job_id = if forked? - RepositoryForkWorker.perform_async(id, forked_from_project.repository_storage_path, - forked_from_project.path_with_namespace, - self.namespace.full_path) - else - RepositoryImportWorker.perform_async(self.id) - end + job_id = + if forked? + RepositoryForkWorker.perform_async(id, forked_from_project.repository_storage_path, + forked_from_project.path_with_namespace, + self.namespace.full_path) + else + RepositoryImportWorker.perform_async(self.id) + end if job_id Rails.logger.info "Import job started for #{path_with_namespace} with job ID #{job_id}" diff --git a/app/models/project_services/pushover_service.rb b/app/models/project_services/pushover_service.rb index cd185f6e120..f4106048345 100644 --- a/app/models/project_services/pushover_service.rb +++ b/app/models/project_services/pushover_service.rb @@ -72,13 +72,14 @@ class PushoverService < Service before = data[:before] after = data[:after] - message = if Gitlab::Git.blank_ref?(before) - "#{data[:user_name]} pushed new branch \"#{ref}\"." - elsif Gitlab::Git.blank_ref?(after) - "#{data[:user_name]} deleted branch \"#{ref}\"." - else - "#{data[:user_name]} push to branch \"#{ref}\"." - end + message = + if Gitlab::Git.blank_ref?(before) + "#{data[:user_name]} pushed new branch \"#{ref}\"." + elsif Gitlab::Git.blank_ref?(after) + "#{data[:user_name]} deleted branch \"#{ref}\"." + else + "#{data[:user_name]} push to branch \"#{ref}\"." + end if data[:total_commits_count] > 0 message << "\nTotal commits count: #{data[:total_commits_count]}" diff --git a/app/services/system_note_service.rb b/app/services/system_note_service.rb index 3e362bb2ca9..5cb4401d69d 100644 --- a/app/services/system_note_service.rb +++ b/app/services/system_note_service.rb @@ -408,12 +408,13 @@ module SystemNoteService # Initial scope should be system notes of this noteable type notes = Note.system.where(noteable_type: noteable.class) - notes = if noteable.is_a?(Commit) - # Commits have non-integer IDs, so they're stored in `commit_id` - notes.where(commit_id: noteable.id) - else - notes.where(noteable_id: noteable.id) - end + notes = + if noteable.is_a?(Commit) + # Commits have non-integer IDs, so they're stored in `commit_id` + notes.where(commit_id: noteable.id) + else + notes.where(noteable_id: noteable.id) + end notes_for_mentioner(mentioner, noteable, notes).exists? end |