Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the following code analysis mean?

I have an object instantiated like the following 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;
    }

The 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 says the following about recursive calls. Basically I didn't understand the meaning. Can anyone elaborate to help me understand?

Problem synopsis

Constructor has usage(s) but they all belong to recursive calls chain that has no members reachable from entry points.   

Problem resolution

  1. Safe delete
  2. Comment out
  3. Add as Entry Point
like image 898
phoenix Avatar asked Sep 28 '22 00:09

phoenix


1 Answers

This is a warning from the Unused declaration inspection. IntelliJ IDEA thinks the constructor is not reachable from any entry points. The constructor is not unused however, but the usages are themselves unreachable.

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

like image 56
Bas Leijdekkers Avatar answered Oct 05 '22 06:10

Bas Leijdekkers