isRegularFile in lambda/method reference

java
sonarlint

(Ewa Śliwińska) #1

I would like to ask about one thing which I don’t understand.
When I use

f -> Files.isRegularFile( f )

there is a major code smell that Java 8’s “Files.exists” should not be used (squid:S3725).

But when I replace it with

Files::isRegularFile

the warning disappears. Why is so?
Looks like some inconsistency, the same method is called.


(Nicolas Peru) #2

Thank you very much for the feedback : this is indeed inconsistent for that rule and this problem is very likely impacting other rules.

Ticket created to handle the issue : https://jira.sonarsource.com/browse/SONARJAVA-2925