Skip to content

Commit

Permalink
Merge pull request #12239 from opf/fix/lint-autocorrect-rubocop
Browse files Browse the repository at this point in the history
lint: Run rubocop safe autocorrect
  • Loading branch information
cbliard committed Mar 15, 2023
2 parents fdd45d3 + 9e865b4 commit ca33ec3
Show file tree
Hide file tree
Showing 393 changed files with 940 additions and 1,017 deletions.
2 changes: 1 addition & 1 deletion app/contracts/admin_only_contract.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#++

# A contract that only checks whether the current user is an admin
class AdminOnlyContract < ::ModelContract
class AdminOnlyContract < ModelContract
include RequiresAdminGuard

protected
Expand Down
34 changes: 17 additions & 17 deletions app/controllers/attribute_help_texts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ class AttributeHelpTextsController < ApplicationController
before_action :find_entry, only: %i(edit update destroy)
before_action :find_type_scope

def index
@texts_by_type = AttributeHelpText.all_by_scope
end

def new
@attribute_help_text = AttributeHelpText.new type: @attribute_scope
end
Expand All @@ -43,32 +47,32 @@ def edit; end

def upsale; end

def update
call = ::AttributeHelpTexts::UpdateService
.new(user: current_user, model: @attribute_help_text)
def create
call = ::AttributeHelpTexts::CreateService
.new(user: current_user)
.call(permitted_params_with_attachments)

if call.success?
flash[:notice] = t(:notice_successful_update)
redirect_to attribute_help_texts_path(tab: @attribute_help_text.attribute_scope)
flash[:notice] = t(:notice_successful_create)
redirect_to attribute_help_texts_path(tab: call.result.attribute_scope)
else
@attribute_help_text = call.result
flash[:error] = call.message || I18n.t('notice_internal_server_error')
render action: 'edit'
render action: 'new'
end
end

def create
call = ::AttributeHelpTexts::CreateService
.new(user: current_user)
def update
call = ::AttributeHelpTexts::UpdateService
.new(user: current_user, model: @attribute_help_text)
.call(permitted_params_with_attachments)

if call.success?
flash[:notice] = t(:notice_successful_create)
redirect_to attribute_help_texts_path(tab: call.result.attribute_scope)
flash[:notice] = t(:notice_successful_update)
redirect_to attribute_help_texts_path(tab: @attribute_help_text.attribute_scope)
else
@attribute_help_text = call.result
flash[:error] = call.message || I18n.t('notice_internal_server_error')
render action: 'new'
render action: 'edit'
end
end

Expand All @@ -82,10 +86,6 @@ def destroy
redirect_to attribute_help_texts_path(tab: @attribute_help_text.attribute_scope)
end

def index
@texts_by_type = AttributeHelpText.all_by_scope
end

protected

def require_ee_token
Expand Down
10 changes: 5 additions & 5 deletions app/controllers/auth_sources_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ def new
render 'auth_sources/new'
end

def edit
@auth_source = AuthSource.find(params[:id])
render 'auth_sources/edit'
end

def create
@auth_source = auth_source_class.new permitted_params.auth_source
if @auth_source.save
Expand All @@ -57,11 +62,6 @@ def create
end
end

def edit
@auth_source = AuthSource.find(params[:id])
render 'auth_sources/edit'
end

def update
@auth_source = AuthSource.find(params[:id])
updated = permitted_params.auth_source
Expand Down
14 changes: 7 additions & 7 deletions app/controllers/colors_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ def new
end
end

def edit
@color = Color.find(params[:id])
respond_to do |format|
format.html
end
end

def create
@color = Color.new(permitted_params.color)

Expand All @@ -65,13 +72,6 @@ def create
end
end

def edit
@color = Color.find(params[:id])
respond_to do |format|
format.html
end
end

def update
@color = Color.find(params[:id])

Expand Down
4 changes: 2 additions & 2 deletions app/controllers/concerns/accounts/user_password_change.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ def redirect_if_password_change_not_allowed(user)
def flash_error_message(log_reason: '', flash_now: true)
flash_hash = flash_now ? flash.now : flash

logger.warn "Failed login for '#{params[:username]}' from #{request.remote_ip}" \
" at #{Time.now.utc}: #{log_reason}"
logger.warn "Failed login for '#{params[:username]}' from #{request.remote_ip} " \
"at #{Time.now.utc}: #{log_reason}"

flash_message = yield

Expand Down
4 changes: 2 additions & 2 deletions app/controllers/custom_actions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ def new
@custom_action = CustomAction.new
end

def edit; end

def create
CustomActions::CreateService
.new(user: current_user)
.call(attributes: permitted_params.custom_action.to_h,
&index_or_render(:new))
end

def edit; end

def update
CustomActions::UpdateService
.new(action: @custom_action, user: current_user)
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/custom_fields_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ def new
end
end

def edit; end

def create
call = ::CustomFields::CreateService
.new(user: current_user)
Expand All @@ -66,8 +68,6 @@ def create
end
end

def edit; end

def update
perform_update(get_custom_field_params)
end
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/enumerations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ class EnumerationsController < ApplicationController

def index; end

def edit; end

def new
enum_class = enumeration_class(permitted_params.enumeration_type)
if enum_class
Expand All @@ -47,6 +45,8 @@ def new
end
end

def edit; end

def create
enum_params = permitted_params.enumerations
type = permitted_params.enumeration_type
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/errors_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class ErrorsController < ::ActionController::Base
class ErrorsController < ActionController::Base
include ErrorsHelper
include OpenProjectErrorHelper
include Accounts::CurrentUser
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/forums_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ def set_topics

def new; end

def edit; end

def create
if @forum.save
flash[:notice] = I18n.t(:notice_successful_create)
Expand All @@ -95,8 +97,6 @@ def create
end
end

def edit; end

def update
if @forum.update(permitted_params.forum)
flash[:notice] = I18n.t(:notice_successful_update)
Expand Down
14 changes: 7 additions & 7 deletions app/controllers/messages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ def new
.result
end

# Edit a message
def edit
return render_403 unless @message.editable_by?(User.current)

@message.attributes = permitted_params.message(@message)
end

# Create a new topic
def create
call = create_message(@forum)
Expand Down Expand Up @@ -97,13 +104,6 @@ def reply
redirect_to topic_path(@topic, r: @reply)
end

# Edit a message
def edit
return render_403 unless @message.editable_by?(User.current)

@message.attributes = permitted_params.message(@message)
end

# Edit a message
def update
# TODO: move into contract
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/news_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ def new
@news = News.new(project: @project, author: User.current)
end

def edit; end

def create
@news = News.new(project: @project, author: User.current)
@news.attributes = permitted_params.news
Expand All @@ -81,8 +83,6 @@ def create
end
end

def edit; end

def update
@news.attributes = permitted_params.news
if @news.save
Expand Down
8 changes: 4 additions & 4 deletions app/controllers/oauth/applications_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ def index
@applications = ::Doorkeeper::Application.without_integration.includes(:owner).all
end

def new; end

def edit; end

def show
@reveal_secret = flash[:reveal_secret]
flash.delete :reveal_secret
end

def new; end

def edit; end

def create
call = ::OAuth::PersistApplicationService.new(@application, user: current_user)
.call(permitted_params.oauth_application)
Expand Down
10 changes: 5 additions & 5 deletions app/controllers/placeholder_users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ def new
.result
end

def edit
@membership ||= Member.new
@individual_principal = @placeholder_user
end

def create
service = PlaceholderUsers::CreateService.new(user: User.current)
service_result = service.call(permitted_params.placeholder_user)
Expand All @@ -90,11 +95,6 @@ def create
end
end

def edit
@membership ||= Member.new
@individual_principal = @placeholder_user
end

def update
service_result = PlaceholderUsers::UpdateService
.new(user: User.current,
Expand Down
58 changes: 29 additions & 29 deletions app/controllers/repositories_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,29 @@ class RepositoriesController < ApplicationController

rescue_from OpenProject::SCM::Exceptions::SCMError, with: :show_error_command_failed

def update
@repository = @project.repository
update_repository(params.fetch(:repository, {}))
def show
if Setting.autofetch_changesets? && @path.blank?
@repository.fetch_changesets
@repository.update_required_storage
end

redirect_to project_settings_repository_path(@project)
@limit = Setting.repository_truncate_at
@entries = @repository.entries(@path, @rev, limit: @limit)
@changeset = @repository.find_changeset_by_name(@rev)

if request.xhr?
if @entries && @repository.valid?
render(partial: 'dir_list_content')
else
render(nothing: true)
end
elsif @entries.nil? && @repository.invalid?
show_error_not_found
else
@changesets = @repository.latest_changesets(@path, @rev)
@properties = @repository.properties(@path, @rev)
render action: 'show'
end
end

def create
Expand All @@ -71,6 +89,13 @@ def create
redirect_to project_settings_repository_path(@project)
end

def update
@repository = @project.repository
update_repository(params.fetch(:repository, {}))

redirect_to project_settings_repository_path(@project)
end

def committers
@committers = @repository.committers
@users = @project.users.to_a
Expand Down Expand Up @@ -105,31 +130,6 @@ def destroy
redirect_to project_settings_repository_path(@project)
end

def show
if Setting.autofetch_changesets? && @path.blank?
@repository.fetch_changesets
@repository.update_required_storage
end

@limit = Setting.repository_truncate_at
@entries = @repository.entries(@path, @rev, limit: @limit)
@changeset = @repository.find_changeset_by_name(@rev)

if request.xhr?
if @entries && @repository.valid?
render(partial: 'dir_list_content')
else
render(nothing: true)
end
elsif @entries.nil? && @repository.invalid?
show_error_not_found
else
@changesets = @repository.latest_changesets(@path, @rev)
@properties = @repository.properties(@path, @rev)
render action: 'show'
end
end

alias_method :browse, :show

def changes
Expand Down
Loading

0 comments on commit ca33ec3

Please sign in to comment.