isRegularFile in lambda/method reference

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.

1 Like

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

3 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.