diff options
Diffstat (limited to 'app')
76 files changed, 101 insertions, 105 deletions
diff --git a/app/controllers/admin/deploy_keys_controller.rb b/app/controllers/admin/deploy_keys_controller.rb index b0c4c31cffc..5c2025c1988 100644 --- a/app/controllers/admin/deploy_keys_controller.rb +++ b/app/controllers/admin/deploy_keys_controller.rb @@ -22,7 +22,7 @@ class Admin::DeployKeysController < Admin::ApplicationController end def update - if deploy_key.update_attributes(update_params) + if deploy_key.update(update_params) flash[:notice] = 'Deploy key was successfully updated.' redirect_to admin_deploy_keys_path else @@ -34,7 +34,7 @@ class Admin::DeployKeysController < Admin::ApplicationController deploy_key.destroy respond_to do |format| - format.html { redirect_to admin_deploy_keys_path, status: 302 } + format.html { redirect_to admin_deploy_keys_path, status: :found } format.json { head :ok } end end diff --git a/app/controllers/admin/groups_controller.rb b/app/controllers/admin/groups_controller.rb index 96b7bc65ac9..d7a5b745d3f 100644 --- a/app/controllers/admin/groups_controller.rb +++ b/app/controllers/admin/groups_controller.rb @@ -39,7 +39,7 @@ class Admin::GroupsController < Admin::ApplicationController end def update - if @group.update_attributes(group_params) + if @group.update(group_params) redirect_to [:admin, @group], notice: 'Group was successfully updated.' else render "edit" diff --git a/app/controllers/admin/hooks_controller.rb b/app/controllers/admin/hooks_controller.rb index 6944857bd33..a98c355c7ba 100644 --- a/app/controllers/admin/hooks_controller.rb +++ b/app/controllers/admin/hooks_controller.rb @@ -23,7 +23,7 @@ class Admin::HooksController < Admin::ApplicationController end def update - if hook.update_attributes(hook_params) + if hook.update(hook_params) flash[:notice] = 'System hook was successfully updated.' redirect_to admin_hooks_path else @@ -34,7 +34,7 @@ class Admin::HooksController < Admin::ApplicationController def destroy hook.destroy - redirect_to admin_hooks_path, status: 302 + redirect_to admin_hooks_path, status: :found end def test diff --git a/app/controllers/admin/identities_controller.rb b/app/controllers/admin/identities_controller.rb index 43b4e3a2cc3..ceb45865804 100644 --- a/app/controllers/admin/identities_controller.rb +++ b/app/controllers/admin/identities_controller.rb @@ -25,7 +25,7 @@ class Admin::IdentitiesController < Admin::ApplicationController end def update - if @identity.update_attributes(identity_params) + if @identity.update(identity_params) RepairLdapBlockedUserService.new(@user).execute redirect_to admin_user_identities_path(@user), notice: 'User identity was successfully updated.' else diff --git a/app/controllers/admin/impersonations_controller.rb b/app/controllers/admin/impersonations_controller.rb index 39dbf85f6c0..d2f947d2c66 100644 --- a/app/controllers/admin/impersonations_controller.rb +++ b/app/controllers/admin/impersonations_controller.rb @@ -11,7 +11,7 @@ class Admin::ImpersonationsController < Admin::ApplicationController session[:impersonator_id] = nil - redirect_to admin_user_path(original_user), status: 302 + redirect_to admin_user_path(original_user), status: :found end private diff --git a/app/controllers/admin/jobs_controller.rb b/app/controllers/admin/jobs_controller.rb index ae7a7f6279c..ac1ae0f16b3 100644 --- a/app/controllers/admin/jobs_controller.rb +++ b/app/controllers/admin/jobs_controller.rb @@ -20,6 +20,6 @@ class Admin::JobsController < Admin::ApplicationController def cancel_all Ci::Build.running_or_pending.each(&:cancel) - redirect_to admin_jobs_path, status: 303 + redirect_to admin_jobs_path, status: :see_other end end diff --git a/app/controllers/admin/runner_projects_controller.rb b/app/controllers/admin/runner_projects_controller.rb index 7aba77d8129..51d5799cd89 100644 --- a/app/controllers/admin/runner_projects_controller.rb +++ b/app/controllers/admin/runner_projects_controller.rb @@ -16,7 +16,7 @@ class Admin::RunnerProjectsController < Admin::ApplicationController runner = rp.runner rp.destroy - redirect_to admin_runner_path(runner), status: 302 + redirect_to admin_runner_path(runner), status: :found end private diff --git a/app/controllers/admin/runners_controller.rb b/app/controllers/admin/runners_controller.rb index 4b01904f2a1..6c76c55a9d4 100644 --- a/app/controllers/admin/runners_controller.rb +++ b/app/controllers/admin/runners_controller.rb @@ -28,7 +28,7 @@ class Admin::RunnersController < Admin::ApplicationController def destroy @runner.destroy - redirect_to admin_runners_path, status: 302 + redirect_to admin_runners_path, status: :found end def resume diff --git a/app/controllers/admin/services_controller.rb b/app/controllers/admin/services_controller.rb index a7025b62ad7..e70aa549140 100644 --- a/app/controllers/admin/services_controller.rb +++ b/app/controllers/admin/services_controller.rb @@ -16,7 +16,7 @@ class Admin::ServicesController < Admin::ApplicationController end def update - if service.update_attributes(service_params[:service]) + if service.update(service_params[:service]) PropagateServiceTemplateWorker.perform_async(service.id) if service.active? redirect_to admin_application_settings_services_path, diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index 653f3dfffc4..a51a8c3ed4a 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -163,7 +163,7 @@ class Admin::UsersController < Admin::ApplicationController format.json { head :ok } else format.html { redirect_back_or_admin_user(alert: 'There was an error removing the e-mail.') } - format.json { render json: 'There was an error removing the e-mail.', status: 400 } + format.json { render json: 'There was an error removing the e-mail.', status: :bad_request } end end end diff --git a/app/controllers/concerns/issuable_actions.rb b/app/controllers/concerns/issuable_actions.rb index ba510968684..37e03d70b6f 100644 --- a/app/controllers/concerns/issuable_actions.rb +++ b/app/controllers/concerns/issuable_actions.rb @@ -127,7 +127,7 @@ module IssuableActions errors: [ "Someone edited this #{issuable.human_class_name} at the same time you did. Please refresh your browser and make sure your changes will not unintentionally remove theirs." ] - }, status: 409 + }, status: :conflict end end end diff --git a/app/controllers/concerns/lfs_request.rb b/app/controllers/concerns/lfs_request.rb index 5e4e8a87153..79ee5b2f91e 100644 --- a/app/controllers/concerns/lfs_request.rb +++ b/app/controllers/concerns/lfs_request.rb @@ -27,7 +27,7 @@ module LfsRequest message: 'Git LFS is not enabled on this GitLab server, contact your admin.', documentation_url: help_url }, - status: 501 + status: :not_implemented ) end diff --git a/app/controllers/groups/avatars_controller.rb b/app/controllers/groups/avatars_controller.rb index cc5ba5878f8..35a61b359c8 100644 --- a/app/controllers/groups/avatars_controller.rb +++ b/app/controllers/groups/avatars_controller.rb @@ -7,6 +7,6 @@ class Groups::AvatarsController < Groups::ApplicationController @group.remove_avatar! @group.save - redirect_to edit_group_path(@group), status: 302 + redirect_to edit_group_path(@group), status: :found end end diff --git a/app/controllers/groups/runners_controller.rb b/app/controllers/groups/runners_controller.rb index 78992ec7f46..1036b4e6ed3 100644 --- a/app/controllers/groups/runners_controller.rb +++ b/app/controllers/groups/runners_controller.rb @@ -23,7 +23,7 @@ class Groups::RunnersController < Groups::ApplicationController def destroy @runner.destroy - redirect_to group_settings_ci_cd_path(@group, anchor: 'runners-settings'), status: 302 + redirect_to group_settings_ci_cd_path(@group, anchor: 'runners-settings'), status: :found end def resume diff --git a/app/controllers/jwt_controller.rb b/app/controllers/jwt_controller.rb index 67057b5b126..3cb9e46b548 100644 --- a/app/controllers/jwt_controller.rb +++ b/app/controllers/jwt_controller.rb @@ -41,7 +41,7 @@ class JwtController < ApplicationController "You must use a personal access token with 'api' scope for Git over HTTP.\n" \ "You can generate one at #{profile_personal_access_tokens_url}" } ] - }, status: 401 + }, status: :unauthorized end def render_unauthorized @@ -50,7 +50,7 @@ class JwtController < ApplicationController { code: 'UNAUTHORIZED', message: 'HTTP Basic: Access denied' } ] - }, status: 401 + }, status: :unauthorized end def auth_params diff --git a/app/controllers/notification_settings_controller.rb b/app/controllers/notification_settings_controller.rb index 8ec4bb1233f..ed20302487c 100644 --- a/app/controllers/notification_settings_controller.rb +++ b/app/controllers/notification_settings_controller.rb @@ -5,14 +5,14 @@ class NotificationSettingsController < ApplicationController return render_404 unless can_read?(resource) @notification_setting = current_user.notification_settings_for(resource) - @saved = @notification_setting.update_attributes(notification_setting_params) + @saved = @notification_setting.update(notification_setting_params) render_response end def update @notification_setting = current_user.notification_settings.find(params[:id]) - @saved = @notification_setting.update_attributes(notification_setting_params) + @saved = @notification_setting.update(notification_setting_params) render_response end diff --git a/app/controllers/profiles/active_sessions_controller.rb b/app/controllers/profiles/active_sessions_controller.rb index f0cdc228366..f1e77d68acd 100644 --- a/app/controllers/profiles/active_sessions_controller.rb +++ b/app/controllers/profiles/active_sessions_controller.rb @@ -7,7 +7,7 @@ class Profiles::ActiveSessionsController < Profiles::ApplicationController ActiveSession.destroy(current_user, params[:id]) respond_to do |format| - format.html { redirect_to profile_active_sessions_url, status: 302 } + format.html { redirect_to profile_active_sessions_url, status: :found } format.js { head :ok } end end diff --git a/app/controllers/profiles/avatars_controller.rb b/app/controllers/profiles/avatars_controller.rb index 39b9f8a84d1..4f030ded80f 100644 --- a/app/controllers/profiles/avatars_controller.rb +++ b/app/controllers/profiles/avatars_controller.rb @@ -4,6 +4,6 @@ class Profiles::AvatarsController < Profiles::ApplicationController Users::UpdateService.new(current_user, user: @user).execute { |user| user.remove_avatar! } - redirect_to profile_path, status: 302 + redirect_to profile_path, status: :found end end diff --git a/app/controllers/profiles/chat_names_controller.rb b/app/controllers/profiles/chat_names_controller.rb index 2353f0840d6..a186c5f36a8 100644 --- a/app/controllers/profiles/chat_names_controller.rb +++ b/app/controllers/profiles/chat_names_controller.rb @@ -39,7 +39,7 @@ class Profiles::ChatNamesController < Profiles::ApplicationController flash[:alert] = "Could not delete chat nickname #{@chat_name.chat_name}." end - redirect_to profile_chat_names_path, status: 302 + redirect_to profile_chat_names_path, status: :found end private diff --git a/app/controllers/profiles/emails_controller.rb b/app/controllers/profiles/emails_controller.rb index bbd7ba49d77..a39824ec9c8 100644 --- a/app/controllers/profiles/emails_controller.rb +++ b/app/controllers/profiles/emails_controller.rb @@ -19,7 +19,7 @@ class Profiles::EmailsController < Profiles::ApplicationController Emails::DestroyService.new(current_user, user: current_user).execute(@email) respond_to do |format| - format.html { redirect_to profile_emails_url, status: 302 } + format.html { redirect_to profile_emails_url, status: :found } format.js { head :ok } end end diff --git a/app/controllers/profiles/gpg_keys_controller.rb b/app/controllers/profiles/gpg_keys_controller.rb index 38e3eacd229..c32507756e8 100644 --- a/app/controllers/profiles/gpg_keys_controller.rb +++ b/app/controllers/profiles/gpg_keys_controller.rb @@ -21,7 +21,7 @@ class Profiles::GpgKeysController < Profiles::ApplicationController @gpg_key.destroy respond_to do |format| - format.html { redirect_to profile_gpg_keys_url, status: 302 } + format.html { redirect_to profile_gpg_keys_url, status: :found } format.js { head :ok } end end @@ -30,7 +30,7 @@ class Profiles::GpgKeysController < Profiles::ApplicationController @gpg_key.revoke respond_to do |format| - format.html { redirect_to profile_gpg_keys_url, status: 302 } + format.html { redirect_to profile_gpg_keys_url, status: :found } format.js { head :ok } end end diff --git a/app/controllers/profiles/keys_controller.rb b/app/controllers/profiles/keys_controller.rb index 12a6cd11f80..6035258667e 100644 --- a/app/controllers/profiles/keys_controller.rb +++ b/app/controllers/profiles/keys_controller.rb @@ -26,7 +26,7 @@ class Profiles::KeysController < Profiles::ApplicationController Keys::DestroyService.new(current_user).execute(@key) respond_to do |format| - format.html { redirect_to profile_keys_url, status: 302 } + format.html { redirect_to profile_keys_url, status: :found } format.js { head :ok } end end diff --git a/app/controllers/profiles/two_factor_auths_controller.rb b/app/controllers/profiles/two_factor_auths_controller.rb index aa9789f8a0f..29ff18a1219 100644 --- a/app/controllers/profiles/two_factor_auths_controller.rb +++ b/app/controllers/profiles/two_factor_auths_controller.rb @@ -78,7 +78,7 @@ class Profiles::TwoFactorAuthsController < Profiles::ApplicationController def destroy current_user.disable_two_factor! - redirect_to profile_account_path, status: 302 + redirect_to profile_account_path, status: :found end def skip diff --git a/app/controllers/projects/application_controller.rb b/app/controllers/projects/application_controller.rb index 5ab6d103c89..b4f814fd3a4 100644 --- a/app/controllers/projects/application_controller.rb +++ b/app/controllers/projects/application_controller.rb @@ -61,7 +61,7 @@ class Projects::ApplicationController < ApplicationController def require_non_empty_project # Be sure to return status code 303 to avoid a double DELETE: # http://api.rubyonrails.org/classes/ActionController/Redirecting.html - redirect_to project_path(@project), status: 303 if @project.empty_repo? + redirect_to project_path(@project), status: :see_other if @project.empty_repo? end def require_branch_head diff --git a/app/controllers/projects/avatars_controller.rb b/app/controllers/projects/avatars_controller.rb index 21a403f3765..a13d552dbd8 100644 --- a/app/controllers/projects/avatars_controller.rb +++ b/app/controllers/projects/avatars_controller.rb @@ -21,6 +21,6 @@ class Projects::AvatarsController < Projects::ApplicationController @project.save - redirect_to edit_project_path(@project), status: 302 + redirect_to edit_project_path(@project), status: :found end end diff --git a/app/controllers/projects/branches_controller.rb b/app/controllers/projects/branches_controller.rb index cd7250b10fc..d1dc9fe9600 100644 --- a/app/controllers/projects/branches_controller.rb +++ b/app/controllers/projects/branches_controller.rb @@ -98,7 +98,7 @@ class Projects::BranchesController < Projects::ApplicationController flash_type = result[:status] == :error ? :alert : :notice flash[flash_type] = result[:message] - redirect_to project_branches_path(@project), status: 303 + redirect_to project_branches_path(@project), status: :see_other end format.js { render nothing: true, status: result[:return_code] } diff --git a/app/controllers/projects/clusters_controller.rb b/app/controllers/projects/clusters_controller.rb index 62193257940..358fe59618b 100644 --- a/app/controllers/projects/clusters_controller.rb +++ b/app/controllers/projects/clusters_controller.rb @@ -62,7 +62,7 @@ class Projects::ClustersController < Projects::ApplicationController def destroy if cluster.destroy flash[:notice] = _('Kubernetes cluster integration was successfully removed.') - redirect_to project_clusters_path(project), status: 302 + redirect_to project_clusters_path(project), status: :found else flash[:notice] = _('Kubernetes cluster integration was not removed.') render :show diff --git a/app/controllers/projects/deploy_keys_controller.rb b/app/controllers/projects/deploy_keys_controller.rb index f43ef2e5f2f..06739d8fd4a 100644 --- a/app/controllers/projects/deploy_keys_controller.rb +++ b/app/controllers/projects/deploy_keys_controller.rb @@ -35,7 +35,7 @@ class Projects::DeployKeysController < Projects::ApplicationController end def update - if deploy_key.update_attributes(update_params) + if deploy_key.update(update_params) flash[:notice] = 'Deploy key was successfully updated.' redirect_to_repository_settings(@project) else diff --git a/app/controllers/projects/environments_controller.rb b/app/controllers/projects/environments_controller.rb index 27b7425b965..395c5336ad5 100644 --- a/app/controllers/projects/environments_controller.rb +++ b/app/controllers/projects/environments_controller.rb @@ -116,7 +116,7 @@ class Projects::EnvironmentsController < Projects::ApplicationController set_workhorse_internal_api_content_type render json: Gitlab::Workhorse.terminal_websocket(terminal) else - render text: 'Not found', status: 404 + render text: 'Not found', status: :not_found end end diff --git a/app/controllers/projects/git_http_client_controller.rb b/app/controllers/projects/git_http_client_controller.rb index 07249fe3182..a52814e6e52 100644 --- a/app/controllers/projects/git_http_client_controller.rb +++ b/app/controllers/projects/git_http_client_controller.rb @@ -53,7 +53,7 @@ class Projects::GitHttpClientController < Projects::ApplicationController end send_challenges - render plain: "HTTP Basic: Access denied\n", status: 401 + render plain: "HTTP Basic: Access denied\n", status: :unauthorized rescue Gitlab::Auth::MissingPersonalAccessTokenError render_missing_personal_access_token end @@ -83,7 +83,7 @@ class Projects::GitHttpClientController < Projects::ApplicationController render plain: "HTTP Basic: Access denied\n" \ "You must use a personal access token with 'api' scope for Git over HTTP.\n" \ "You can generate one at #{profile_personal_access_tokens_url}", - status: 401 + status: :unauthorized end def repository diff --git a/app/controllers/projects/group_links_controller.rb b/app/controllers/projects/group_links_controller.rb index f58ee3e9109..bc5f38f3c2b 100644 --- a/app/controllers/projects/group_links_controller.rb +++ b/app/controllers/projects/group_links_controller.rb @@ -24,7 +24,7 @@ class Projects::GroupLinksController < Projects::ApplicationController def update @group_link = @project.project_group_links.find(params[:id]) - @group_link.update_attributes(group_link_params) + @group_link.update(group_link_params) end def destroy @@ -34,7 +34,7 @@ class Projects::GroupLinksController < Projects::ApplicationController respond_to do |format| format.html do - redirect_to project_project_members_path(project), status: 302 + redirect_to project_project_members_path(project), status: :found end format.js { head :ok } end diff --git a/app/controllers/projects/hooks_controller.rb b/app/controllers/projects/hooks_controller.rb index 6800d742b0a..2da2aad9b33 100644 --- a/app/controllers/projects/hooks_controller.rb +++ b/app/controllers/projects/hooks_controller.rb @@ -29,7 +29,7 @@ class Projects::HooksController < Projects::ApplicationController end def update - if hook.update_attributes(hook_params) + if hook.update(hook_params) flash[:notice] = 'Hook was successfully updated.' redirect_to project_settings_integrations_path(@project) else @@ -48,7 +48,7 @@ class Projects::HooksController < Projects::ApplicationController def destroy hook.destroy - redirect_to project_settings_integrations_path(@project), status: 302 + redirect_to project_settings_integrations_path(@project), status: :found end private diff --git a/app/controllers/projects/labels_controller.rb b/app/controllers/projects/labels_controller.rb index 91016f6494e..21d3c918581 100644 --- a/app/controllers/projects/labels_controller.rb +++ b/app/controllers/projects/labels_controller.rb @@ -39,7 +39,7 @@ class Projects::LabelsController < Projects::ApplicationController else respond_to do |format| format.html { render :new } - format.json { render json: { message: @label.errors.messages }, status: 400 } + format.json { render json: { message: @label.errors.messages }, status: :bad_request } end end end @@ -115,7 +115,7 @@ class Projects::LabelsController < Projects::ApplicationController flash[:notice] = "#{@label.title} promoted to <a href=\"#{group_labels_path(@project.group)}\">group label</a>.".html_safe respond_to do |format| format.html do - redirect_to(project_labels_path(@project), status: 303) + redirect_to(project_labels_path(@project), status: :see_other) end format.json do render json: { url: project_labels_path(@project) } diff --git a/app/controllers/projects/lfs_api_controller.rb b/app/controllers/projects/lfs_api_controller.rb index 3f4962b543d..c64ccc3d473 100644 --- a/app/controllers/projects/lfs_api_controller.rb +++ b/app/controllers/projects/lfs_api_controller.rb @@ -25,7 +25,7 @@ class Projects::LfsApiController < Projects::GitHttpClientController message: 'Server supports batch API only, please update your Git LFS client to version 1.0.1 and up.', documentation_url: "#{Gitlab.config.gitlab.url}/help" }, - status: 501 + status: :not_implemented ) end diff --git a/app/controllers/projects/lfs_storage_controller.rb b/app/controllers/projects/lfs_storage_controller.rb index 45c98d60822..dd7e673ec75 100644 --- a/app/controllers/projects/lfs_storage_controller.rb +++ b/app/controllers/projects/lfs_storage_controller.rb @@ -28,7 +28,7 @@ class Projects::LfsStorageController < Projects::GitHttpClientController if store_file!(oid, size) head 200 else - render plain: 'Unprocessable entity', status: 422 + render plain: 'Unprocessable entity', status: :unprocessable_entity end rescue ActiveRecord::RecordInvalid render_lfs_forbidden diff --git a/app/controllers/projects/merge_requests_controller.rb b/app/controllers/projects/merge_requests_controller.rb index a7c5f858c42..1ad2e93c85f 100644 --- a/app/controllers/projects/merge_requests_controller.rb +++ b/app/controllers/projects/merge_requests_controller.rb @@ -227,7 +227,7 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo def rebase RebaseWorker.perform_async(@merge_request.id, current_user.id) - render nothing: true, status: 200 + render nothing: true, status: :ok end protected diff --git a/app/controllers/projects/milestones_controller.rb b/app/controllers/projects/milestones_controller.rb index 594563d1f6f..5e86ec93f34 100644 --- a/app/controllers/projects/milestones_controller.rb +++ b/app/controllers/projects/milestones_controller.rb @@ -96,7 +96,7 @@ class Projects::MilestonesController < Projects::ApplicationController Milestones::DestroyService.new(project, current_user).execute(milestone) respond_to do |format| - format.html { redirect_to namespace_project_milestones_path, status: 303 } + format.html { redirect_to namespace_project_milestones_path, status: :see_other } format.js { head :ok } end end diff --git a/app/controllers/projects/mirrors_controller.rb b/app/controllers/projects/mirrors_controller.rb index 5698ff4e706..3b24d231f3d 100644 --- a/app/controllers/projects/mirrors_controller.rb +++ b/app/controllers/projects/mirrors_controller.rb @@ -13,7 +13,7 @@ class Projects::MirrorsController < Projects::ApplicationController end def update - if project.update_attributes(mirror_params) + if project.update(mirror_params) flash[:notice] = 'Mirroring settings were successfully updated.' else flash[:alert] = project.errors.full_messages.join(', ').html_safe diff --git a/app/controllers/projects/pipeline_schedules_controller.rb b/app/controllers/projects/pipeline_schedules_controller.rb index fa258f3d9af..aeda7b3edf5 100644 --- a/app/controllers/projects/pipeline_schedules_controller.rb +++ b/app/controllers/projects/pipeline_schedules_controller.rb @@ -64,7 +64,7 @@ class Projects::PipelineSchedulesController < Projects::ApplicationController def destroy if schedule.destroy - redirect_to pipeline_schedules_path(@project), status: 302 + redirect_to pipeline_schedules_path(@project), status: :found else redirect_to pipeline_schedules_path(@project), status: :forbidden, diff --git a/app/controllers/projects/releases_controller.rb b/app/controllers/projects/releases_controller.rb index 3e0a530fdb9..19e09b3af6f 100644 --- a/app/controllers/projects/releases_controller.rb +++ b/app/controllers/projects/releases_controller.rb @@ -14,7 +14,7 @@ class Projects::ReleasesController < Projects::ApplicationController # it exists only to save a description to each Tag. # If description is empty we should destroy the existing record. if release_params[:description].present? - release.update_attributes(release_params) + release.update(release_params) else release.destroy end diff --git a/app/controllers/projects/repositories_controller.rb b/app/controllers/projects/repositories_controller.rb index d01f324e6fd..ecb2ece7532 100644 --- a/app/controllers/projects/repositories_controller.rb +++ b/app/controllers/projects/repositories_controller.rb @@ -24,7 +24,7 @@ class Projects::RepositoriesController < Projects::ApplicationController send_git_archive @repository, ref: @ref, format: params[:format], append_sha: append_sha rescue => ex logger.error("#{self.class.name}: #{ex}") - return git_not_found! + git_not_found! end def assign_archive_vars diff --git a/app/controllers/projects/runner_projects_controller.rb b/app/controllers/projects/runner_projects_controller.rb index a080724634b..c098c82081e 100644 --- a/app/controllers/projects/runner_projects_controller.rb +++ b/app/controllers/projects/runner_projects_controller.rb @@ -21,6 +21,6 @@ class Projects::RunnerProjectsController < Projects::ApplicationController runner_project = project.runner_projects.find(params[:id]) runner_project.destroy - redirect_to project_runners_path(project), status: 302 + redirect_to project_runners_path(project), status: :found end end diff --git a/app/controllers/projects/runners_controller.rb b/app/controllers/projects/runners_controller.rb index bef94cea989..cc7cce887bf 100644 --- a/app/controllers/projects/runners_controller.rb +++ b/app/controllers/projects/runners_controller.rb @@ -24,7 +24,7 @@ class Projects::RunnersController < Projects::ApplicationController @runner.destroy end - redirect_to project_runners_path(@project), status: 302 + redirect_to project_runners_path(@project), status: :found end def resume diff --git a/app/controllers/projects/services_controller.rb b/app/controllers/projects/services_controller.rb index 690596b12db..d55046047ae 100644 --- a/app/controllers/projects/services_controller.rb +++ b/app/controllers/projects/services_controller.rb @@ -34,7 +34,7 @@ class Projects::ServicesController < Projects::ApplicationController private def service_test_response - if @service.update_attributes(service_params[:service]) + if @service.update(service_params[:service]) data = @service.test_data(project, current_user) outcome = @service.test(data) diff --git a/app/controllers/projects/snippets_controller.rb b/app/controllers/projects/snippets_controller.rb index 208a1d19862..f742d7edf83 100644 --- a/app/controllers/projects/snippets_controller.rb +++ b/app/controllers/projects/snippets_controller.rb @@ -82,7 +82,7 @@ class Projects::SnippetsController < Projects::ApplicationController @snippet.destroy - redirect_to project_snippets_path(@project), status: 302 + redirect_to project_snippets_path(@project), status: :found end protected diff --git a/app/controllers/projects/tags_controller.rb b/app/controllers/projects/tags_controller.rb index b62d7d9b7c5..b17753222a0 100644 --- a/app/controllers/projects/tags_controller.rb +++ b/app/controllers/projects/tags_controller.rb @@ -50,7 +50,7 @@ class Projects::TagsController < Projects::ApplicationController respond_to do |format| if result[:status] == :success format.html do - redirect_to project_tags_path(@project), status: 303 + redirect_to project_tags_path(@project), status: :see_other end format.js diff --git a/app/controllers/projects/templates_controller.rb b/app/controllers/projects/templates_controller.rb index 694b468c8d3..52d6fb82093 100644 --- a/app/controllers/projects/templates_controller.rb +++ b/app/controllers/projects/templates_controller.rb @@ -14,6 +14,6 @@ class Projects::TemplatesController < Projects::ApplicationController def get_template_class template_types = { issue: Gitlab::Template::IssueTemplate, merge_request: Gitlab::Template::MergeRequestTemplate }.with_indifferent_access @template_type = template_types[params[:template_type]] - render json: [], status: 404 unless @template_type + render json: [], status: :not_found unless @template_type end end diff --git a/app/controllers/projects/triggers_controller.rb b/app/controllers/projects/triggers_controller.rb index e04145dd0b3..6f3de43f85a 100644 --- a/app/controllers/projects/triggers_controller.rb +++ b/app/controllers/projects/triggers_controller.rb @@ -50,7 +50,7 @@ class Projects::TriggersController < Projects::ApplicationController flash[:alert] = "Could not remove the trigger." end - redirect_to project_settings_ci_cd_path(@project), status: 302 + redirect_to project_settings_ci_cd_path(@project), status: :found end private diff --git a/app/controllers/projects/wikis_controller.rb b/app/controllers/projects/wikis_controller.rb index aa844e94d89..c01066c688a 100644 --- a/app/controllers/projects/wikis_controller.rb +++ b/app/controllers/projects/wikis_controller.rb @@ -120,7 +120,7 @@ class Projects::WikisController < Projects::ApplicationController rescue ProjectWiki::CouldNotCreateWikiError flash[:notice] = "Could not create Wiki Repository at this time. Please try again later." redirect_to project_path(@project) - return false + false end def wiki_params @@ -129,7 +129,7 @@ class Projects::WikisController < Projects::ApplicationController def build_page(args) WikiPage.new(@project_wiki).tap do |page| - page.update_attributes(args) + page.update_attributes(args) # rubocop:disable Rails/ActiveRecordAliases end end end diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index f2abe27f60e..9d1c44db137 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -133,7 +133,7 @@ class ProjectsController < Projects::ApplicationController ::Projects::DestroyService.new(@project, current_user, {}).async_execute flash[:notice] = _("Project '%{project_name}' is in the process of being deleted.") % { project_name: @project.full_name } - redirect_to dashboard_projects_path, status: 302 + redirect_to dashboard_projects_path, status: :found rescue Projects::DestroyService::DestroyError => ex redirect_to edit_project_path(@project), status: 302, alert: ex.message end diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 1de6ae24622..9dd652206fe 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -32,8 +32,8 @@ class SessionsController < Devise::SessionsController super do |resource| # User has successfully signed in, so clear any unused reset token if resource.reset_password_token.present? - resource.update_attributes(reset_password_token: nil, - reset_password_sent_at: nil) + resource.update(reset_password_token: nil, + reset_password_sent_at: nil) end # hide the signed-in notification diff --git a/app/controllers/sherlock/transactions_controller.rb b/app/controllers/sherlock/transactions_controller.rb index cb6c3a7cd98..ae4953c3259 100644 --- a/app/controllers/sherlock/transactions_controller.rb +++ b/app/controllers/sherlock/transactions_controller.rb @@ -13,7 +13,7 @@ module Sherlock def destroy_all Gitlab::Sherlock.collection.clear - redirect_to :back, status: 302 + redirect_to :back, status: :found end end end diff --git a/app/controllers/snippets_controller.rb b/app/controllers/snippets_controller.rb index 3d51520ddf4..1d6d0943674 100644 --- a/app/controllers/snippets_controller.rb +++ b/app/controllers/snippets_controller.rb @@ -89,7 +89,7 @@ class SnippetsController < ApplicationController @snippet.destroy - redirect_to snippets_path, status: 302 + redirect_to snippets_path, status: :found end protected diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index 19949f83351..44103e3bc4f 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -371,7 +371,7 @@ module Ci def update_coverage coverage = trace.extract_coverage(coverage_regex) - update_attributes(coverage: coverage) if coverage.present? + update(coverage: coverage) if coverage.present? end def parse_trace_sections! diff --git a/app/models/concerns/protected_ref.rb b/app/models/concerns/protected_ref.rb index 94eef4ff7cd..dbe8d31de37 100644 --- a/app/models/concerns/protected_ref.rb +++ b/app/models/concerns/protected_ref.rb @@ -23,7 +23,7 @@ module ProtectedRef # If we don't `protected_branch` or `protected_tag` would be empty and # `project` cannot be delegated to it, which in turn would cause validations # to fail. - has_many :"#{type}_access_levels", inverse_of: self.model_name.singular # rubocop:disable Cop/ActiveRecordDependent + has_many :"#{type}_access_levels", inverse_of: self.model_name.singular validates :"#{type}_access_levels", length: { is: 1, message: "are restricted to a single instance per #{self.model_name.human}." } diff --git a/app/models/network/commit.rb b/app/models/network/commit.rb index 22d48c9e661..d667948deae 100644 --- a/app/models/network/commit.rb +++ b/app/models/network/commit.rb @@ -11,8 +11,8 @@ module Network @parent_spaces = [] end - def method_missing(m, *args, &block) - @commit.__send__(m, *args, &block) # rubocop:disable GitlabSecurity/PublicSend + def method_missing(msg, *args, &block) + @commit.__send__(msg, *args, &block) # rubocop:disable GitlabSecurity/PublicSend end def space diff --git a/app/models/project_wiki.rb b/app/models/project_wiki.rb index a6f94b3e3b0..fc868c3ebb7 100644 --- a/app/models/project_wiki.rb +++ b/app/models/project_wiki.rb @@ -107,7 +107,7 @@ class ProjectWiki update_project_activity rescue Gitlab::Git::Wiki::DuplicatePageError => e @error_message = "Duplicate page: #{e.message}" - return false + false end def update_page(page, content:, title: nil, format: :markdown, message: nil) diff --git a/app/models/remote_mirror.rb b/app/models/remote_mirror.rb index c4b5dd2dc96..976b501e297 100644 --- a/app/models/remote_mirror.rb +++ b/app/models/remote_mirror.rb @@ -57,7 +57,7 @@ class RemoteMirror < ActiveRecord::Base Gitlab::Metrics.add_event(:remote_mirrors_finished, path: remote_mirror.project.full_path) timestamp = Time.now - remote_mirror.update_attributes!( + remote_mirror.update!( last_update_at: timestamp, last_successful_update_at: timestamp, last_error: nil ) end diff --git a/app/models/repository.rb b/app/models/repository.rb index 7cd600fec5b..5ed2a7b4068 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -462,12 +462,12 @@ class Repository expire_branches_cache end - def method_missing(m, *args, &block) - if m == :lookup && !block_given? - lookup_cache[m] ||= {} - lookup_cache[m][args.join(":")] ||= raw_repository.__send__(m, *args, &block) # rubocop:disable GitlabSecurity/PublicSend + def method_missing(msg, *args, &block) + if msg == :lookup && !block_given? + lookup_cache[msg] ||= {} + lookup_cache[msg][args.join(":")] ||= raw_repository.__send__(msg, *args, &block) # rubocop:disable GitlabSecurity/PublicSend else - raw_repository.__send__(m, *args, &block) # rubocop:disable GitlabSecurity/PublicSend + raw_repository.__send__(msg, *args, &block) # rubocop:disable GitlabSecurity/PublicSend end end diff --git a/app/models/user.rb b/app/models/user.rb index 27a5d0278b7..1c5d39db118 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -496,7 +496,7 @@ class User < ActiveRecord::Base def disable_two_factor! transaction do - update_attributes( + update( otp_required_for_login: false, encrypted_otp_secret: nil, encrypted_otp_secret_iv: nil, @@ -1053,7 +1053,7 @@ class User < ActiveRecord::Base return @global_notification_setting if defined?(@global_notification_setting) @global_notification_setting = notification_settings.find_or_initialize_by(source: nil) - @global_notification_setting.update_attributes(level: NotificationSetting.levels[DEFAULT_NOTIFICATION_LEVEL]) unless @global_notification_setting.persisted? + @global_notification_setting.update(level: NotificationSetting.levels[DEFAULT_NOTIFICATION_LEVEL]) unless @global_notification_setting.persisted? @global_notification_setting end @@ -1333,8 +1333,8 @@ class User < ActiveRecord::Base end end - def self.unique_internal(scope, username, email_pattern, &b) - scope.first || create_unique_internal(scope, username, email_pattern, &b) + def self.unique_internal(scope, username, email_pattern, &block) + scope.first || create_unique_internal(scope, username, email_pattern, &block) end def self.create_unique_internal(scope, username, email_pattern, &creation_block) diff --git a/app/models/wiki_page.rb b/app/models/wiki_page.rb index cde79b95062..4b49edb01a5 100644 --- a/app/models/wiki_page.rb +++ b/app/models/wiki_page.rb @@ -1,3 +1,4 @@ +# rubocop:disable Rails/ActiveRecordAliases class WikiPage PageChangedError = Class.new(StandardError) PageRenameError = Class.new(StandardError) diff --git a/app/services/badges/update_service.rb b/app/services/badges/update_service.rb index 7ca84b5df31..495a4a2c99d 100644 --- a/app/services/badges/update_service.rb +++ b/app/services/badges/update_service.rb @@ -3,7 +3,7 @@ module Badges # returns the updated badge def execute(badge) if params.present? - badge.update_attributes(params) + badge.update(params) end badge diff --git a/app/services/commits/change_service.rb b/app/services/commits/change_service.rb index b9d0173a2d0..1ce6ab36cbf 100644 --- a/app/services/commits/change_service.rb +++ b/app/services/commits/change_service.rb @@ -13,8 +13,6 @@ module Commits # rubocop:disable GitlabSecurity/PublicSend message = @commit.public_send(:"#{action}_message", current_user) - - # rubocop:disable GitlabSecurity/PublicSend repository.public_send( action, current_user, diff --git a/app/services/issuable_base_service.rb b/app/services/issuable_base_service.rb index 683f64e82ad..5e06e0c61cf 100644 --- a/app/services/issuable_base_service.rb +++ b/app/services/issuable_base_service.rb @@ -130,7 +130,7 @@ class IssuableBaseService < BaseService def create_issuable(issuable, attributes, label_ids:) issuable.with_transaction_returning_status do if issuable.save - issuable.update_attributes(label_ids: label_ids) + issuable.update(label_ids: label_ids) end end end diff --git a/app/services/members/update_service.rb b/app/services/members/update_service.rb index 48b3d59f7bd..cb19cf01dd7 100644 --- a/app/services/members/update_service.rb +++ b/app/services/members/update_service.rb @@ -6,7 +6,7 @@ module Members old_access_level = member.human_access - if member.update_attributes(params) + if member.update(params) after_execute(action: permission, old_access_level: old_access_level, member: member) end diff --git a/app/services/merge_requests/rebase_service.rb b/app/services/merge_requests/rebase_service.rb index 5b4bc86b9ba..c741e913860 100644 --- a/app/services/merge_requests/rebase_service.rb +++ b/app/services/merge_requests/rebase_service.rb @@ -26,7 +26,7 @@ module MergeRequests Gitlab::GitLogger.info("#{log_prefix} rebased to #{rebase_sha}") - merge_request.update_attributes(rebase_commit_sha: rebase_sha) + merge_request.update(rebase_commit_sha: rebase_sha) Gitlab::GitLogger.info("#{log_prefix} rebase SHA saved: #{rebase_sha}") diff --git a/app/services/milestones/update_service.rb b/app/services/milestones/update_service.rb index 31b441ed476..74edbf9b41d 100644 --- a/app/services/milestones/update_service.rb +++ b/app/services/milestones/update_service.rb @@ -11,7 +11,7 @@ module Milestones end if params.present? - milestone.update_attributes(params.except(:state_event)) + milestone.update(params.except(:state_event)) end milestone diff --git a/app/services/notes/update_service.rb b/app/services/notes/update_service.rb index 75fd08ea0a9..e16ef398184 100644 --- a/app/services/notes/update_service.rb +++ b/app/services/notes/update_service.rb @@ -5,7 +5,7 @@ module Notes old_mentioned_users = note.mentioned_users.to_a - note.update_attributes(params.merge(updated_by: current_user)) + note.update(params.merge(updated_by: current_user)) note.create_new_cross_references!(current_user) if note.previous_changes.include?('note') diff --git a/app/services/notification_recipient_service.rb b/app/services/notification_recipient_service.rb index 4fa38665abc..d9834fd0ccc 100644 --- a/app/services/notification_recipient_service.rb +++ b/app/services/notification_recipient_service.rb @@ -10,16 +10,16 @@ module NotificationRecipientService NotificationRecipient.new(user, *args).notifiable? end - def self.build_recipients(*a) - Builder::Default.new(*a).notification_recipients + def self.build_recipients(*args) + Builder::Default.new(*args).notification_recipients end - def self.build_new_note_recipients(*a) - Builder::NewNote.new(*a).notification_recipients + def self.build_new_note_recipients(*args) + Builder::NewNote.new(*args).notification_recipients end - def self.build_merge_request_unmergeable_recipients(*a) - Builder::MergeRequestUnmergeable.new(*a).notification_recipients + def self.build_merge_request_unmergeable_recipients(*args) + Builder::MergeRequestUnmergeable.new(*args).notification_recipients end module Builder @@ -44,7 +44,6 @@ module NotificationRecipientService raise 'abstract' end - # rubocop:disable Rails/Delegate def project target.project end diff --git a/app/services/projects/destroy_service.rb b/app/services/projects/destroy_service.rb index 02769e72229..87173cc79ec 100644 --- a/app/services/projects/destroy_service.rb +++ b/app/services/projects/destroy_service.rb @@ -124,7 +124,7 @@ module Projects # It's possible that the project was destroyed, but some after_commit # hook failed and caused us to end up here. A destroyed model will be a frozen hash, # which cannot be altered. - project.update_attributes(delete_error: message, pending_delete: false) unless project.destroyed? + project.update(delete_error: message, pending_delete: false) unless project.destroyed? log_error("Deletion failed on #{project.full_path} with the following message: #{message}") end diff --git a/app/services/projects/fork_service.rb b/app/services/projects/fork_service.rb index 348eb0bf8d8..a8aafa9fb4f 100644 --- a/app/services/projects/fork_service.rb +++ b/app/services/projects/fork_service.rb @@ -37,7 +37,7 @@ module Projects return new_project unless new_project.persisted? builds_access_level = @project.project_feature.builds_access_level - new_project.project_feature.update_attributes(builds_access_level: builds_access_level) + new_project.project_feature.update(builds_access_level: builds_access_level) link_fork_network(new_project) diff --git a/app/services/projects/lfs_pointers/lfs_download_service.rb b/app/services/projects/lfs_pointers/lfs_download_service.rb index 6ea43561d61..618c30b971f 100644 --- a/app/services/projects/lfs_pointers/lfs_download_service.rb +++ b/app/services/projects/lfs_pointers/lfs_download_service.rb @@ -22,7 +22,7 @@ module Projects private def download_and_save_file(file, sanitized_uri) - IO.copy_stream(open(sanitized_uri.sanitized_url, headers(sanitized_uri)), file) + IO.copy_stream(open(sanitized_uri.sanitized_url, headers(sanitized_uri)), file) # rubocop:disable Security/Open end def headers(sanitized_uri) diff --git a/app/services/projects/update_service.rb b/app/services/projects/update_service.rb index d8250cd8102..f4fbaacc08b 100644 --- a/app/services/projects/update_service.rb +++ b/app/services/projects/update_service.rb @@ -22,7 +22,7 @@ module Projects # If the block added errors, don't try to save the project return validation_failed! if project.errors.any? - if project.update_attributes(params.except(:default_branch)) + if project.update(params.except(:default_branch)) if project.previous_changes.include?('path') project.rename_repo else diff --git a/app/services/update_release_service.rb b/app/services/update_release_service.rb index b7c36651968..dc696e9c440 100644 --- a/app/services/update_release_service.rb +++ b/app/services/update_release_service.rb @@ -7,7 +7,7 @@ class UpdateReleaseService < BaseService release = project.releases.find_by(tag: tag_name) if release - release.update_attributes(description: release_description) + release.update(description: release_description) success(release) else diff --git a/app/workers/email_receiver_worker.rb b/app/workers/email_receiver_worker.rb index f9f0efb302a..12706613ac2 100644 --- a/app/workers/email_receiver_worker.rb +++ b/app/workers/email_receiver_worker.rb @@ -15,14 +15,14 @@ class EmailReceiverWorker private - def handle_failure(raw, e) - Rails.logger.warn("Email can not be processed: #{e}\n\n#{raw}") + def handle_failure(raw, error) + Rails.logger.warn("Email can not be processed: #{error}\n\n#{raw}") return unless raw.present? can_retry = false reason = - case e + case error when Gitlab::Email::UnknownIncomingEmail "We couldn't figure out what the email is for. Please create your issue or comment through the web interface." when Gitlab::Email::SentNotificationNotFoundError @@ -42,7 +42,7 @@ class EmailReceiverWorker "The thread you are replying to no longer exists, perhaps it was deleted? If you believe this is in error, contact a staff member." when Gitlab::Email::InvalidRecordError can_retry = true - e.message + error.message end if reason diff --git a/app/workers/object_storage/migrate_uploads_worker.rb b/app/workers/object_storage/migrate_uploads_worker.rb index a3ecfa8e711..01d03ec7888 100644 --- a/app/workers/object_storage/migrate_uploads_worker.rb +++ b/app/workers/object_storage/migrate_uploads_worker.rb @@ -1,6 +1,4 @@ # frozen_string_literal: true -# rubocop:disable Metrics/LineLength -# rubocop:disable Style/Documentation module ObjectStorage class MigrateUploadsWorker |