Example below class -
`package sonar.autofix;
import java.util.List;
public class CollectionIsEmpty {
public void check(List<String> myList){
if(myList.size() > 0){
System.out.println("My List is not Empty.");
}
if(myList.size() <= 0){
System.out.println("My List is Empty.");
}
if(myList.size() == 0){
System.out.println("My List is Empty.");
}
}
}
`
Run -
walkmod apply sonar:UseCollectionIsEmpty
After modification first "if-block" is expected to be changed to "!list.isEmpty()" (not operator is missing)
`package sonar.autofix;
import java.util.List;
public class CollectionIsEmpty {
public void check(List<String> myList){
if(myList.isEmpty()){
System.out.println("My List is not Empty.");
}
if(myList.size() <= 0){
System.out.println("My List is Empty.");
}
if(myList.isEmpty()){
System.out.println("My List is Empty.");
}
}
}
`