Check that spans multiple java class


Can you please let me know if there is way to write a check when it spans across java classes.

For Example: we want to check if there is DB call made in loop, in the below the call from first class is made to a second class. So we want to check if helper method is a call to DB. Is is possible to write a rule for this scenario? Can you please point me to custom rule that checks across class files.

public class First {
  public void method1(){
       Second secRef = new Second();
       List<String> res = new ArrayList<>();

       for(int i=0;i<n;i++){

public class Second{
  public String helper(int i){
        //      call database
        String result;
        result = DAO.callSQL(i);
        return result;


Hello @sachin.desai7 ,

Thanks for your patience!

Unfortunately, we do not support this use-case for custom rules, so you won’t be able to find custom rules trying to do that. FYI, the risk in trying to implement such a rule is that if you store elements from the AST within the rule implementation class, you might face huge memory leaks. Storing an element from a tree, whatever it is, forces the analyzer to keep in memory the whole structure (AST+semantic layer).


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.