== Why is this an issue?

Java 8 adds ``++Comparator.comparing++`` to allow the creation of a single-value comparator to be shorthanded into a single call. This cleaner syntax should be preferred.


*Note* that this rule is automatically disabled when the project's ``++sonar.java.source++`` is lower than ``++8++``.


=== Noncompliant code example

[source,java]
----
Comparator<Foo> compartor = (foo1, foo2) -> foo.getName().compareTo(foo2.getName());  // Noncompliant
----


=== Compliant solution

[source,java]
----
Comparator<Foo> compartor = Comparator.comparing(Foo::getName);
----

ifdef::env-github,rspecator-view[]

'''
== Implementation Specification
(visible only on this page)

=== Message

Simplify this code with the use of "Comparator.comparing" instead.


=== Highlighting

the comparator definition


endif::env-github,rspecator-view[]
