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 issue

The method 'getChartMap' has a Cyclomatic Complexity of 16.
Please help me to remidiate this code scan issue?

public static List<Case> getChartMap(String id){
       //System.debug('getChartMap'+id);
       case c1= new case();
       String s1 = String.valueof(Id);
       Id conid;
       Patient__c p1=new Patient__c();
       List<Case> cList= new List<Case>();
       if(case.sObjectType.getDescribe().isAccessible() && s1.startsWith('500')){
           c1=[select id,RecordType.Name,ContactId,Status from case where id=:id];
           conid=c1.ContactId;//Added for SFSVC-145 Service Console UI Enhancements Patient
       }
       if(Patient__c.sObjectType.getDescribe().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(Opportunity.sObjectType.getDescribe().isAccessible() && s1.startsWith('006')){
           opportunity opp1 = [select id,Contact__c from opportunity where id=:id];
           conid = opp1.Contact__c;
       }
       if((c1.ContactId!=null || p1.Contact__c!=null || conid!=null) && case.sObjectType.getDescribe().isAccessible()){
           cList=[select id,CaseNumber,BusinessHoursId,CreatedDate,RecordType.Name,ContactId,Status,Symptom_Code__c from case where ContactId=:conid and Status!='Closed' and Status!='Approved' and Status!='Rejected' order by createddate desc LIMIT 5];
       }
       return cList;
   }

Thanks!!
AnkaiahAnkaiah (Salesforce Developers) 
Hi Jai,

What is the issue and which line you were getting an error.?

Thanks!!