OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Remove instance variables in error helper and lint
Oliver Günther7e6a923790fc
diff --git a/app/helpers/errors_helper.rb b/app/helpers/errors_helper.rbindex a41b5fb2101..507828b3fc9 100644--- a/app/helpers/errors_helper.rb+++ b/app/helpers/errors_helper.rb@@ -27,34 +27,34 @@#++module ErrorsHelper- def render_400(options = {})- @project = nil+ def render_400(options = {}) # rubocop:disable Naming/VariableNumber+ unset_template_magicrender_error({ message: :notice_bad_request, status: 400 }.merge(options))falseend- def render_403(options = {})- @project = nil+ def render_403(options = {}) # rubocop:disable Naming/VariableNumber+ unset_template_magicrender_error({ message: :notice_not_authorized, status: 403 }.merge(options))falseend- def render_404(options = {})+ def render_404(options = {}) # rubocop:disable Naming/VariableNumberrender_error({ message: :notice_file_not_found, status: 404 }.merge(options))falseend- def render_500(options = {})- message = t(:notice_internal_server_error, app_title: Setting.app_title)-+ def render_500(options = {}) # rubocop:disable Naming/VariableNumberunset_template_magic+ message = t(:notice_internal_server_error, app_title: Setting.app_title)+# Append error informationif current_user.admin?options[:message_details] = get_additional_messageend- render_error({ message: }.merge(options))+ render_error({ message:, status: 500 }.merge(options))falseend@@ -80,39 +80,34 @@ module ErrorsHelperend# Renders an error response- def render_error(arg)+ def render_error(arg) # rubocop:disable Metrics/AbcSizearg = { message: arg } unless arg.is_a?(Hash)- @status = arg[:status] || 500- @message = arg[:message]+ status = arg[:status] || 500+ message = arg[:message]- if @status >= 500- op_handle_error(arg[:exception] || "[Error #@status] #@message", payload: arg[:payload])+ if status >= 500+ op_handle_error(arg[:exception] || "[Error #status] #message", payload: arg[:payload])end- @message = I18n.t(@message) if @message.is_a?(Symbol)- @message_details = arg[:message_details]+ message = I18n.t(message) if message.is_a?(Symbol)+ message_details = arg[:message_details]respond_to do |format|format.html do- error_message = "[#{I18n.t(:error_code, code: @status)}] #{@message}\n#{@message_details}"+ error_message = "[#{I18n.t(:error_code, code: status)}] #{message}\n#{message_details}"flash.now[:op_primer_flash] = { scheme: :danger, message: error_message, dismiss_scheme: :none }- render template: "common/error", layout: use_layout, status: @status+ render template: "common/error",+ layout: use_layout,+ status:,+ locals: { status:, params: }endformat.any do- head @status+ head statusendendenddef unset_template_magic- if $ERROR_INFO.is_a?(ActionView::ActionViewError)- @template.instance_variable_set(:@project, nil)- @template.instance_variable_set(:@status, 500)- @template.instance_variable_set(:@message, message)- else- @project = nil- end- rescue StandardError- # bad luck+ @project = nil # rubocop:disable Rails/HelperInstanceVariableendenddiff --git a/app/views/common/error.html.erb b/app/views/common/error.html.erbindex 85f38b27a71..ea265ef425a 100644--- a/app/views/common/error.html.erb+++ b/app/views/common/error.html.erb@@ -29,4 +29,4 @@ See COPYRIGHT and LICENSE files for more details.<%= call_hook(:view_common_error_details, { params: params, project: ((defined? @project) ? @project : nil) }) %>-<% html_title h(@status) %>+<% html_title h(status) %>