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
Is your feature request related to a problem? Please describe.
The rule UseExplicitTypes regarding the Java 10 type var has two properties, allowLiterals and allowCtors.
There are two other legitimate uses of var that I run into often, where the type is obvious:
explicit casts, and iteration over an Iterable whose type is explicit and apparent.
But PMD complains about these, and cramps my style.
Direct cast is still a reasonable construct:
// direct cast
var other = (MyClass<E>)obj;
An iteration over a Collection whose type is immediately apparent:
method( List<E> list) {
for( var e : list ) {
...
}
}
Generally, iteration over an explicitly-typed Iterable:
method( Iterable<E> it) {
for( var e : it ) {
...
}
}
Describe the solution you'd like
For the rule UseExplicitTypes,
A property allowExplicitCasts, to allow var in the first situation.
A property allowExplicitIterables to allow var in the second situation.
Describe alternatives you've considered
The exact property names aren't important. Those were the best I came up with.
Additional context
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
The rule
UseExplicitTypes
regarding the Java 10 typevar
has two properties,allowLiterals
andallowCtors
.There are two other legitimate uses of
var
that I run into often, where the type is obvious:explicit casts, and iteration over an Iterable whose type is explicit and apparent.
But PMD complains about these, and cramps my style.
Direct cast is still a reasonable construct:
An iteration over a Collection whose type is immediately apparent:
Generally, iteration over an explicitly-typed Iterable:
Describe the solution you'd like
For the rule
UseExplicitTypes
,Describe alternatives you've considered
The exact property names aren't important. Those were the best I came up with.
Additional context
The text was updated successfully, but these errors were encountered: