Checkstyle Java 11 false positives.

Hi, just found out that checkstyle is not completely aware of Java 11 features. Completely valid syntax e.g. "var attachmentsToRemove = new HashSet<Guid>();" is marked with error: "DiamondOperator: Diamond operator should be used" What can we do about this? Thanks. Regards, Ales -- Ales Musil Associate Software Engineer - RHV Network Red Hat EMEA <https://www.redhat.com> amusil@redhat.com IM: amusil <https://red.ht/sig>

On Mon, Oct 14, 2019 at 9:49 AM Ales Musil <amusil@redhat.com> wrote:
Hi, just found out that checkstyle is not completely aware of Java 11 features. Completely valid syntax e.g. "var attachmentsToRemove = new HashSet<Guid>();"
We are using custom DiamongOperator check style: https://github.com/oVirt/ovirt-engine/blob/master/build-tools-root/ovirt-che... I think more correct usage is: Set<Guid> attachmentsToRemove = new HashSet<>(); Does check style complain if you change to above? is marked with error: "DiamondOperator: Diamond operator should be used"
What can we do about this?
Thanks. Regards, Ales
--
Ales Musil
Associate Software Engineer - RHV Network
Red Hat EMEA <https://www.redhat.com>
amusil@redhat.com IM: amusil <https://red.ht/sig> _______________________________________________ Devel mailing list -- devel@ovirt.org To unsubscribe send an email to devel-leave@ovirt.org Privacy Statement: https://www.ovirt.org/site/privacy-policy/ oVirt Code of Conduct: https://www.ovirt.org/community/about/community-guidelines/ List Archives: https://lists.ovirt.org/archives/list/devel@ovirt.org/message/GA3QZK7IHFMGLN...
-- Martin Perina Manager, Software Engineering Red Hat Czech s.r.o.

I think more correct usage is:
Set<Guid> attachmentsToRemove = new HashSet<>();
Well, for something that survives long enough yes. But `var` is a new Java 10 feature that is totally valid. See for example here: https://www.baeldung.com/java-10-local-variable-type-inference Martin On Mon, Oct 14, 2019 at 4:11 PM Martin Perina <mperina@redhat.com> wrote:
On Mon, Oct 14, 2019 at 9:49 AM Ales Musil <amusil@redhat.com> wrote:
Hi, just found out that checkstyle is not completely aware of Java 11 features. Completely valid syntax e.g. "var attachmentsToRemove = new HashSet<Guid>();"
We are using custom DiamongOperator check style:
https://github.com/oVirt/ovirt-engine/blob/master/build-tools-root/ovirt-che...
I think more correct usage is:
Set<Guid> attachmentsToRemove = new HashSet<>();
Does check style complain if you change to above?
is marked with error: "DiamondOperator: Diamond operator should be used"
What can we do about this?
Thanks. Regards, Ales
--
Ales Musil
Associate Software Engineer - RHV Network
Red Hat EMEA
amusil@redhat.com IM: amusil
_______________________________________________ Devel mailing list -- devel@ovirt.org To unsubscribe send an email to devel-leave@ovirt.org Privacy Statement: https://www.ovirt.org/site/privacy-policy/ oVirt Code of Conduct: https://www.ovirt.org/community/about/community-guidelines/ List Archives: https://lists.ovirt.org/archives/list/devel@ovirt.org/message/GA3QZK7IHFMGLN...
-- Martin Perina Manager, Software Engineering Red Hat Czech s.r.o. _______________________________________________ Devel mailing list -- devel@ovirt.org To unsubscribe send an email to devel-leave@ovirt.org Privacy Statement: https://www.ovirt.org/site/privacy-policy/ oVirt Code of Conduct: https://www.ovirt.org/community/about/community-guidelines/ List Archives: https://lists.ovirt.org/archives/list/devel@ovirt.org/message/WXKMNDI6QM6ADD...

On Mon, Oct 14, 2019 at 4:14 PM Martin Sivak <msivak@redhat.com> wrote:
I think more correct usage is:
Set<Guid> attachmentsToRemove = new HashSet<>();
Well, for something that survives long enough yes. But `var` is a new Java 10 feature that is totally valid. See for example here:
https://www.baeldung.com/java-10-local-variable-type-inference
So that's definitely not supported by current diamond check, but feel free to post a patch which will allow this feature :-)
Martin
On Mon, Oct 14, 2019 at 4:11 PM Martin Perina <mperina@redhat.com> wrote:
On Mon, Oct 14, 2019 at 9:49 AM Ales Musil <amusil@redhat.com> wrote:
Hi, just found out that checkstyle is not completely aware of Java 11
features.
Completely valid syntax e.g. "var attachmentsToRemove = new HashSet<Guid>();"
We are using custom DiamongOperator check style:
https://github.com/oVirt/ovirt-engine/blob/master/build-tools-root/ovirt-che...
I think more correct usage is:
Set<Guid> attachmentsToRemove = new HashSet<>();
Does check style complain if you change to above?
is marked with error: "DiamondOperator: Diamond operator should be used"
What can we do about this?
Thanks. Regards, Ales
--
Ales Musil
Associate Software Engineer - RHV Network
Red Hat EMEA
amusil@redhat.com IM: amusil
_______________________________________________ Devel mailing list -- devel@ovirt.org To unsubscribe send an email to devel-leave@ovirt.org Privacy Statement: https://www.ovirt.org/site/privacy-policy/ oVirt Code of Conduct:
https://www.ovirt.org/community/about/community-guidelines/
List Archives: https://lists.ovirt.org/archives/list/devel@ovirt.org/message/GA3QZK7IHFMGLN...
-- Martin Perina Manager, Software Engineering Red Hat Czech s.r.o. _______________________________________________ Devel mailing list -- devel@ovirt.org To unsubscribe send an email to devel-leave@ovirt.org Privacy Statement: https://www.ovirt.org/site/privacy-policy/ oVirt Code of Conduct: https://www.ovirt.org/community/about/community-guidelines/ List Archives: https://lists.ovirt.org/archives/list/devel@ovirt.org/message/WXKMNDI6QM6ADD...
-- Martin Perina Manager, Software Engineering Red Hat Czech s.r.o.
participants (3)
-
Ales Musil
-
Martin Perina
-
Martin Sivak