java sonar error List<T>" cannot contain a "Function"

93 views Asked by At

I have following code in java which is causing error in sonar.

The code is as :

 private Table sliceTable(Table table, String[] columns, Map<DependencyKey, List<F>> reportFields) {
    TableSliceGroup tableSlices = table.splitOn(columns);
    ListMultimap map = ArrayListMultimap.create();
    reportFields
            .entrySet()
            .stream()
            .filter(entry -> !entry.getKey().getDependencyType().equals(ReportingDependency.SELF) ||
                    !entry.getKey().getDependencyType().equals(ReportingDependency.SELF_WITH_CHECKPOINT))
            .flatMap(entry -> entry.getValue().stream().map(it -> Pair.of(entry.getKey().getDependencyType(), it)))
            .flatMap(pair -> pair.getRight().getDependencyDefinitions().stream().map(depDef -> Triple.of(pair.getLeft(), pair.getRight(), depDef)))
            .filter(triple -> triple.getRight().getClientName().equals(triple.getLeft()))
            .flatMap(triple -> triple.getRight().getFields().stream().map(it -> Triple.of(triple.getMiddle(), triple.getRight(), it)))
            .filter(triple -> TableUtils.containsColumn(table, triple.getMiddle().getClientName(),
                    triple.getRight()))     // This filters out the unresolved columns
            .forEach(triple -> {
                List<AggregateFunction<?, ?>> aggFuncList = map.get(TableUtils.getColumnNameFromTable(table,
                        triple.getMiddle().getClientName(), triple.getRight()));
                if (!aggFuncList.contains(
                        TableUtils.getAggregationFunction(
                                TableUtils.getColumnFromTable(table,
                                        triple.getMiddle().getClientName(),
                                        triple.getRight()).type(),
                                triple.getRight().getAggregation()))) {
                    map.put(TableUtils.getColumnNameFromTable(table, triple.getMiddle().getClientName(),
                            triple.getRight()),
                            TableUtils.getAggregationFunction(
                                    TableUtils.getColumnFromTable(table,
                                            triple.getMiddle().getClientName(),
                                            triple.getRight()).type(),
                                    triple.getRight().getAggregation()));
                }
            });

    Table slicedTable = TableSummarizer.aggregate(tableSlices, map, columns);
    return slicedTable;
}

sonar is giving error in this as on following line:

 if (!aggFuncList.contains(
                        TableUtils.getAggregationFunction(

A "List<AggregateFunction>" cannot contain a "SummarizingFunction".

can anyone please suggest whats missing in wrong here .

public abstract class SummarizingFunction<INCOL extends Column<?>, OUT>  {

private final String functionName;

/** Constructs a function with the given name */
public SummarizingFunction(String functionName) {
    this.functionName = functionName;
}

/** Returns this function's name */
public String functionName() {
    return functionName;
}

/** Apply this function to the column argument */
public abstract OUT summarize(INCOL column, int[] indices);

public String toString() {
    return functionName();
}

/** Returns the {@link ColumnType} to be used for the values returned by this function */
public abstract ColumnType returnType();

}

Thanks

0

There are 0 answers