From 1d54018513b5c6263942c645c68b38a186bc115d Mon Sep 17 00:00:00 2001 From: Jennifer Vendetti Date: Thu, 15 Feb 2024 14:46:37 -0800 Subject: [PATCH] Fix some RuboCop warnings --- app/controllers/notes_controller.rb | 38 ++++++++++++++--------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/app/controllers/notes_controller.rb b/app/controllers/notes_controller.rb index ae7f30babd..875e3138e1 100644 --- a/app/controllers/notes_controller.rb +++ b/app/controllers/notes_controller.rb @@ -1,5 +1,6 @@ -class NotesController < ApplicationController +# frozen_string_literal: true +class NotesController < ApplicationController layout 'ontology' def show @@ -10,12 +11,12 @@ def show @ontology = (@note.explore.relatedOntology || []).first if request.xhr? - render :partial => 'thread' + render partial: 'thread' return end respond_to do |format| - format.html { render :template => 'notes/show' } + format.html { render template: 'notes/show' } end end @@ -33,12 +34,12 @@ def virtual_show elsif concept_id @notes = @ontology.explore.single_class(concept_id).explore.notes @note_link = "/notes/virtual/#{@ontology.ontologyId}/?noteid=" - render :partial => 'list', :layout => 'ontology' + render partial: 'list', layout: 'ontology' return else @notes = @ontology.explore.notes @note_link = "/notes/virtual/#{@ontology.ontologyId}/?noteid=" - render :partial => 'list', :layout => 'ontology' + render partial: 'list', layout: 'ontology' return end @@ -53,14 +54,14 @@ def virtual_show end def create - if params[:type].eql?("reply") + if params[:type].eql?('reply') note = LinkedData::Client::Models::Reply.new(values: note_params) - elsif params[:type].eql?("ontology") + elsif params[:type].eql?('ontology') params[:relatedOntology] = [params.delete(:parent)] note = LinkedData::Client::Models::Note.new(values: note_params) - elsif params[:type].eql?("class") + elsif params[:type].eql?('class') params[:relatedClass] = [params.delete(:parent)] - params[:relatedOntology] = params[:relatedClass].map {|c| c["ontology"]} + params[:relatedOntology] = params[:relatedClass].map { |c| c['ontology'] } note = LinkedData::Client::Models::Note.new(values: note_params) else note = LinkedData::Client::Models::Note.new(values: note_params) @@ -69,17 +70,17 @@ def create new_note = note.save if new_note.errors - render :json => new_note.errors, :status => 500 + render json: new_note.errors, status: 500 return end unless new_note.nil? - render :json => new_note.to_hash.to_json + render json: new_note.to_hash.to_json end end def destroy - note_ids = params[:noteids].kind_of?(String) ? params[:noteids].split(",") : params[:noteids] + note_ids = params[:noteids].kind_of?(String) ? params[:noteids].split(',') : params[:noteids] ontology = DataAccess.getOntology(params[:ontologyid]) @@ -88,7 +89,7 @@ def destroy note_ids.each do |note_id| begin result = DataAccess.deleteNote(note_id, ontology.ontologyId, params[:concept_id]) - raise Exception if !result.nil? && result["errorCode"] + raise Exception if !result.nil? && result['errorCode'] rescue Exception => e errors << note_id next @@ -96,27 +97,27 @@ def destroy successes << note_id end - render :json => { :success => successes, :error => errors } + render json: { success: successes, error: errors } end def archive ontology = DataAccess.getLatestOntology(params[:ontology_virtual_id]) unless ontology.admin?(session[:user]) - render :json => nil.to_json, :status => 500 + render json: nil.to_json, status: 500 return end @archive = DataAccess.archiveNote(params) unless @archive.nil? - render :json => @archive.to_json + render json: @archive.to_json end end def show_concept_list - params[:p] = "classes" - params[:t] = "notes" + params[:p] = 'classes' + params[:t] = 'notes' redirect_new_api end @@ -135,5 +136,4 @@ def clean_note_id(id) id = id.match(/\Ahttp:\/\w/) ? id.sub('http:/', 'http://') : id CGI.unescape(id) end - end