rspec/rules/S1611/java/rule.adoc

46 lines
1.0 KiB
Plaintext

== Why is this an issue?
Lambda expressions with only one argument with an inferred type (i.e., no explicit type declaration) can be written without parentheses around that single parameter.
This syntax is simpler, more compact and readable than using parentheses and is therefore preferred.
This rule is automatically disabled when the project's `sonar.java.source` is lower than `8`, as lambda expressions were introduced in Java 8.
=== Noncompliant code example
[source,java,diff-id=1,diff-type=noncompliant]
----
(x) -> x * 2
----
=== Compliant solution
[source,java,diff-id=1,diff-type=compliant]
----
x -> x * 2
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Remove the parentheses around the "XXX" parameter. [(sonar.java.source not set. Assuming 8 or greater.)]
'''
== Comments And Links
(visible only on this page)
=== on 26 Feb 2014, 00:01:00 Freddy Mallet wrote:
Is implemented by \http://jira.codehaus.org/browse/SONARJAVA-464
endif::env-github,rspecator-view[]