Commit 4ee08b77 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Updates from `rubocop -a`

parent 612f5e63
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
# Add your own tasks in files placed in lib/tasks ending in .rake, # Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__) require File.expand_path('config/application', __dir__)
relative_url_conf = File.expand_path('../config/initializers/relative_url', __FILE__) relative_url_conf = File.expand_path('config/initializers/relative_url', __dir__)
require relative_url_conf if File.exist?("#{relative_url_conf}.rb") require relative_url_conf if File.exist?("#{relative_url_conf}.rb")
Gitlab::Application.load_tasks Gitlab::Application.load_tasks
......
...@@ -22,7 +22,7 @@ class Admin::DeployKeysController < Admin::ApplicationController ...@@ -22,7 +22,7 @@ class Admin::DeployKeysController < Admin::ApplicationController
end end
def update def update
if deploy_key.update_attributes(update_params) if deploy_key.update(update_params)
flash[:notice] = 'Deploy key was successfully updated.' flash[:notice] = 'Deploy key was successfully updated.'
redirect_to admin_deploy_keys_path redirect_to admin_deploy_keys_path
else else
...@@ -34,7 +34,7 @@ class Admin::DeployKeysController < Admin::ApplicationController ...@@ -34,7 +34,7 @@ class Admin::DeployKeysController < Admin::ApplicationController
deploy_key.destroy deploy_key.destroy
respond_to do |format| 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 } format.json { head :ok }
end end
end end
......
...@@ -39,7 +39,7 @@ class Admin::GroupsController < Admin::ApplicationController ...@@ -39,7 +39,7 @@ class Admin::GroupsController < Admin::ApplicationController
end end
def update def update
if @group.update_attributes(group_params) if @group.update(group_params)
redirect_to [:admin, @group], notice: 'Group was successfully updated.' redirect_to [:admin, @group], notice: 'Group was successfully updated.'
else else
render "edit" render "edit"
......
...@@ -23,7 +23,7 @@ class Admin::HooksController < Admin::ApplicationController ...@@ -23,7 +23,7 @@ class Admin::HooksController < Admin::ApplicationController
end end
def update def update
if hook.update_attributes(hook_params) if hook.update(hook_params)
flash[:notice] = 'System hook was successfully updated.' flash[:notice] = 'System hook was successfully updated.'
redirect_to admin_hooks_path redirect_to admin_hooks_path
else else
...@@ -34,7 +34,7 @@ class Admin::HooksController < Admin::ApplicationController ...@@ -34,7 +34,7 @@ class Admin::HooksController < Admin::ApplicationController
def destroy def destroy
hook.destroy hook.destroy
redirect_to admin_hooks_path, status: 302 redirect_to admin_hooks_path, status: :found
end end
def test def test
......
...@@ -25,7 +25,7 @@ class Admin::IdentitiesController < Admin::ApplicationController ...@@ -25,7 +25,7 @@ class Admin::IdentitiesController < Admin::ApplicationController
end end
def update def update
if @identity.update_attributes(identity_params) if @identity.update(identity_params)
RepairLdapBlockedUserService.new(@user).execute RepairLdapBlockedUserService.new(@user).execute
redirect_to admin_user_identities_path(@user), notice: 'User identity was successfully updated.' redirect_to admin_user_identities_path(@user), notice: 'User identity was successfully updated.'
else else
......
...@@ -11,7 +11,7 @@ class Admin::ImpersonationsController < Admin::ApplicationController ...@@ -11,7 +11,7 @@ class Admin::ImpersonationsController < Admin::ApplicationController
session[:impersonator_id] = nil session[:impersonator_id] = nil
redirect_to admin_user_path(original_user), status: 302 redirect_to admin_user_path(original_user), status: :found
end end
private private
......
...@@ -20,6 +20,6 @@ class Admin::JobsController < Admin::ApplicationController ...@@ -20,6 +20,6 @@ class Admin::JobsController < Admin::ApplicationController
def cancel_all def cancel_all
Ci::Build.running_or_pending.each(&:cancel) Ci::Build.running_or_pending.each(&:cancel)
redirect_to admin_jobs_path, status: 303 redirect_to admin_jobs_path, status: :see_other
end end
end end
...@@ -16,7 +16,7 @@ class Admin::RunnerProjectsController < Admin::ApplicationController ...@@ -16,7 +16,7 @@ class Admin::RunnerProjectsController < Admin::ApplicationController
runner = rp.runner runner = rp.runner
rp.destroy rp.destroy
redirect_to admin_runner_path(runner), status: 302 redirect_to admin_runner_path(runner), status: :found
end end
private private
......
...@@ -28,7 +28,7 @@ class Admin::RunnersController < Admin::ApplicationController ...@@ -28,7 +28,7 @@ class Admin::RunnersController < Admin::ApplicationController
def destroy def destroy
@runner.destroy @runner.destroy
redirect_to admin_runners_path, status: 302 redirect_to admin_runners_path, status: :found
end end
def resume def resume
......
...@@ -16,7 +16,7 @@ class Admin::ServicesController < Admin::ApplicationController ...@@ -16,7 +16,7 @@ class Admin::ServicesController < Admin::ApplicationController
end end
def update def update
if service.update_attributes(service_params[:service]) if service.update(service_params[:service])
PropagateServiceTemplateWorker.perform_async(service.id) if service.active? PropagateServiceTemplateWorker.perform_async(service.id) if service.active?
redirect_to admin_application_settings_services_path, redirect_to admin_application_settings_services_path,
......
...@@ -163,7 +163,7 @@ class Admin::UsersController < Admin::ApplicationController ...@@ -163,7 +163,7 @@ class Admin::UsersController < Admin::ApplicationController
format.json { head :ok } format.json { head :ok }
else else
format.html { redirect_back_or_admin_user(alert: 'There was an error removing the e-mail.') } 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 end
end end
......
...@@ -127,7 +127,7 @@ module IssuableActions ...@@ -127,7 +127,7 @@ module IssuableActions
errors: [ 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." "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 end
end end
......
...@@ -27,7 +27,7 @@ module LfsRequest ...@@ -27,7 +27,7 @@ module LfsRequest
message: 'Git LFS is not enabled on this GitLab server, contact your admin.', message: 'Git LFS is not enabled on this GitLab server, contact your admin.',
documentation_url: help_url documentation_url: help_url
}, },
status: 501 status: :not_implemented
) )
end end
......
...@@ -7,6 +7,6 @@ class Groups::AvatarsController < Groups::ApplicationController ...@@ -7,6 +7,6 @@ class Groups::AvatarsController < Groups::ApplicationController
@group.remove_avatar! @group.remove_avatar!
@group.save @group.save
redirect_to edit_group_path(@group), status: 302 redirect_to edit_group_path(@group), status: :found
end end
end end
...@@ -23,7 +23,7 @@ class Groups::RunnersController < Groups::ApplicationController ...@@ -23,7 +23,7 @@ class Groups::RunnersController < Groups::ApplicationController
def destroy def destroy
@runner.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 end
def resume def resume
......
...@@ -41,7 +41,7 @@ class JwtController < ApplicationController ...@@ -41,7 +41,7 @@ class JwtController < ApplicationController
"You must use a personal access token with 'api' scope for Git over HTTP.\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}" } "You can generate one at #{profile_personal_access_tokens_url}" }
] ]
}, status: 401 }, status: :unauthorized
end end
def render_unauthorized def render_unauthorized
...@@ -50,7 +50,7 @@ class JwtController < ApplicationController ...@@ -50,7 +50,7 @@ class JwtController < ApplicationController
{ code: 'UNAUTHORIZED', { code: 'UNAUTHORIZED',
message: 'HTTP Basic: Access denied' } message: 'HTTP Basic: Access denied' }
] ]
}, status: 401 }, status: :unauthorized
end end
def auth_params def auth_params
......
...@@ -5,14 +5,14 @@ class NotificationSettingsController < ApplicationController ...@@ -5,14 +5,14 @@ class NotificationSettingsController < ApplicationController
return render_404 unless can_read?(resource) return render_404 unless can_read?(resource)
@notification_setting = current_user.notification_settings_for(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 render_response
end end
def update def update
@notification_setting = current_user.notification_settings.find(params[:id]) @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 render_response
end end
......
...@@ -7,7 +7,7 @@ class Profiles::ActiveSessionsController < Profiles::ApplicationController ...@@ -7,7 +7,7 @@ class Profiles::ActiveSessionsController < Profiles::ApplicationController
ActiveSession.destroy(current_user, params[:id]) ActiveSession.destroy(current_user, params[:id])
respond_to do |format| 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 } format.js { head :ok }
end end
end end
......
...@@ -4,6 +4,6 @@ class Profiles::AvatarsController < Profiles::ApplicationController ...@@ -4,6 +4,6 @@ class Profiles::AvatarsController < Profiles::ApplicationController
Users::UpdateService.new(current_user, user: @user).execute { |user| user.remove_avatar! } 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
end end
...@@ -39,7 +39,7 @@ class Profiles::ChatNamesController < Profiles::ApplicationController ...@@ -39,7 +39,7 @@ class Profiles::ChatNamesController < Profiles::ApplicationController
flash[:alert] = "Could not delete chat nickname #{@chat_name.chat_name}." flash[:alert] = "Could not delete chat nickname #{@chat_name.chat_name}."
end end
redirect_to profile_chat_names_path, status: 302 redirect_to profile_chat_names_path, status: :found
end end
private private
......
...@@ -19,7 +19,7 @@ class Profiles::EmailsController < Profiles::ApplicationController ...@@ -19,7 +19,7 @@ class Profiles::EmailsController < Profiles::ApplicationController
Emails::DestroyService.new(current_user, user: current_user).execute(@email) Emails::DestroyService.new(current_user, user: current_user).execute(@email)
respond_to do |format| 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 } format.js { head :ok }
end end
end end
......
...@@ -21,7 +21,7 @@ class Profiles::GpgKeysController < Profiles::ApplicationController ...@@ -21,7 +21,7 @@ class Profiles::GpgKeysController < Profiles::ApplicationController
@gpg_key.destroy @gpg_key.destroy
respond_to do |format| 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 } format.js { head :ok }
end end
end end
...@@ -30,7 +30,7 @@ class Profiles::GpgKeysController < Profiles::ApplicationController ...@@ -30,7 +30,7 @@ class Profiles::GpgKeysController < Profiles::ApplicationController
@gpg_key.revoke @gpg_key.revoke
respond_to do |format| 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 } format.js { head :ok }
end end
end end
......
...@@ -26,7 +26,7 @@ class Profiles::KeysController < Profiles::ApplicationController ...@@ -26,7 +26,7 @@ class Profiles::KeysController < Profiles::ApplicationController
Keys::DestroyService.new(current_user).execute(@key) Keys::DestroyService.new(current_user).execute(@key)
respond_to do |format| 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 } format.js { head :ok }
end end
end end
......
...@@ -78,7 +78,7 @@ class Profiles::TwoFactorAuthsController < Profiles::ApplicationController ...@@ -78,7 +78,7 @@ class Profiles::TwoFactorAuthsController < Profiles::ApplicationController
def destroy def destroy
current_user.disable_two_factor! current_user.disable_two_factor!
redirect_to profile_account_path, status: 302 redirect_to profile_account_path, status: :found
end end
def skip def skip
......
...@@ -61,7 +61,7 @@ class Projects::ApplicationController < ApplicationController ...@@ -61,7 +61,7 @@ class Projects::ApplicationController < ApplicationController
def require_non_empty_project def require_non_empty_project
# Be sure to return status code 303 to avoid a double DELETE: # Be sure to return status code 303 to avoid a double DELETE:
# http://api.rubyonrails.org/classes/ActionController/Redirecting.html # 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 end
def require_branch_head def require_branch_head
......
...@@ -21,6 +21,6 @@ class Projects::AvatarsController < Projects::ApplicationController ...@@ -21,6 +21,6 @@ class Projects::AvatarsController < Projects::ApplicationController
@project.save @project.save
redirect_to edit_project_path(@project), status: 302 redirect_to edit_project_path(@project), status: :found
end end
end end
...@@ -98,7 +98,7 @@ class Projects::BranchesController < Projects::ApplicationController ...@@ -98,7 +98,7 @@ class Projects::BranchesController < Projects::ApplicationController
flash_type = result[:status] == :error ? :alert : :notice flash_type = result[:status] == :error ? :alert : :notice
flash[flash_type] = result[:message] flash[flash_type] = result[:message]
redirect_to project_branches_path(@project), status: 303 redirect_to project_branches_path(@project), status: :see_other
end end
format.js { render nothing: true, status: result[:return_code] } format.js { render nothing: true, status: result[:return_code] }
......
...@@ -62,7 +62,7 @@ class Projects::ClustersController < Projects::ApplicationController ...@@ -62,7 +62,7 @@ class Projects::ClustersController < Projects::ApplicationController
def destroy def destroy
if cluster.destroy if cluster.destroy
flash[:notice] = _('Kubernetes cluster integration was successfully removed.') 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 else
flash[:notice] = _('Kubernetes cluster integration was not removed.') flash[:notice] = _('Kubernetes cluster integration was not removed.')
render :show render :show
......
...@@ -35,7 +35,7 @@ class Projects::DeployKeysController < Projects::ApplicationController ...@@ -35,7 +35,7 @@ class Projects::DeployKeysController < Projects::ApplicationController
end end
def update def update
if deploy_key.update_attributes(update_params) if deploy_key.update(update_params)
flash[:notice] = 'Deploy key was successfully updated.' flash[:notice] = 'Deploy key was successfully updated.'
redirect_to_repository_settings(@project) redirect_to_repository_settings(@project)
else else
......
...@@ -116,7 +116,7 @@ class Projects::EnvironmentsController < Projects::ApplicationController ...@@ -116,7 +116,7 @@ class Projects::EnvironmentsController < Projects::ApplicationController
set_workhorse_internal_api_content_type set_workhorse_internal_api_content_type
render json: Gitlab::Workhorse.terminal_websocket(terminal) render json: Gitlab::Workhorse.terminal_websocket(terminal)
else else
render text: 'Not found', status: 404 render text: 'Not found', status: :not_found
end end
end end
......
...@@ -53,7 +53,7 @@ class Projects::GitHttpClientController < Projects::ApplicationController ...@@ -53,7 +53,7 @@ class Projects::GitHttpClientController < Projects::ApplicationController
end end
send_challenges send_challenges
render plain: "HTTP Basic: Access denied\n", status: 401 render plain: "HTTP Basic: Access denied\n", status: :unauthorized
rescue Gitlab::Auth::MissingPersonalAccessTokenError rescue Gitlab::Auth::MissingPersonalAccessTokenError
render_missing_personal_access_token render_missing_personal_access_token
end end
...@@ -83,7 +83,7 @@ class Projects::GitHttpClientController < Projects::ApplicationController ...@@ -83,7 +83,7 @@ class Projects::GitHttpClientController < Projects::ApplicationController
render plain: "HTTP Basic: Access denied\n" \ render plain: "HTTP Basic: Access denied\n" \
"You must use a personal access token with 'api' scope for Git over HTTP.\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}", "You can generate one at #{profile_personal_access_tokens_url}",
status: 401 status: :unauthorized
end end
def repository def repository
......
...@@ -24,7 +24,7 @@ class Projects::GroupLinksController < Projects::ApplicationController ...@@ -24,7 +24,7 @@ class Projects::GroupLinksController < Projects::ApplicationController
def update def update
@group_link = @project.project_group_links.find(params[:id]) @group_link = @project.project_group_links.find(params[:id])
@group_link.update_attributes(group_link_params) @group_link.update(group_link_params)
end end
def destroy def destroy
...@@ -34,7 +34,7 @@ class Projects::GroupLinksController < Projects::ApplicationController ...@@ -34,7 +34,7 @@ class Projects::GroupLinksController < Projects::ApplicationController
respond_to do |format| respond_to do |format|
format.html do format.html do
redirect_to project_project_members_path(project), status: 302 redirect_to project_project_members_path(project), status: :found
end end
format.js { head :ok } format.js { head :ok }
end end
......
...@@ -29,7 +29,7 @@ class Projects::HooksController < Projects::ApplicationController ...@@ -29,7 +29,7 @@ class Projects::HooksController < Projects::ApplicationController
end end
def update def update
if hook.update_attributes(hook_params) if hook.update(hook_params)
flash[:notice] = 'Hook was successfully updated.' flash[:notice] = 'Hook was successfully updated.'
redirect_to project_settings_integrations_path(@project) redirect_to project_settings_integrations_path(@project)
else else
...@@ -48,7 +48,7 @@ class Projects::HooksController < Projects::ApplicationController ...@@ -48,7 +48,7 @@ class Projects::HooksController < Projects::ApplicationController
def destroy def destroy
hook.destroy hook.destroy
redirect_to project_settings_integrations_path(@project), status: 302 redirect_to project_settings_integrations_path(@project), status: :found
end end
private private
......
...@@ -39,7 +39,7 @@ class Projects::LabelsController < Projects::ApplicationController ...@@ -39,7 +39,7 @@ class Projects::LabelsController < Projects::ApplicationController
else else
respond_to do |format| respond_to do |format|
format.html { render :new } 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 end
end end
...@@ -115,7 +115,7 @@ class Projects::LabelsController < Projects::ApplicationController ...@@ -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 flash[:notice] = "#{@label.title} promoted to <a href=\"#{group_labels_path(@project.group)}\">group label</a>.".html_safe
respond_to do |format| respond_to do |format|
format.html do format.html do
redirect_to(project_labels_path(@project), status: 303) redirect_to(project_labels_path(@project), status: :see_other)
end end
format.json do format.json do
render json: { url: project_labels_path(@project) } render json: { url: project_labels_path(@project) }
......
...@@ -25,7 +25,7 @@ class Projects::LfsApiController < Projects::GitHttpClientController ...@@ -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.', 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" documentation_url: "#{Gitlab.config.gitlab.url}/help"
}, },
status: 501 status: :not_implemented
) )
end end
......
...@@ -28,7 +28,7 @@ class Projects::LfsStorageController < Projects::GitHttpClientController ...@@ -28,7 +28,7 @@ class Projects::LfsStorageController < Projects::GitHttpClientController
if store_file!(oid, size) if store_file!(oid, size)
head 200 head 200
else else
render plain: 'Unprocessable entity', status: 422 render plain: 'Unprocessable entity', status: :unprocessable_entity
end end
rescue ActiveRecord::RecordInvalid rescue ActiveRecord::RecordInvalid
render_lfs_forbidden render_lfs_forbidden
......
...@@ -227,7 +227,7 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo ...@@ -227,7 +227,7 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo
def rebase def rebase