=== On 2019-07-05T17:35:38Z Nicolas Harraudeau Wrote:
If the rule raise false positives one possible exception is:


== Exceptions

No issue will be raised when the DML statement is executed on a collection returned by a for loop. In this case the for loop already executed the DML statement in bulk.


----
public class myDMLLoop {
    public static void myFunction() {
        for (Task[] task: [Select Id, subject from Task]) { // Ok. The SOQL query is processing a batch of Tasks instead of a single one
        	task.subject = task.subject + ' processed';
        	update task; // This update a batch of Tasks
        }
        for (List<Task> tasks: [Select Id, subject from Task]) { // Same here
            for (Task task: tasks) {
        		task.subject = task.subject + ' processed';
            }
            update tasks;
         }
    }
}
----

