4

I have findebug which check find bug in one case and dont fing in another, and i completely do not understand how its connected.

So i encounter this RV_RETURN_VALUE_IGNORED_NO_SIDE_EFFECT and started to try different code, and found variant which fix this warning but it looks totaly unconnected to reported problem.

This code DOES generate RV_RETURN_VALUE_IGNORED_NO_SIDE_EFFECT

        final Node currentProjectNode = TripleUtil.createNode(projectId);

        final ParameterizedSparqlString pQuery = new ParameterizedSparqlString();
        pQuery.setNsPrefix(TripleUtil.NS_PREFIX, TripleUtil.NS);

And this code NOT generate bug

        final Node currentProjectNode = TripleUtil.createNode(projectId);
        final PrefixMappingImpl prefixMapping = new PrefixMappingImpl();
        prefixMapping.setNsPrefix(TripleUtil.NS_PREFIX, TripleUtil.NS);
        final ParameterizedSparqlString pQuery = new ParameterizedSparqlString();
        pQuery.setNsPrefix(TripleUtil.NS_PREFIX, TripleUtil.NS);

As you can see i just instantiate class and then use its method and thats all, i didnt change code which generate bug, i didnt change method which generate bug. It looks like in first sample findbug just cant find proper implementation or something, but i dont understand why? It should not be reported after all because prefixMapping.setNsPrefix do some job not just return value.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Wizzard
  • 345
  • 3
  • 13

1 Answers1

0

When the call to a function doesn’t have any side effects, what is the point of making the call if the results are ignored? In such case, either the function call is useless and should be dropped or the source code doesn’t behave as expected.

Some operation needs to perform after setting up the value for prefixMapping.