From 653d03b1d5f7c78394cbabd683e45fed7c5e363b Mon Sep 17 00:00:00 2001 From: Stuart McHattie Date: Mon, 16 Dec 2024 11:46:18 +0000 Subject: [PATCH] Fix Rubocop issues --- app/controllers/api/v2/qc_files_controller.rb | 8 ++++---- app/controllers/api/v2/tag_layouts_controller.rb | 9 ++++----- app/controllers/api/v2/transfers_controller.rb | 2 +- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/app/controllers/api/v2/qc_files_controller.rb b/app/controllers/api/v2/qc_files_controller.rb index 81f6443ddf..22c475b04f 100644 --- a/app/controllers/api/v2/qc_files_controller.rb +++ b/app/controllers/api/v2/qc_files_controller.rb @@ -15,21 +15,21 @@ class QcFileProcessor < JSONAPI::Processor private def prepare_temporary_file - filename, contents = get_required_attributes + filename, contents = required_attributes tempfile = create_temporary_file(filename, contents) context.merge!(filename:, tempfile:) end # Validate that attributes contains both the filename and the contents of the QcFile. - def get_required_attributes + def required_attributes attributes = params[:data][:attributes] filename = attributes[:filename] - raise JSONAPI::Exceptions::ParameterMissing.new('filename') if filename.nil? + raise JSONAPI::Exceptions::ParameterMissing, 'filename' if filename.nil? contents = attributes[:contents] - raise JSONAPI::Exceptions::ParameterMissing.new('contents') if contents.nil? + raise JSONAPI::Exceptions::ParameterMissing, 'contents' if contents.nil? [filename, contents] end diff --git a/app/controllers/api/v2/tag_layouts_controller.rb b/app/controllers/api/v2/tag_layouts_controller.rb index 6e76e1d20c..ca41e0525c 100644 --- a/app/controllers/api/v2/tag_layouts_controller.rb +++ b/app/controllers/api/v2/tag_layouts_controller.rb @@ -37,11 +37,10 @@ def find_template end def raise_if_key_present(data, key) - unless data[key.to_sym].blank? - raise JSONAPI::Exceptions::BadRequest.new( - "Cannot provide '#{key}' while also providing 'tag_layout_template_uuid'." - ) - end + return if data[key.to_sym].blank? + + raise JSONAPI::Exceptions::BadRequest, + "Cannot provide '#{key}' while also providing 'tag_layout_template_uuid'." end def merge_template_attributes(template) diff --git a/app/controllers/api/v2/transfers_controller.rb b/app/controllers/api/v2/transfers_controller.rb index 12f9614a60..8c135f0e15 100644 --- a/app/controllers/api/v2/transfers_controller.rb +++ b/app/controllers/api/v2/transfers_controller.rb @@ -19,7 +19,7 @@ class TransferProcessor < JSONAPI::Processor def extract_template_data attributes = params[:data][:attributes] template_uuid = attributes[:transfer_template_uuid] - raise JSONAPI::Exceptions::ParameterMissing.new('transfer_template_uuid') if template_uuid.nil? + raise JSONAPI::Exceptions::ParameterMissing, 'transfer_template_uuid' if template_uuid.nil? template = TransferTemplate.with_uuid(template_uuid).first raise JSONAPI::Exceptions::InvalidFieldValue.new('transfer_template_uuid', template_uuid) if template.nil?