We should always bulkify the code which collects all the records to be updated/inserted/deleted and it does once DML for all qualified records. We shouln't be making multiple same DMLs on the same object in the same contexts. Please check for existing DMLs if it is existing and can be reused.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
We should always bulkify the code which collects all the records to be updated/inserted/deleted and it does once DML for all qualified records. We shouln't be making multiple same DMLs on the same object in the same contexts. Please check for existing DMLs if it is existing and can be reused.
This sounds a bit like the rules AvoidDmlStatementsInLoops, AvoidSoqlInLoops and AvoidSoslInLoops. Those rules will be replaced by the new OperationsWithLimitsInLoops.
The difference is, that these rules only check the statements inside loops. You rule suggestion is a bit more generic I think.
Feel free to post the rule suggestion on https://github.com/pmd/pmd/issues . Thanks!
Hi Andreas,
I have raised an issue.below is the link available.Please check and let me know the solution
https://github.com/pmd/pmd/issues/2884
Thanks!