What does the following code analysis mean?

I have an object created in the way shown below in only one place in my code (AggregateFunctions).

    private String selectColumns() {
        String query = "SELECT ";

        if (this.distinctResults) {
            query = query + "DISTINCT ";
        }

        SelectColumn selectColumn = new SelectColumn(this);

        if (!this.applyAggregation) {
            for (Object object : this.columns) {
                query = selectColumn.selectColumn(query, object);
            }
        } else {
            AggregateFunctions aggregateFunctions = new AggregateFunctions(this);
            query = query + aggregateFunctions.select();
        }
        //Remove extra ', '
        query = query.substring(0, query.length() - 2) + " FROM ";
        return query;
    }

      

Constructors:

    public AggregateFunctions(@NotNull SqlQueryGenerator sqlQueryGenerator) {
        this.spaceEncloser = sqlQueryGenerator.getSpaceEncloser();
        this.selectColumn = new SelectColumn(sqlQueryGenerator);
        JSONObject formData = sqlQueryGenerator.getFormData();
        this.columns = formData.getJSONArray("columns");
        this.aggregateJson = formData.getJSONObject("functions").getJSONArray("aggregate");
        this.aggregatesList = new ArrayList<Aggregate>();
        prepareAggregates();
        this.query = new StringBuilder();
    }

    public SelectColumn(SqlQueryGenerator sqlQueryGenerator) {
        this.sqlQueryGenerator = sqlQueryGenerator;
    }

      

But IntelliJ Code Analysis talks about recursive calls. Basically, I didn't understand the meaning. Can anyone elaborate to help me understand?

Summary of the problem

The constructor has use (s), but they all belong to a recursive call chain that has no elements reachable from entry points.

Troubleshooting

  • Safe removal
  • A comment
  • Add as entry point
+3


source to share


2 answers


This is a warning from checking an unused ad. IntelliJ IDEA thinks the constructor is not available from any entry points. However, the constructor is not used, but not available by itself.



If this is not the case for your code, it might be a bug in IntelliJ IDEA.

+3


source


Probably in the AggregateFunctions constructor in the code you are calling, go back to the selectColumns () method in another class. This way the recursion will never end.

I'm guessing either here

 JSONObject formData = sqlQueryGenerator.getFormData();

      

Or somewhere here:



 this.selectColumn = new SelectColumn(sqlQueryGenerator);

      

You go to the previous class and the same method that creates the new collection and the loop is executed.

You call AggregateFunction with this - it's the same object. But then in the constructor you call the methods of that. Check out these methods, and if any of them have a different AggregateFunction object creation - there is your problem.

0


source







All Articles