chore: rubocop

chore: fix api test conventions

chore: rubocop -A spec/

chore: more rubocop -A

fix failing test

rubocop fixes

removes helper methods that are in my opinion dead code

more rubocop fixes

rubocop -a --auto-gen-config
This commit is contained in:
Philipp Rothmann 2023-05-12 13:01:12 +02:00 committed by Philipp Rothmann
parent f6fb804bbe
commit fb2b4d8a8a
331 changed files with 4263 additions and 4507 deletions

View file

@ -4,16 +4,16 @@ class DocumentsController < ApplicationController
before_action -> { require_plugin_enabled FoodsoftDocuments }
def index
if params["sort"]
sort = case params["sort"]
when "name" then "data IS NULL DESC, name"
when "created_at" then "created_at"
when "name_reverse" then "data IS NULL, name DESC"
when "created_at_reverse" then "created_at DESC"
sort = if params['sort']
case params['sort']
when 'name' then 'data IS NULL DESC, name'
when 'created_at' then 'created_at'
when 'name_reverse' then 'data IS NULL, name DESC'
when 'created_at_reverse' then 'created_at DESC'
end
else
sort = "data IS NULL DESC, name"
end
else
'data IS NULL DESC, name'
end
@documents = Document.where(parent: @document).page(params[:page]).per(@per_page).order(sort)
end
@ -34,22 +34,22 @@ class DocumentsController < ApplicationController
if @document.name.empty?
name = File.basename(data.original_filename)
@document.name = name.gsub(/[^\w\.\-]/, '_')
@document.name = name.gsub(/[^\w.-]/, '_')
end
end
@document.created_by = current_user
@document.save!
redirect_to @document.parent || documents_path, notice: t('.notice')
rescue => error
redirect_to @document.parent || documents_path, alert: t('.error', error: error.message)
rescue StandardError => e
redirect_to @document.parent || documents_path, alert: t('.error', error: e.message)
end
def update
@document = Document.find(params[:id])
@document.update_attribute(:parent_id, params[:parent_id])
redirect_to @document.parent || documents_path, notice: t('.notice')
rescue => error
redirect_to @document.parent || documents_path, alert: t('errors.general_msg', msg: error.message)
rescue StandardError => e
redirect_to @document.parent || documents_path, alert: t('errors.general_msg', msg: e.message)
end
def destroy
@ -60,8 +60,8 @@ class DocumentsController < ApplicationController
else
redirect_to documents_path, alert: t('.no_right')
end
rescue => error
redirect_to documents_path, alert: t('.error', error: error.message)
rescue StandardError => e
redirect_to documents_path, alert: t('.error', error: e.message)
end
def show