When I run the APEX PMD, getting Design Error for the Below method.
ExcessiveParameterList Avoid long parameter lists.
Checked below link not able to solve this issue, Can anyone please help me on this.
https://pmd.github.io/latest/pmd_rules_apex_design.html#excessiveparameterlist
@AuraEnabled
public static boolean updatestudentProgramDiscount(Id recId, string discountType, decimal discountPercentage, string discountDetails) {
try{
students_Programs__c spt;
spt =[select Id from students_Programs__c where Id=:recId];
spt.Discount_Type__c = discountType;
spt.Discount__c = discountPercentage;
spt.Discount_Details__c = discountDetails;
Update spt;
return true;
}catch (Exception e) {
return false;
}
}
Best Answer
As the rule says, you have too many parameters. Consider passing in an entire record:
Note: You should use Security.stripInaccessible to prevent invalid field access. Note also using an exception thrown to trigger the "catch"/"error" handler on the client.