BigW Consortium Gitlab

Commit 181cd299 by Jacopo

Adds Rubocop rule for line break after guard clause

Adds a rubocop rule (with autocorrect) to ensure line break after guard clauses.
parent f2997af4
...@@ -97,6 +97,7 @@ class ApplicationController < ActionController::Base ...@@ -97,6 +97,7 @@ class ApplicationController < ActionController::Base
# (e.g. tokens) to authenticate the user, whereas Devise sets current_user # (e.g. tokens) to authenticate the user, whereas Devise sets current_user
def auth_user def auth_user
return current_user if current_user.present? return current_user if current_user.present?
return try(:authenticated_user) return try(:authenticated_user)
end end
......
...@@ -44,6 +44,7 @@ class AutocompleteController < ApplicationController ...@@ -44,6 +44,7 @@ class AutocompleteController < ApplicationController
if @project.blank? && params[:group_id].present? if @project.blank? && params[:group_id].present?
group = Group.find(params[:group_id]) group = Group.find(params[:group_id])
return render_404 unless can?(current_user, :read_group, group) return render_404 unless can?(current_user, :read_group, group)
group group
end end
end end
...@@ -54,6 +55,7 @@ class AutocompleteController < ApplicationController ...@@ -54,6 +55,7 @@ class AutocompleteController < ApplicationController
if params[:project_id].present? if params[:project_id].present?
project = Project.find(params[:project_id]) project = Project.find(params[:project_id])
return render_404 unless can?(current_user, :read_project, project) return render_404 unless can?(current_user, :read_project, project)
project project
end end
end end
......
...@@ -4,6 +4,7 @@ class Import::GitlabProjectsController < Import::BaseController ...@@ -4,6 +4,7 @@ class Import::GitlabProjectsController < Import::BaseController
def new def new
@namespace = Namespace.find(project_params[:namespace_id]) @namespace = Namespace.find(project_params[:namespace_id])
return render_404 unless current_user.can?(:create_projects, @namespace) return render_404 unless current_user.can?(:create_projects, @namespace)
@path = project_params[:path] @path = project_params[:path]
end end
......
...@@ -12,6 +12,7 @@ class Projects::DeploymentsController < Projects::ApplicationController ...@@ -12,6 +12,7 @@ class Projects::DeploymentsController < Projects::ApplicationController
def metrics def metrics
return render_404 unless deployment.has_metrics? return render_404 unless deployment.has_metrics?
@metrics = deployment.metrics @metrics = deployment.metrics
if @metrics&.any? if @metrics&.any?
render json: @metrics, status: :ok render json: @metrics, status: :ok
......
...@@ -12,6 +12,7 @@ class Projects::GroupLinksController < Projects::ApplicationController ...@@ -12,6 +12,7 @@ class Projects::GroupLinksController < Projects::ApplicationController
if group if group
return render_404 unless can?(current_user, :read_group, group) return render_404 unless can?(current_user, :read_group, group)
Projects::GroupLinks::CreateService.new(project, current_user, group_link_create_params).execute(group) Projects::GroupLinks::CreateService.new(project, current_user, group_link_create_params).execute(group)
else else
flash[:alert] = 'Please select a group.' flash[:alert] = 'Please select a group.'
......
...@@ -171,6 +171,7 @@ class Projects::IssuesController < Projects::ApplicationController ...@@ -171,6 +171,7 @@ class Projects::IssuesController < Projects::ApplicationController
def issue def issue
return @issue if defined?(@issue) return @issue if defined?(@issue)
# The Sortable default scope causes performance issues when used with find_by # The Sortable default scope causes performance issues when used with find_by
@issuable = @noteable = @issue ||= @project.issues.where(iid: params[:id]).reorder(nil).take! @issuable = @noteable = @issue ||= @project.issues.where(iid: params[:id]).reorder(nil).take!
@note = @project.notes.new(noteable: @issuable) @note = @project.notes.new(noteable: @issuable)
......
...@@ -111,6 +111,7 @@ class Projects::LabelsController < Projects::ApplicationController ...@@ -111,6 +111,7 @@ class Projects::LabelsController < Projects::ApplicationController
begin begin
return render_404 unless promote_service.execute(@label) return render_404 unless promote_service.execute(@label)
respond_to do |format| respond_to do |format|
format.html do format.html do
redirect_to(project_labels_path(@project), redirect_to(project_labels_path(@project),
......
...@@ -54,6 +54,7 @@ class Projects::LfsStorageController < Projects::GitHttpClientController ...@@ -54,6 +54,7 @@ class Projects::LfsStorageController < Projects::GitHttpClientController
name = request.headers['X-Gitlab-Lfs-Tmp'] name = request.headers['X-Gitlab-Lfs-Tmp']
return if name.include?('/') return if name.include?('/')
return unless oid.present? && name.start_with?(oid) return unless oid.present? && name.start_with?(oid)
name name
end end
......
...@@ -76,6 +76,7 @@ class Projects::NotesController < Projects::ApplicationController ...@@ -76,6 +76,7 @@ class Projects::NotesController < Projects::ApplicationController
def authorize_create_note! def authorize_create_note!
return unless noteable.lockable? return unless noteable.lockable?
access_denied! unless can?(current_user, :create_note, noteable) access_denied! unless can?(current_user, :create_note, noteable)
end end
end end
...@@ -28,6 +28,7 @@ class Projects::WikisController < Projects::ApplicationController ...@@ -28,6 +28,7 @@ class Projects::WikisController < Projects::ApplicationController
) )
else else
return render('empty') unless can?(current_user, :create_wiki, @project) return render('empty') unless can?(current_user, :create_wiki, @project)
@page = WikiPage.new(@project_wiki) @page = WikiPage.new(@project_wiki)
@page.title = params[:id] @page.title = params[:id]
......
...@@ -269,6 +269,7 @@ class ProjectsController < Projects::ApplicationController ...@@ -269,6 +269,7 @@ class ProjectsController < Projects::ApplicationController
def render_landing_page def render_landing_page
if can?(current_user, :download_code, @project) if can?(current_user, :download_code, @project)
return render 'projects/no_repo' unless @project.repository_exists? return render 'projects/no_repo' unless @project.repository_exists?
render 'projects/empty' if @project.empty_repo? render 'projects/empty' if @project.empty_repo?
else else
if @project.wiki_enabled? if @project.wiki_enabled?
......
...@@ -18,6 +18,7 @@ class PersonalAccessTokensFinder ...@@ -18,6 +18,7 @@ class PersonalAccessTokensFinder
def by_user(tokens) def by_user(tokens)
return tokens unless @params[:user] return tokens unless @params[:user]
tokens.where(user: @params[:user]) tokens.where(user: @params[:user])
end end
......
...@@ -111,6 +111,7 @@ module DiffHelper ...@@ -111,6 +111,7 @@ module DiffHelper
def diff_file_old_blob_raw_path(diff_file) def diff_file_old_blob_raw_path(diff_file)
sha = diff_file.old_content_sha sha = diff_file.old_content_sha
return unless sha return unless sha
project_raw_path(@project, tree_join(diff_file.old_content_sha, diff_file.old_path)) project_raw_path(@project, tree_join(diff_file.old_content_sha, diff_file.old_path))
end end
......
...@@ -24,6 +24,7 @@ module EmailsHelper ...@@ -24,6 +24,7 @@ module EmailsHelper
def action_title(url) def action_title(url)
return unless url return unless url
%w(merge_requests issues commit).each do |action| %w(merge_requests issues commit).each do |action|
if url.split("/").include?(action) if url.split("/").include?(action)
return "View #{action.humanize.singularize}" return "View #{action.humanize.singularize}"
......
...@@ -53,6 +53,7 @@ module MarkupHelper ...@@ -53,6 +53,7 @@ module MarkupHelper
# text, wrapping anything found in the requested link # text, wrapping anything found in the requested link
fragment.children.each do |node| fragment.children.each do |node|
next unless node.text? next unless node.text?
node.replace(link_to(node.text, url, html_options)) node.replace(link_to(node.text, url, html_options))
end end
end end
......
...@@ -78,6 +78,7 @@ module NotificationsHelper ...@@ -78,6 +78,7 @@ module NotificationsHelper
# Create hidden field to send notification setting source to controller # Create hidden field to send notification setting source to controller
def hidden_setting_source_input(notification_setting) def hidden_setting_source_input(notification_setting)
return unless notification_setting.source_type return unless notification_setting.source_type
hidden_field_tag "#{notification_setting.source_type.downcase}_id", notification_setting.source_id hidden_field_tag "#{notification_setting.source_type.downcase}_id", notification_setting.source_id
end end
......
...@@ -88,6 +88,7 @@ module TreeHelper ...@@ -88,6 +88,7 @@ module TreeHelper
part_path = part if part_path.empty? part_path = part if part_path.empty?
next if parts.count > max_links && !parts.last(2).include?(part) next if parts.count > max_links && !parts.last(2).include?(part)
yield(part, part_path) yield(part, part_path)
end end
end end
......
...@@ -150,6 +150,7 @@ module VisibilityLevelHelper ...@@ -150,6 +150,7 @@ module VisibilityLevelHelper
def restricted_visibility_levels(show_all = false) def restricted_visibility_levels(show_all = false)
return [] if current_user.admin? && !show_all return [] if current_user.admin? && !show_all
current_application_settings.restricted_visibility_levels || [] current_application_settings.restricted_visibility_levels || []
end end
...@@ -159,6 +160,7 @@ module VisibilityLevelHelper ...@@ -159,6 +160,7 @@ module VisibilityLevelHelper
def disallowed_visibility_level?(form_model, level) def disallowed_visibility_level?(form_model, level)
return false unless form_model.respond_to?(:visibility_level_allowed?) return false unless form_model.respond_to?(:visibility_level_allowed?)
!form_model.visibility_level_allowed?(level) !form_model.visibility_level_allowed?(level)
end end
......
...@@ -317,6 +317,7 @@ module Ci ...@@ -317,6 +317,7 @@ module Ci
def execute_hooks def execute_hooks
return unless project return unless project
build_data = Gitlab::DataBuilder::Build.build(self) build_data = Gitlab::DataBuilder::Build.build(self)
project.execute_hooks(build_data.dup, :job_hooks) project.execute_hooks(build_data.dup, :job_hooks)
project.execute_services(build_data.dup, :job_hooks) project.execute_services(build_data.dup, :job_hooks)
......
...@@ -300,8 +300,10 @@ module Ci ...@@ -300,8 +300,10 @@ module Ci
def latest? def latest?
return false unless ref return false unless ref
commit = project.commit(ref) commit = project.commit(ref)
return false unless commit return false unless commit
commit.sha == sha commit.sha == sha
end end
......
...@@ -56,6 +56,7 @@ module Clusters ...@@ -56,6 +56,7 @@ module Clusters
before_transition any => [:creating] do |provider, transition| before_transition any => [:creating] do |provider, transition|
operation_id = transition.args.first operation_id = transition.args.first
raise ArgumentError.new('operation_id is required') unless operation_id.present? raise ArgumentError.new('operation_id is required') unless operation_id.present?
provider.operation_id = operation_id provider.operation_id = operation_id
end end
......
...@@ -98,6 +98,7 @@ module Awardable ...@@ -98,6 +98,7 @@ module Awardable
def create_award_emoji(name, current_user) def create_award_emoji(name, current_user)
return unless emoji_awardable? return unless emoji_awardable?
award_emoji.create(name: normalize_name(name), user: current_user) award_emoji.create(name: normalize_name(name), user: current_user)
end end
......
...@@ -65,6 +65,7 @@ class PagesDomain < ActiveRecord::Base ...@@ -65,6 +65,7 @@ class PagesDomain < ActiveRecord::Base
def expired? def expired?
return false unless x509 return false unless x509
current = Time.new current = Time.new
current < x509.not_before || x509.not_after < current current < x509.not_before || x509.not_after < current
end end
...@@ -75,6 +76,7 @@ class PagesDomain < ActiveRecord::Base ...@@ -75,6 +76,7 @@ class PagesDomain < ActiveRecord::Base
def subject def subject
return unless x509 return unless x509
x509.subject.to_s x509.subject.to_s
end end
...@@ -102,6 +104,7 @@ class PagesDomain < ActiveRecord::Base ...@@ -102,6 +104,7 @@ class PagesDomain < ActiveRecord::Base
def validate_pages_domain def validate_pages_domain
return unless domain return unless domain
if domain.downcase.ends_with?(Settings.pages.host.downcase) if domain.downcase.ends_with?(Settings.pages.host.downcase)
self.errors.add(:domain, "*.#{Settings.pages.host} is restricted") self.errors.add(:domain, "*.#{Settings.pages.host} is restricted")
end end
...@@ -109,6 +112,7 @@ class PagesDomain < ActiveRecord::Base ...@@ -109,6 +112,7 @@ class PagesDomain < ActiveRecord::Base
def x509 def x509
return unless certificate return unless certificate
@x509 ||= OpenSSL::X509::Certificate.new(certificate) @x509 ||= OpenSSL::X509::Certificate.new(certificate)
rescue OpenSSL::X509::CertificateError rescue OpenSSL::X509::CertificateError
nil nil
...@@ -116,6 +120,7 @@ class PagesDomain < ActiveRecord::Base ...@@ -116,6 +120,7 @@ class PagesDomain < ActiveRecord::Base
def pkey def pkey
return unless key return unless key
@pkey ||= OpenSSL::PKey::RSA.new(key) @pkey ||= OpenSSL::PKey::RSA.new(key)
rescue OpenSSL::PKey::PKeyError, OpenSSL::Cipher::CipherError rescue OpenSSL::PKey::PKeyError, OpenSSL::Cipher::CipherError
nil nil
......
...@@ -51,8 +51,10 @@ class HipchatService < Service ...@@ -51,8 +51,10 @@ class HipchatService < Service
def execute(data) def execute(data)
return unless supported_events.include?(data[:object_kind]) return unless supported_events.include?(data[:object_kind])
message = create_message(data) message = create_message(data)
return unless message.present? return unless message.present?
gate[room].send('GitLab', message, message_options(data)) # rubocop:disable GitlabSecurity/PublicSend gate[room].send('GitLab', message, message_options(data)) # rubocop:disable GitlabSecurity/PublicSend
end end
......
...@@ -176,6 +176,7 @@ class JiraService < IssueTrackerService ...@@ -176,6 +176,7 @@ class JiraService < IssueTrackerService
def test_settings def test_settings
return unless client_url.present? return unless client_url.present?
# Test settings by getting the project # Test settings by getting the project
jira_request { client.ServerInfo.all.attrs } jira_request { client.ServerInfo.all.attrs }
end end
......
...@@ -182,6 +182,7 @@ class KubernetesService < DeploymentService ...@@ -182,6 +182,7 @@ class KubernetesService < DeploymentService
kubeclient.get_pods(namespace: actual_namespace).as_json kubeclient.get_pods(namespace: actual_namespace).as_json
rescue KubeException => err rescue KubeException => err
raise err unless err.error_code == 404 raise err unless err.error_code == 404
[] []
end end
......
...@@ -242,6 +242,7 @@ class Repository ...@@ -242,6 +242,7 @@ class Repository
Rails.logger.error "Unable to create #{REF_KEEP_AROUND} reference for repository #{path}: #{ex}" Rails.logger.error "Unable to create #{REF_KEEP_AROUND} reference for repository #{path}: #{ex}"
rescue Rugged::OSError => ex rescue Rugged::OSError => ex
raise unless ex.message =~ /Failed to create locked file/ && ex.message =~ /File exists/ raise unless ex.message =~ /Failed to create locked file/ && ex.message =~ /File exists/
Rails.logger.error "Unable to create #{REF_KEEP_AROUND} reference for repository #{path}: #{ex}" Rails.logger.error "Unable to create #{REF_KEEP_AROUND} reference for repository #{path}: #{ex}"
end end
end end
...@@ -662,6 +663,7 @@ class Repository ...@@ -662,6 +663,7 @@ class Repository
def next_branch(name, opts = {}) def next_branch(name, opts = {})
branch_ids = self.branch_names.map do |n| branch_ids = self.branch_names.map do |n|
next 1 if n == name next 1 if n == name
result = n.match(/\A#{name}-([0-9]+)\z/) result = n.match(/\A#{name}-([0-9]+)\z/)
result[1].to_i if result result[1].to_i if result
end.compact end.compact
......
...@@ -1119,6 +1119,7 @@ class User < ActiveRecord::Base ...@@ -1119,6 +1119,7 @@ class User < ActiveRecord::Base
# override, from Devise::Validatable # override, from Devise::Validatable
def password_required? def password_required?
return false if internal? return false if internal?
super super
end end
...@@ -1136,6 +1137,7 @@ class User < ActiveRecord::Base ...@@ -1136,6 +1137,7 @@ class User < ActiveRecord::Base
# Added according to https://github.com/plataformatec/devise/blob/7df57d5081f9884849ca15e4fde179ef164a575f/README.md#activejob-integration # Added according to https://github.com/plataformatec/devise/blob/7df57d5081f9884849ca15e4fde179ef164a575f/README.md#activejob-integration
def send_devise_notification(notification, *args) def send_devise_notification(notification, *args)
return true unless can?(:receive_notifications) return true unless can?(:receive_notifications)
devise_mailer.__send__(notification, self, *args).deliver_later # rubocop:disable GitlabSecurity/PublicSend devise_mailer.__send__(notification, self, *args).deliver_later # rubocop:disable GitlabSecurity/PublicSend
end end
......
...@@ -34,6 +34,7 @@ module Ci ...@@ -34,6 +34,7 @@ module Ci
kubeclient.get_secrets.as_json kubeclient.get_secrets.as_json
rescue KubeException => err rescue KubeException => err
raise err unless err.error_code == 404 raise err unless err.error_code == 404
[] []
end end
......
...@@ -19,6 +19,7 @@ module Labels ...@@ -19,6 +19,7 @@ module Labels
# We skipped validations during creation. Let's run them now, after deleting conflicting labels # We skipped validations during creation. Let's run them now, after deleting conflicting labels
raise ActiveRecord::RecordInvalid.new(new_label) unless new_label.valid? raise ActiveRecord::RecordInvalid.new(new_label) unless new_label.valid?
new_label new_label
end end
end end
......
...@@ -28,6 +28,7 @@ module MergeRequests ...@@ -28,6 +28,7 @@ module MergeRequests
def find_target_project def find_target_project
return target_project if target_project.present? && can?(current_user, :read_project, target_project) return target_project if target_project.present? && can?(current_user, :read_project, target_project)
project.default_merge_request_target project.default_merge_request_target
end end
......
...@@ -3,6 +3,7 @@ module Projects ...@@ -3,6 +3,7 @@ module Projects
class DestroyService < BaseService class DestroyService < BaseService
def execute(group_link) def execute(group_link)
return false unless group_link return false unless group_link
group_link.destroy group_link.destroy
end end
end end
......
...@@ -208,6 +208,7 @@ class TodoService ...@@ -208,6 +208,7 @@ class TodoService
def create_todos(users, attributes) def create_todos(users, attributes)
Array(users).map do |user| Array(users).map do |user|
next if pending_todos(user, attributes).exists? next if pending_todos(user, attributes).exists?
todo = Todo.create(attributes.merge(user_id: user.id)) todo = Todo.create(attributes.merge(user_id: user.id))
user.update_todos_count_cache user.update_todos_count_cache
todo todo
......
...@@ -17,6 +17,7 @@ class CertificateKeyValidator < ActiveModel::EachValidator ...@@ -17,6 +17,7 @@ class CertificateKeyValidator < ActiveModel::EachValidator
def valid_private_key_pem?(value) def valid_private_key_pem?(value)
return false unless value return false unless value
pkey = OpenSSL::PKey::RSA.new(value) pkey = OpenSSL::PKey::RSA.new(value)
pkey.private? pkey.private?
rescue OpenSSL::PKey::PKeyError rescue OpenSSL::PKey::PKeyError
......
...@@ -17,6 +17,7 @@ class CertificateValidator < ActiveModel::EachValidator ...@@ -17,6 +17,7 @@ class CertificateValidator < ActiveModel::EachValidator
def valid_certificate_pem?(value) def valid_certificate_pem?(value)
return false unless value return false unless value
OpenSSL::X509::Certificate.new(value).present? OpenSSL::X509::Certificate.new(value).present?
rescue OpenSSL::X509::CertificateError rescue OpenSSL::X509::CertificateError
false false
......
...@@ -104,6 +104,7 @@ class IrkerWorker ...@@ -104,6 +104,7 @@ class IrkerWorker
parents = commit.parents parents = commit.parents
# Return old value if there's no new one # Return old value if there's no new one
return push_data['before'] if parents.empty? return push_data['before'] if parents.empty?
# Or return the first parent-commit # Or return the first parent-commit
parents[0].id parents[0].id
end end
......
...@@ -39,6 +39,7 @@ class StuckCiJobsWorker ...@@ -39,6 +39,7 @@ class StuckCiJobsWorker
def drop_stuck(status, timeout) def drop_stuck(status, timeout)
search(status, timeout) do |build| search(status, timeout) do |build|
return unless build.stuck? return unless build.stuck?
drop_build :stuck, build, status, timeout drop_build :stuck, build, status, timeout
end end
end end
......
---
title: Adds Rubocop rule for line break after guard clause
merge_request: 15188
author: Jacopo Beschi @jacopo-beschi
type: added
...@@ -34,6 +34,7 @@ module ActiveRecord ...@@ -34,6 +34,7 @@ module ActiveRecord
yield yielded_relation yield yielded_relation
break if ids.length < of break if ids.length < of
batch_relation = relation.where(arel_table[primary_key].gt(primary_key_offset)) batch_relation = relation.where(arel_table[primary_key].gt(primary_key_offset))
end end
end end
......
...@@ -236,6 +236,7 @@ Devise.setup do |config| ...@@ -236,6 +236,7 @@ Devise.setup do |config|
provider['args'][:on_single_sign_out] = lambda do |request| provider['args'][:on_single_sign_out] = lambda do |request|
ticket = request.params[:session_index] ticket = request.params[:session_index]
raise "Service Ticket not found." unless Gitlab::OAuth::Session.valid?(:cas3, ticket) raise "Service Ticket not found." unless Gitlab::OAuth::Session.valid?(:cas3, ticket)
Gitlab::OAuth::Session.destroy(:cas3, ticket) Gitlab::OAuth::Session.destroy(:cas3, ticket)
true true
end end
......
...@@ -3,6 +3,7 @@ if Gitlab::LDAP::Config.enabled? ...@@ -3,6 +3,7 @@ if Gitlab::LDAP::Config.enabled?
Gitlab::LDAP::Config.available_servers.each do |server| Gitlab::LDAP::Config.available_servers.each do |server|
# do not redeclare LDAP # do not redeclare LDAP
next if server['provider_name'] == 'ldap' next if server['provider_name'] == 'ldap'
const_set(server['provider_class'], Class.new(LDAP)) const_set(server['provider_class'], Class.new(LDAP))
end end
end end
......
...@@ -61,11 +61,13 @@ module ActiveRecord ...@@ -61,11 +61,13 @@ module ActiveRecord
def with_values=(values) def with_values=(values)
raise ImmutableRelation if @loaded raise ImmutableRelation if @loaded
@values[:with] = values @values[:with] = values
end end
def recursive_value=(value) def recursive_value=(value)
raise ImmutableRelation if @loaded raise ImmutableRelation if @loaded
@values[:recursive] = value @values[:recursive] = value
end end
......
...@@ -12,6 +12,7 @@ class RemoveTemporaryCiBuildsIndex < ActiveRecord::Migration ...@@ -12,6 +12,7 @@ class RemoveTemporaryCiBuildsIndex < ActiveRecord::Migration
def up def up
return unless index_exists?(:ci_builds, :id, name: 'index_for_ci_builds_retried_migration') return unless index_exists?(:ci_builds, :id, name: 'index_for_ci_builds_retried_migration')
remove_concurrent_index(:ci_builds, :id, name: "index_for_ci_builds_retried_migration") remove_concurrent_index(:ci_builds, :id, name: "index_for_ci_builds_retried_migration")
end end
......
...@@ -14,6 +14,7 @@ class CleanUploadSymlinks < ActiveRecord::Migration ...@@ -14,6 +14,7 @@ class CleanUploadSymlinks < ActiveRecord::Migration
DIRECTORIES_TO_MOVE.each do |dir| DIRECTORIES_TO_MOVE.each do |dir|
symlink_location = File.join(old_upload_dir, dir) symlink_location = File.join(old_upload_dir, dir)
next unless File.symlink?(symlink_location) next unless File.symlink?(symlink_location)
say "removing symlink: #{symlink_location}" say "removing symlink: #{symlink_location}"
FileUtils.rm(symlink_location) FileUtils.rm(symlink_location)
end end
......
...@@ -32,6 +32,7 @@ class MovePersonalSnippetsFiles < ActiveRecord::Migration ...@@ -32,6 +32,7 @@ class MovePersonalSnippetsFiles < ActiveRecord::Migration
file_name = upload['path'].split('/')[1] file_name = upload['path'].split('/')[1]
next unless move_file(upload['model_id'], secret, file_name) next unless move_file(upload['model_id'], secret, file_name)
update_markdown(upload['model_id'], secret, file_name, upload['description']) update_markdown(upload['model_id'], secret, file_name, upload['description'])
end end
end end
......
...@@ -13,6 +13,7 @@ class CleanAppearanceSymlinks < ActiveRecord::Migration ...@@ -13,6 +13,7 @@ class CleanAppearanceSymlinks < ActiveRecord::Migration
symlink_location = File.join(old_upload_dir, dir) symlink_location = File.join(old_upload_dir, dir)
return unless File.symlink?(symlink_location) return unless File.symlink?(symlink_location)
say "removing symlink: #{symlink_location}" say "removing symlink: #{symlink_location}"
FileUtils.rm(symlink_location) FileUtils.rm(symlink_location)
end end
......
...@@ -180,10 +180,12 @@ module API ...@@ -180,10 +180,12 @@ module API
if params[:path] if params[:path]
commit.raw_diffs(limits: false).each do |diff| commit.raw_diffs(limits: false).each do |diff|
next unless diff.new_path == params[:path] next unless diff.new_path == params[:path]
lines = Gitlab::Diff::Parser.new.parse(diff.diff.each_line) lines = Gitlab::Diff::Parser.new.parse(diff.diff.each_line)
lines.each do |line| lines.each do |line|
next unless line.new_pos == params[:line] && line.type == params[:line_type] next unless line.new_pos == params[:line] && line.type == params[:line_type]
break opts[:line_code] = Gitlab::Git.diff_line_code(diff.new_path, line.new_pos, line.old_pos) break opts[:line_code] = Gitlab::Git.diff_line_code(diff.new_path, line.new_pos, line.old_pos)
end end
......
...@@ -4,6 +4,7 @@ module API ...@@ -4,6 +4,7 @@ module API
class Absence < Grape::Validations::Base class Absence < Grape::Validations::Base
def validate_param!(attr_name, params) def validate_param!(attr_name, params)
return if params.respond_to?(:key?) && !params.key?(attr_name) return if params.respond_to?(:key?) && !params.key?(attr_name)
raise Grape::Exceptions::Validation, params: [@scope.full_name(attr_name)], message: message(:absence) raise Grape::Exceptions::Validation, params: [@scope.full_name(attr_name)], message: message(:absence)
end end
end end
......
...@@ -14,6 +14,7 @@ module API ...@@ -14,6 +14,7 @@ module API
def get_runner_version_from_params def get_runner_version_from_params
return unless params['info'].present? return unless params['info'].present?
attributes_for_keys(%w(name version revision platform architecture), params['info']) attributes_for_keys(%w(name version revision platform architecture), params['info'])
end end
......
...@@ -165,17 +165,20 @@ module API ...@@ -165,17 +165,20 @@ module API
def authenticate_show_runner!(runner) def authenticate_show_runner!(runner)
return if runner.is_shared || current_user.admin? return if runner.is_shared || current_user.admin?
forbidden!("No access granted") unless user_can_access_runner?(runner) forbidden!("No access granted") unless user_can_access_runner?(runner)
end end
def authenticate_update_runner!(runner) def authenticate_update_runner!(runner)
return if current_user.admin? return if current_user.admin?
forbidden!("Runner is shared") if runner.is_shared? forbidden!("Runner is shared") if runner.is_shared?
forbidden!("No access granted") unless user_can_access_runner?(runner) forbidden!("No access granted") unless user_can_access_runner?(runner)
end end
def authenticate_delete_runner!(runner) def authenticate_delete_runner!(runner)
return if current_user.admin? return if current_user.admin?
forbidden!("Runner is shared") if runner.is_shared? forbidden!("Runner is shared") if runner.is_shared?
forbidden!("Runner associated with more than one project") if runner.projects.count > 1 forbidden!("Runner associated with more than one project") if runner.projects.count > 1
forbidden!("No access granted") unless user_can_access_runner?(runner) forbidden!("No access granted") unless user_can_access_runner?(runner)
...@@ -185,6 +188,7 @@ module API ...@@ -185,6 +188,7 @@ module API
forbidden!("Runner is shared") if runner.is_shared? forbidden!("Runner is shared") if runner.is_shared?
forbidden!("Runner is locked") if runner.locked? forbidden!("Runner is locked") if runner.locked?
return if current_user.admin? return if current_user.admin?
forbidden!("No access granted") unless user_can_access_runner?(runner) forbidden!("No access granted") unless user_can_access_runner?(runner)
end end
......
...@@ -95,6 +95,7 @@ module API ...@@ -95,6 +95,7 @@ module API
put ':id' do put ':id' do
snippet = snippets_for_current_user.find_by(id: params.delete(:id)) snippet = snippets_for_current_user.find_by(id: params.delete(:id))
return not_found!('Snippet') unless snippet return not_found!('Snippet') unless snippet
authorize! :update_personal_snippet, snippet authorize! :update_personal_snippet, snippet
attrs = declared_params(include_missing: false).merge(request: request, api: true) attrs = declared_params(include_missing: false).merge(request: request, api: true)
......
...@@ -169,10 +169,12 @@ module API ...@@ -169,10 +169,12 @@ module API
if params[:path] if params[:path]
commit.raw_diffs(limits: false).each do |diff| commit.raw_diffs(limits: false).each do |diff|
next unless diff.new_path == params[:path] next unless diff.new_path == params[:path]
lines = Gitlab::Diff::Parser.new.parse(diff.diff.each_line) lines = Gitlab::Diff::Parser.new.parse(diff.diff.each_line)
lines.each do |line| lines.each do |line|
next unless line.new_pos == params[:line] && line.type == params[:line_type] next unless line.new_pos == params[:line] && line.type == params[:line_type]
break opts[:line_code] = Gitlab::Git.diff_line_code(diff.new_path, line.new_pos, line.old_pos) break opts[:line_code] = Gitlab::Git.diff_line_code(diff.new_path, line.new_pos, line.old_pos)
end end
......
...@@ -51,6 +51,7 @@ module API ...@@ -51,6 +51,7 @@ module API
helpers do helpers do
def authenticate_delete_runner!(runner) def authenticate_delete_runner!(runner)
return if current_user.admin? return if current_user.admin?
forbidden!("Runner is shared") if runner.is_shared? forbidden!("Runner is shared") if runner.is_shared?
forbidden!("Runner associated with more than one project") if runner.projects.count > 1 forbidden!("Runner associated with more than one project") if runner.projects.count > 1
forbidden!("No access granted") unless user_can_access_runner?(runner) forbidden!("No access granted") unless user_can_access_runner?(runner)
......
...@@ -91,6 +91,7 @@ module API ...@@ -91,6 +91,7 @@ module API
put ':id' do put ':id' do
snippet = snippets_for_current_user.find_by(id: params.delete(:id)) snippet = snippets_for_current_user.find_by(id: params.delete(:id))
return not_found!('Snippet') unless snippet return not_found!('Snippet') unless snippet
authorize! :update_personal_snippet, snippet authorize! :update_personal_snippet, snippet
attrs = declared_params(include_missing: false) attrs = declared_params(include_missing: false)
...@@ -113,6 +114,7 @@ module API ...@@ -113,6 +114,7 @@ module API
delete ':id' do delete ':id' do
snippet = snippets_for_current_user.find_by(id: params.delete(:id)) snippet = snippets_for_current_user.find_by(id: params.delete(:id))
return not_found!('Snippet') unless snippet return not_found!('Snippet') unless snippet
authorize! :destroy_personal_snippet, snippet authorize! :destroy_personal_snippet, snippet
snippet.destroy snippet.destroy
no_content! no_content!
......
...@@ -86,6 +86,7 @@ module Banzai ...@@ -86,6 +86,7 @@ module Banzai
def save_options def save_options
return {} unless base_context[:xhtml] return {} unless base_context[:xhtml]
{ save_with: Nokogiri::XML::Node::SaveOptions::AS_XHTML } { save_with: Nokogiri::XML::Node::SaveOptions::AS_XHTML }
end end
end end
......
...@@ -52,8 +52,10 @@ module Banzai ...@@ -52,8 +52,10 @@ module Banzai
children.each do |child| children.each do |child|
next if child.text.blank? next if child.text.blank?
node = nodes.shift node = nodes.shift
break unless node == child break unless node == child
filtered_nodes << node filtered_nodes << node
end end
end end
......
...@@ -31,6 +31,7 @@ module Banzai ...@@ -31,6 +31,7 @@ module Banzai
nodes.each do |node| nodes.each do |node|
if node.has_attribute?(group_attr) if node.has_attribute?(group_attr)
next unless can_read_group_reference?(node, user, groups) next unless can_read_group_reference?(node, user, groups)
visible << node visible << node
elsif can_read_project_reference?(node) elsif can_read_project_reference?(node)
visible << node visible << node
......
...@@ -149,6 +149,7 @@ module Banzai ...@@ -149,6 +149,7 @@ module Banzai
def self.full_cache_key(cache_key, pipeline_name) def self.full_cache_key(cache_key, pipeline_name)
return unless cache_key return unless cache_key
["banzai", *cache_key, pipeline_name || :full] ["banzai", *cache_key, pipeline_name || :full]
end end
...@@ -157,6 +158,7 @@ module Banzai ...@@ -157,6 +158,7 @@ module Banzai
# method. # method.
def self.full_cache_multi_key(cache_key, pipeline_name) def self.full_cache_multi_key(cache_key, pipeline_name)
return unless cache_key return unless cache_key
Rails.cache.__send__(:expanded_key, full_cache_key(cache_key, pipeline_name)) # rubocop:disable GitlabSecurity/PublicSend Rails.cache.__send__(:expanded_key, full_cache_key(cache_key, pipeline_name)) # rubocop:disable GitlabSecurity/PublicSend
end end
end end
......
...@@ -30,6 +30,7 @@ module DeclarativePolicy ...@@ -30,6 +30,7 @@ module DeclarativePolicy
policy_class = class_for_class(subject.class) policy_class = class_for_class(subject.class)
raise "no policy for #{subject.class.name}" if policy_class.nil? raise "no policy for #{subject.class.name}" if policy_class.nil?
policy_class policy_class
end end
...@@ -84,6 +85,7 @@ module DeclarativePolicy ...@@ -84,6 +85,7 @@ module DeclarativePolicy
while subject.respond_to?(:declarative_policy_delegate) while subject.respond_to?(:declarative_policy_delegate)
raise ArgumentError, "circular delegations" if seen.include?(subject.object_id) raise ArgumentError, "circular delegations" if seen.include?(subject.object_id)
seen << subject.object_id seen << subject.object_id
subject = subject.declarative_policy_delegate subject = subject.declarative_policy_delegate
end end
......
...@@ -276,6 +276,7 @@ module DeclarativePolicy ...@@ -276,6 +276,7 @@ module DeclarativePolicy
# boolean `false` # boolean `false`
def cache(key, &b) def cache(key, &b)
return @cache[key] if cached?(key) return @cache[key] if cached?(key)
@cache[key] = yield @cache[key] = yield
end end
...@@ -291,6 +292,7 @@ module DeclarativePolicy ...@@ -291,6 +292,7 @@ module DeclarativePolicy
@_conditions[name] ||= @_conditions[name] ||=
begin begin
raise "invalid condition #{name}" unless self.class.conditions.key?(name) raise "invalid condition #{name}" unless self.class.conditions.key?(name)
ManifestCondition.new(self.class.conditions[name], self) ManifestCondition.new(self.class.conditions[name], self)
end end
end end
......
...@@ -3,6 +3,7 @@ module DeclarativePolicy ...@@ -3,6 +3,7 @@ module DeclarativePolicy
class << self class << self
def user_key(user) def user_key(user)
return '<anonymous>' if user.nil? return '<anonymous>' if user.nil?
id_for(user) id_for(user)
end end
...@@ -15,6 +16,7 @@ module DeclarativePolicy ...@@ -15,6 +16,7 @@ module DeclarativePolicy
def subject_key(subject) def subject_key(subject)
return '<nil>' if subject.nil? return '<nil>' if subject.nil?
return subject.inspect if subject.is_a?(Symbol) return subject.inspect if subject.is_a?(Symbol)
"#{subject.class.name}:#{id_for(subject)}" "#{subject.class.name}:#{id_for(subject)}"
end end
......
...@@ -83,6 +83,7 @@ module DeclarativePolicy ...@@ -83,6 +83,7 @@ module DeclarativePolicy
def cached_pass?(context) def cached_pass?(context)
condition = context.condition(@name) condition = context.condition(@name)
return nil unless condition.cached? return nil unless condition.cached?
condition.pass? condition.pass?
end end
...@@ -109,6 +110,7 @@ module DeclarativePolicy ...@@ -109,6 +110,7 @@ module DeclarativePolicy
def delegated_context(context) def delegated_context(context)
policy = context.delegated_policies[@delegate_name] policy = context.delegated_policies[@delegate_name]
raise MissingDelegate if policy.nil? raise MissingDelegate if policy.nil?
policy policy
end end
...@@ -121,6 +123,7 @@ module DeclarativePolicy ...@@ -121,6 +123,7 @@ module DeclarativePolicy
def cached_pass?(context) def cached_pass?(context)
condition = delegated_context(context).condition(@name) condition = delegated_context(context).condition(@name)
return nil unless condition.cached? return nil unless condition.cached?
condition.pass? condition.pass?
rescue MissingDelegate rescue MissingDelegate
false false
...@@ -157,6 +160,7 @@ module DeclarativePolicy ...@@ -157,6 +160,7 @@ module DeclarativePolicy
def cached_pass?(context) def cached_pass?(context)
runner = context.runner(@ability) runner = context.runner(@ability)
return nil unless runner.cached? return nil unless runner.cached?
runner.pass? runner.pass?
end end
...@@ -258,6 +262,7 @@ module DeclarativePolicy ...@@ -258,6 +262,7 @@ module DeclarativePolicy
def score(context) def score(context)
return 0 unless cached_pass?(context).nil? return 0 unless cached_pass?(context).nil?
@rules.map { |r| r.score(context) }.inject(0, :+) @rules.map { |r| r.score(context) }.inject(0, :+)
end end
......
...@@ -43,6 +43,7 @@ module DeclarativePolicy ...@@ -43,6 +43,7 @@ module DeclarativePolicy
# used by Rule::Ability. See #steps_by_score # used by Rule::Ability. See #steps_by_score
def score def score
return 0 if cached? return 0 if cached?
steps.map(&:score).inject(0, :+) steps.map(&:score).inject(0, :+)
end end
......
...@@ -8,6 +8,7 @@ class FileSizeValidator < ActiveModel::EachValidator ...@@ -8,6 +8,7 @@ class FileSizeValidator < ActiveModel::EachValidator
def initialize(options) def initialize(options)
if range = (options.delete(:in) || options.delete(:within)) if range = (options.delete(:in) || options.delete(:within))
raise ArgumentError, ":in and :within must be a Range" unless range.is_a?(Range) raise ArgumentError, ":in and :within must be a Range" unless range.is_a?(Range)
options[:minimum], options[:maximum] = range.begin, range.end options[:minimum], options[:maximum] = range.begin, range.end
options[:maximum] -= 1 if range.exclude_end? options[:maximum] -= 1 if range.exclude_end?
end end
......
...@@ -16,6 +16,7 @@ module Gitlab ...@@ -16,6 +16,7 @@ module Gitlab
@changes ||= begin @changes ||= begin
@raw_changes.map do |change| @raw_changes.map do |change|
next if change.blank? next if change.blank?
oldrev, newrev, ref = change.strip.split(' ') oldrev, newrev, ref = change.strip.split(' ')
{ oldrev: oldrev, newrev: newrev, ref: ref } { oldrev: oldrev, newrev: newrev, ref: ref }
end.compact end.compact
......
...@@ -98,6 +98,7 @@ module Gitlab ...@@ -98,6 +98,7 @@ module Gitlab
def read_string(gz) def read_string(gz)
string_size = read_uint32(gz) string_size = read_uint32(gz)
return nil unless string_size return nil unless string_size
gz.read(string_size) gz.read(string_size)
end end
......
...@@ -43,6 +43,7 @@ module Gitlab ...@@ -43,6 +43,7 @@ module Gitlab
def parent def parent
return nil unless has_parent? return nil unless has_parent?
self.class.new(@path.to_s.chomp(basename), @entries) self.class.new(@path.to_s.chomp(basename), @entries)
end end
...@@ -64,6 +65,7 @@ module Gitlab ...@@ -64,6 +65,7 @@ module Gitlab
def directories(opts = {}) def directories(opts = {})
return [] unless directory? return [] unless directory?
dirs = children.select(&:directory?) dirs = children.select(&:directory?)
return dirs unless has_parent? && opts[:parent] return dirs unless has_parent? && opts[:parent]
...@@ -74,6 +76,7 @@ module Gitlab ...@@ -74,6 +76,7 @@ module Gitlab
def files def files
return [] unless directory? return [] unless directory?
children.select(&:file?) children.select(&:file?)
end end
......
...@@ -8,6 +8,7 @@ module Gitlab ...@@ -8,6 +8,7 @@ module Gitlab
def from_image(job) def from_image(job)
image = Gitlab::Ci::Build::Image.new(job.options[:image]) image = Gitlab::Ci::Build::Image.new(job.options[:image])
return unless image.valid? return unless image.valid?
image image
end end
......
...@@ -37,6 +37,7 @@ module Gitlab ...@@ -37,6 +37,7 @@ module Gitlab
def value def value
return { name: @config } if string? return { name: @config } if string?
return @config if hash? return @config if hash?
{} {}
end end
end end
......
...@@ -111,6 +111,7 @@ module Gitlab ...@@ -111,6 +111,7 @@ module Gitlab
def validate_string_or_regexp(value) def validate_string_or_regexp(value)
return false unless value.is_a?(String) return false unless value.is_a?(String)
return validate_regexp(value) if look_like_regexp?(value) return validate_regexp(value) if look_like_regexp?(value)
true true
end end
end end
......
...@@ -2,6 +2,7 @@ module Gitlab ...@@ -2,6 +2,7 @@ module Gitlab
class Daemon class Daemon
def self.initialize_instance(*args) def self.initialize_instance(*args)
raise "#{name} singleton instance already initialized" if @instance raise "#{name} singleton instance already initialized" if @instance
@instance = new(*args) @instance = new(*args)
Kernel.at_exit(&@instance.method(:stop)) Kernel.at_exit(&@instance.method(:stop))
@instance @instance
......
...@@ -102,6 +102,7 @@ module Gitlab ...@@ -102,6 +102,7 @@ module Gitlab
new_char = b[pos] new_char = b[pos]
break if old_char != new_char break if old_char != new_char
length += 1 length += 1
end end
......
...@@ -30,6 +30,7 @@ module Gitlab ...@@ -30,6 +30,7 @@ module Gitlab
line_new = line.match(/\+[0-9]*/)[0].to_i.abs rescue 0 line_new = line.match(/\+[0-9]*/)[0].to_i.abs rescue 0
next if line_old <= 1 && line_new <= 1 # top of file next if line_old <= 1 && line_new <= 1 # top of file
yielder << Gitlab::Diff::Line.new(full_line, type, line_obj_index, line_old, line_new) yielder << Gitlab::Diff::Line.new(full_line, type, line_obj_index, line_old, line_new)
line_obj_index += 1 line_obj_index += 1
next next
......
...@@ -125,6 +125,7 @@ module Gitlab ...@@ -125,6 +125,7 @@ module Gitlab
def find_diff_file(repository) def find_diff_file(repository)
return unless diff_refs.complete? return unless diff_refs.complete?
return unless comparison = diff_refs.compare_in(repository.project) return unless comparison = diff_refs.compare_in(repository.project)
comparison.diffs(paths: paths, expanded: true).diff_files.first comparison.diffs(paths: paths, expanded: true).diff_files.first
end end
......
...@@ -16,6 +16,7 @@ module Gitlab ...@@ -16,6 +16,7 @@ module Gitlab
noteable = sent_notification.noteable noteable = sent_notification.noteable
raise NoteableNotFoundError unless noteable raise NoteableNotFoundError unless noteable
noteable.unsubscribe(sent_notification.recipient) noteable.unsubscribe(sent_notification.recipient)
end end
......
...@@ -45,6 +45,7 @@ module Gitlab ...@@ -45,6 +45,7 @@ module Gitlab
project_name = repo(project_id).name project_name = repo(project_id).name
res = @api.command(:search, q: "project:'#{project_name}'", cols: 'ixPersonAssignedTo,ixPersonOpenedBy,ixPersonClosedBy,sStatus,sPriority,sCategory,fOpen,sTitle,sLatestTextSummary,dtOpened,dtClosed,dtResolved,dtLastUpdated,events') res = @api.command(:search, q: "project:'#{project_name}'", cols: 'ixPersonAssignedTo,ixPersonOpenedBy,ixPersonClosedBy,sStatus,sPriority,sCategory,fOpen,sTitle,sLatestTextSummary,dtOpened,dtClosed,dtResolved,dtLastUpdated,events')
return [] unless res['cases']['count'].to_i > 0 return [] unless res['cases']['count'].to_i > 0
res['cases']['case'] res['cases']['case']
end end
......
...@@ -18,6 +18,7 @@ module Gitlab ...@@ -18,6 +18,7 @@ module Gitlab
def execute def execute
return true unless repo.valid? return true unless repo.valid?
client = Gitlab::FogbugzImport::Client.new(token: fb_session[:token], uri: fb_session[:uri]) client = Gitlab::FogbugzImport::Client.new(token: fb_session[:token], uri: fb_session[:uri])
@cases = client.cases(@repo.id.to_i) @cases = client.cases(@repo.id.to_i)
...@@ -206,6 +207,7 @@ module Gitlab ...@@ -206,6 +207,7 @@ module Gitlab
def format_content(raw_content) def format_content(raw_content)
return raw_content if raw_content.nil? return raw_content if raw_content.nil?
linkify_issues(escape_for_markdown(raw_content)) linkify_issues(escape_for_markdown(raw_content))
end end
......
...@@ -102,6 +102,7 @@ module Gitlab ...@@ -102,6 +102,7 @@ module Gitlab
if path_arr.size > 1 if path_arr.size > 1
return nil unless entry[:type] == :tree return nil unless entry[:type] == :tree
path_arr.shift path_arr.shift
find_entry_by_path(repository, entry[:oid], path_arr.join('/')) find_entry_by_path(repository, entry[:oid], path_arr.join('/'))
else else
......
...@@ -1376,6 +1376,7 @@ module Gitlab ...@@ -1376,6 +1376,7 @@ module Gitlab
end end
return nil unless tmp_entry.type == :tree return nil unless tmp_entry.type == :tree
tmp_entry = tmp_entry[dir] tmp_entry = tmp_entry[dir]
end end
end end
...@@ -1496,6 +1497,7 @@ module Gitlab ...@@ -1496,6 +1497,7 @@ module Gitlab
# Ref names must start with `refs/`. # Ref names must start with `refs/`.
def rugged_ref_exists?(ref_name) def rugged_ref_exists?(ref_name)
raise ArgumentError, 'invalid refname' unless ref_name.start_with?('refs/') raise ArgumentError, 'invalid refname' unless ref_name.start_with?('refs/')
rugged.references.exist?(ref_name) rugged.references.exist?(ref_name)
rescue Rugged::ReferenceError rescue Rugged::ReferenceError
false false
...@@ -1562,6 +1564,7 @@ module Gitlab ...@@ -1562,6 +1564,7 @@ module Gitlab
Gitlab::Git::Branch.new(self, rugged_ref.name, rugged_ref.target, target_commit) Gitlab::Git::Branch.new(self, rugged_ref.name, rugged_ref.target, target_commit)
rescue Rugged::ReferenceError => e rescue Rugged::ReferenceError => e
raise InvalidRef.new("Branch #{ref} already exists") if e.to_s =~ /'refs\/heads\/#{ref}'/ raise InvalidRef.new("Branch #{ref} already exists") if e.to_s =~ /'refs\/heads\/#{ref}'/
raise InvalidRef.new("Invalid reference #{start_point}") raise InvalidRef.new("Invalid reference #{start_point}")
end end
......
...@@ -137,6 +137,7 @@ module Gitlab ...@@ -137,6 +137,7 @@ module Gitlab
enum_value = Gitaly::FindLocalBranchesRequest::SortBy.resolve(sort_by.upcase.to_sym) enum_value = Gitaly::FindLocalBranchesRequest::SortBy.resolve(sort_by.upcase.to_sym)
raise ArgumentError, "Invalid sort_by key `#{sort_by}`" unless enum_value raise ArgumentError, "Invalid sort_by key `#{sort_by}`" unless enum_value
enum_value enum_value
end end
......
...@@ -94,6 +94,7 @@ module Gitlab ...@@ -94,6 +94,7 @@ module Gitlab
page, version = wiki_page_from_iterator(response) { |message| message.end_of_page } page, version = wiki_page_from_iterator(response) { |message| message.end_of_page }
break unless page && version break unless page && version
pages << [page, version] pages << [page, version]
end end
......
...@@ -65,6 +65,7 @@ module Gitlab ...@@ -65,6 +65,7 @@ module Gitlab
y << item y << item
end end
break if items.empty? || items.size < per_page break if items.empty? || items.size < per_page
page += 1 page += 1
end end
end end
......
...@@ -12,6 +12,7 @@ module Gitlab ...@@ -12,6 +12,7 @@ module Gitlab
@client.get_namespace(name) @client.get_namespace(name)
rescue ::KubeException => ke rescue ::KubeException => ke
raise ke unless ke.error_code == 404 raise ke unless ke.error_code == 404
false false
end end
......
...@@ -62,6 +62,7 @@ module Gitlab ...@@ -62,6 +62,7 @@ module Gitlab
def user def user
return nil unless ldap_user return nil unless ldap_user
Gitlab::LDAP::User.find_by_uid_and_provider(ldap_user.dn, provider) Gitlab::LDAP::User.find_by_uid_and_provider(ldap_user.dn, provider)
end end
end end
......
...@@ -15,6 +15,7 @@ module Gitlab ...@@ -15,6 +15,7 @@ module Gitlab
def client def client
return @client if defined?(@client) return @client if defined?(@client)
unless credentials unless credentials
raise Projects::ImportService::Error, raise Projects::ImportService::Error,
"Unable to find project import data credentials for project ID: #{@project.id}" "Unable to find project import data credentials for project ID: #{@project.id}"
......
...@@ -96,6 +96,7 @@ module Gitlab ...@@ -96,6 +96,7 @@ module Gitlab
def worker_label def worker_label
return {} unless defined?(Unicorn::Worker) return {} unless defined?(Unicorn::Worker)
worker_no = ::Prometheus::Client::Support::Unicorn.worker_id worker_no = ::Prometheus::Client::Support::Unicorn.worker_id
if worker_no if worker_no
......
...@@ -7,6 +7,7 @@ module Gitlab ...@@ -7,6 +7,7 @@ module Gitlab
def sql(event) def sql(event)
return unless current_transaction return unless current_transaction
metric_sql_duration_seconds.observe(current_transaction.labels, event.duration / 1000.0) metric_sql_duration_seconds.observe(current_transaction.labels, event.duration / 1000.0)
current_transaction.increment(:sql_duration, event.duration, false) current_transaction.increment(:sql_duration, event.duration, false)
......
...@@ -66,6 +66,7 @@ module Gitlab ...@@ -66,6 +66,7 @@ module Gitlab
project_path_match = "#{path_info}/".match(PROJECT_PATH_REGEX) project_path_match = "#{path_info}/".match(PROJECT_PATH_REGEX)
return unless project_path_match return unless project_path_match
path = project_path_match[1] path = project_path_match[1]
# Go subpackages may be in the form of `namespace/project/path1/path2/../pathN`. # Go subpackages may be in the form of `namespace/project/path1/path2/../pathN`.
......
...@@ -11,6 +11,7 @@ module Gitlab ...@@ -11,6 +11,7 @@ module Gitlab
rescue ActiveRecord::StaleObjectError rescue ActiveRecord::StaleObjectError
retries -= 1 retries -= 1
raise unless retries >= 0 raise unless retries >= 0
subject.reload subject.reload
end end
end end
......
...@@ -28,6 +28,7 @@ module Gitlab ...@@ -28,6 +28,7 @@ module Gitlab
def changed? def changed?
return true unless gl_user return true unless gl_user
gl_user.changed? || gl_user.identities.any?(&:changed?) gl_user.changed? || gl_user.identities.any?(&:changed?)
end end
......
...@@ -368,6 +368,7 @@ module Gitlab ...@@ -368,6 +368,7 @@ module Gitlab
output, status = gitlab_shell_fast_execute_helper(cmd, vars) output, status = gitlab_shell_fast_execute_helper(cmd, vars)
raise Error, output unless status.zero? raise Error, output unless status.zero?
true true
end end
......
...@@ -90,6 +90,7 @@ module Gitlab ...@@ -90,6 +90,7 @@ module Gitlab
# Takes an array of integers, and returns an array of ranges covering the same integers # Takes an array of integers, and returns an array of ranges covering the same integers
def collapse_ranges(positions) def collapse_ranges(positions)
return [] if positions.empty? return [] if positions.empty?
ranges = [] ranges = []
start = prev = positions[0] start = prev = positions[0]
......
...@@ -18,6 +18,7 @@ module Gitlab ...@@ -18,6 +18,7 @@ module Gitlab
def read(path) def read(path)
blob = @repository.blob_at(@commit.id, path) if @commit blob = @repository.blob_at(@commit.id, path) if @commit
raise FileNotFoundError if blob.nil? raise FileNotFoundError if blob.nil?
blob.data blob.data
end end
......
...@@ -70,6 +70,7 @@ module Gitlab ...@@ -70,6 +70,7 @@ module Gitlab
def generate_full_url def generate_full_url
return @url unless valid_credentials? return @url unless valid_credentials?
@full_url = @url.dup @full_url = @url.dup
@full_url.password = credentials[:password] if credentials[:password].present? @full_url.password = credentials[:password] if credentials[:password].present?
......
...@@ -99,6 +99,7 @@ module Gitlab ...@@ -99,6 +99,7 @@ module Gitlab
def level_value(level) def level_value(level)
return level.to_i if level.to_i.to_s == level.to_s && string_options.key(level.to_i) return level.to_i if level.to_i.to_s == level.to_s && string_options.key(level.to_i)
string_options[level] || PRIVATE string_options[level] || PRIVATE
end end
......
...@@ -174,6 +174,7 @@ module Gitlab ...@@ -174,6 +174,7 @@ module Gitlab
@secret ||= begin @secret ||= begin
bytes = Base64.strict_decode64(File.read(secret_path).chomp) bytes = Base64.strict_decode64(File.read(secret_path).chomp)
raise "#{secret_path} does not contain #{SECRET_LENGTH} bytes" if bytes.length != SECRET_LENGTH raise "#{secret_path} does not contain #{SECRET_LENGTH} bytes" if bytes.length != SECRET_LENGTH
bytes bytes
end end
end end
......
...@@ -9,6 +9,7 @@ unless Rails.env.production? ...@@ -9,6 +9,7 @@ unless Rails.env.production?
def visit_filter(node) def visit_filter(node)
return unless node.filter_type == 'javascript' return unless node.filter_type == 'javascript'
record_lint(node, 'Inline JavaScript is discouraged (https://docs.gitlab.com/ee/development/gotchas.html#do-not-use-inline-javascript-in-views)') record_lint(node, 'Inline JavaScript is discouraged (https://docs.gitlab.com/ee/development/gotchas.html#do-not-use-inline-javascript-in-views)')
end end
end end
......
...@@ -24,6 +24,7 @@ module SystemCheck ...@@ -24,6 +24,7 @@ module SystemCheck
# @param [BaseCheck] check class # @param [BaseCheck] check class
def <<(check) def <<(check)
raise ArgumentError unless check.is_a?(Class) && check < BaseCheck raise ArgumentError unless check.is_a?(Class) && check < BaseCheck
@checks << check @checks << check
end end
......
...@@ -60,6 +60,7 @@ namespace :gitlab do ...@@ -60,6 +60,7 @@ namespace :gitlab do
.chomp('.git') .chomp('.git')
.chomp('.wiki') .chomp('.wiki')
next if Project.find_by_full_path(repo_with_namespace) next if Project.find_by_full_path(repo_with_namespace)
new_path = path + move_suffix new_path = path + move_suffix
puts path.inspect + ' -> ' + new_path.inspect puts path.inspect + ' -> ' + new_path.inspect
File.rename(path, new_path) File.rename(path, new_path)
...@@ -75,6 +76,7 @@ namespace :gitlab do ...@@ -75,6 +76,7 @@ namespace :gitlab do
User.find_each do |user| User.find_each do |user|
next unless user.ldap_user? next unless user.ldap_user?
print "#{user.name} (#{user.ldap_identity.extern_uid}) ..." print "#{user.name} (#{user.ldap_identity.extern_uid}) ..."
if Gitlab::LDAP::Access.allowed?(user) if Gitlab::LDAP::Access.allowed?(user)
puts " [OK]".color(:green) puts " [OK]".color(:green)
......
...@@ -16,6 +16,7 @@ module QA ...@@ -16,6 +16,7 @@ module QA
while Time.now - start < 240 while Time.now - start < 240
break if page.has_css?('.application', wait: 10) break if page.has_css?('.application', wait: 10)
refresh refresh
end end
end end
......
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