You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some people like to use the var keyword everywhere. Usually these people don't care about reviews.
Because it's always cool to read the following as a reviewer (without an IDE):
vardeliveryState = deliveryDao.find(...);
// dozens of lines of codedeliveryState.id(); // It's a DeliverState entityvarsendState = sendDao.find(...);
// dozens of lines of codesendState.isEmpty() // Surprise it's an Optional. // How can you tell without an IDE? // Answer: YOU CAN NOT!
Widespread usage of var effectively makes Code Reviews via Web UIs very hard.
var can be tolerated if it's used on very long Types descriptions (e.g. Map.Entry<MySuperCoolCacheKey, MySuperCoolValue> entry) with good variableNames however otherwise I see no reason why it should be used in the first place, because IDEs have automatic variable extraction capabilities that automatically extract the correct type:
The only problem there is how this could be supplied to PMD.
In Maven and Gradle it's quite doable because we can just link a compiled JAR.
However in IntelliJ this is more complex because the JAR will not be inside the repo and it's also a bit risky because a JAR can contain any code.
Did a team-internal discussion today and as far as I heard people concur with what I described in the issue.
One noteworthy exception that I also encounter and is described in OpenJDK's Local Variable Type Inference CSG (at the end), is when you are inside a try block.
If these were not AutoCloseables you would just move the subsequent method calls into each other e.g. new InputStreamReader(socket.getInputStream(), ...).
However this is so extremely rare that it can just be suppressed in such a case.
Activity
AB-xdev commentedon Nov 11, 2025
Okay so there is no way in doing this with CheckStyle because CheckStyle has no typing information.
It's not possible with PMD XPATH either because there is also no typing information available:

However it could be done with a custom PMD java rule.
PoC
The only problem there is how this could be supplied to PMD.
In Maven and Gradle it's quite doable because we can just link a compiled JAR.
However in IntelliJ this is more complex because the JAR will not be inside the repo and it's also a bit risky because a JAR can contain any code.
AB-xdev commentedon Jul 22, 2026
Did a team-internal discussion today and as far as I heard people concur with what I described in the issue.
One noteworthy exception that I also encounter and is described in OpenJDK's Local Variable Type Inference CSG (at the end), is when you are inside a try block.
If these were not
AutoCloseables you would just move the subsequent method calls into each other e.g.new InputStreamReader(socket.getInputStream(), ...).However this is so extremely rare that it can just be suppressed in such a case.
AB-xdev commentedon Aug 4, 2026
If the PR is not getting merged we can load it from our custom rules:
https://github.com/xdev-software/pmd-java-rules