Possible false positive for java:S2175 when using generics

Problem Description

We are getting a java:S2175 “Inappropriate “Collection” calls should not be made” bug raised for something which does not seem to be a bug (at least to us).


where the the types are using generics: List<T> completeListOfElements and final T lastFilteredElement.

Expected Behaviour

This should not raise the rule java:S2175

Used Version

We are running on SonarCloud.

Additional Info

As we are runniong on sonarcloud I would hope you can hop on our project and take a look there, that’s why I did not create a minimized ready to run example. Also, because I highly suspect it is something specific about our code that raises this bug, because I guess simply using indexOf on gen erics is done often enough that a very simple case would already have been detected.

This seems to me to be related or at least similar to Possible false postive for java:S2175 while using generic wrapping class, but there the problem seems to have simply vanished.