Hi,
There was no intention to modify the original. I was using the “java-symbolic-execution-plugin” directory from the “sonar-java” repository.
I was trying to avoid false positives with rule S2259. In the post I shared, I understood that it was possible to declare the behavior of my code and thus prevent issues from being raised in those specific cases using this custom plugin.
This use case is very specify and I don’t believe that it would be relevant for other users.
I’m working with a legacy Java codebase where it use a custom utility method called CommonFunctionsHLP.vacio(Object) that has multi-purpose logic: it serves as a generic check for “null or empty” values across a wide range of types (e.g., String, Integer, Collection, EntidadVO, etc.) and there are indirect call to user-defined methods. The method is defined like this:
public static boolean vacio(Object value) {
return vacio(value, Boolean.FALSE);
}
public static boolean vacio(Object value, Boolean onlyNull) {
if (value == null) return true;
// More logic for other types...
}
In many places throughout the codebase (hundreds, actually), we do things like:
if (!CommonFunctionsHLP.vacio(dbh)) {
dbh.close();
}
Because this is a large legacy system with hundreds of such checks, updating all usages would be time-consuming and error-prone. That’s reason I tried to modify the behavior of the rule.
We’re developing a new version of our symbolic execution engine, which includes an updated S2259 (Null check) rule, now identified as S6555. This enhanced rule analyzes the entire project and isn’t yet active in the default profile. I believe it could resolve your issue without requiring custom behavior.
While this new rule isn’t available in the SonarQube Community Build, you can test it out using the free edition of SonarQube Cloud.