function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
JaiJai 

Please help me on below code scan issue

The method ticketdetails() has an NPath complexity of 325
@AuraEnabled should have proper error handling


please help me to remidiate these code scan issues please

@auraEnabled
   public static String ticketdetails (String id){
       //System.debug('ticketdetails method calling'+id);
       Case c = new Case ();
       String s1 = String.valueof(Id);
       Patient__c p1=new Patient__c();
       Id conid;
        if(Schema.sObjectType.Case.isAccessible() && s1.startsWith('500')){
          c=[Select id,ContactId from Case where id=:id];
          conid=c.ContactId;
        }
        if(Schema.sObjectType.Patient__c.isAccessible() && s1.startsWith('a02')){
           p1=[Select id,Contact__c from Patient__c where id=:id];
           conid=p1.Contact__c;
        }
       if(Contact.sObjectType.getDescribe().isAccessible() && s1.startsWith('003')){
           conid=id;
       }
       if(Account.sObjectType.getDescribe().isAccessible() && s1.startsWith('001')){
           Contact c2=[select id from Contact where accountid=:id order by createddate desc LIMIT 1];
           conid=c2.id;
       }  
       if (c.ContactId!=null || p1.Contact__c!=null || conid!=null){
           return conid; 
       }
       return null;
   }

Thanks!!
PriyaPriya (Salesforce Developers) 
Hi Jai,

Can you elaborate what is Scan Issue ?

Thanks