Add description
This commit is contained in:
parent
e0e4d95f54
commit
10634b11f7
@ -1,44 +1,32 @@
|
|||||||
FIXME: add a description
|
|
||||||
|
|
||||||
// If you want to factorize the description uncomment the following line and create the file.
|
|
||||||
//include::../description.adoc[]
|
|
||||||
|
|
||||||
== Why is this an issue?
|
== Why is this an issue?
|
||||||
|
|
||||||
FIXME: remove the unused optional headers (that are commented out)
|
Library authors often design APIs to be versatile, enabling them to handle diverse scenarios. Consequently, when we provide a lambda expression as an argument to a library function, we may find ourselves with unused arguments. Naming these arguments can contribute to unnecessary code expansion and diminish readability. Furthermore, it obscures the crucial fact that the argument is intentionally unused. To resolve this and clearly indicate the intent, unused arguments should be denoted with an underscore `_`, a feature introduced in Java 22.
|
||||||
|
|
||||||
//=== What is the potential impact?
|
|
||||||
|
|
||||||
== How to fix it
|
== How to fix it
|
||||||
//== How to fix it in FRAMEWORK NAME
|
|
||||||
|
|
||||||
=== Code examples
|
=== Code examples
|
||||||
|
|
||||||
==== Noncompliant code example
|
==== Noncompliant code example
|
||||||
|
|
||||||
[source,java,diff-id=1,diff-type=noncompliant]
|
[source,java,diff-id=1,diff-type=noncompliant]
|
||||||
----
|
----
|
||||||
FIXME
|
BiFunction<Integer,Integer,Integer> f = (a, b) -> a; // Noncompliant
|
||||||
|
|
||||||
|
// ...
|
||||||
|
|
||||||
|
firstValueMap.merge(event.id, event.value, (oldValue, newValue) -> oldValue); // Noncompliant
|
||||||
----
|
----
|
||||||
|
|
||||||
==== Compliant solution
|
==== Compliant solution
|
||||||
|
|
||||||
[source,java,diff-id=1,diff-type=compliant]
|
[source,java,diff-id=1,diff-type=compliant]
|
||||||
----
|
----
|
||||||
FIXME
|
BiFunction<Integer,Integer,Integer> f2 = (a, _) -> a;
|
||||||
|
|
||||||
|
// ...
|
||||||
|
|
||||||
|
firstValueMap.merge(event.id, event.value, (oldValue, _) -> oldValue);
|
||||||
----
|
----
|
||||||
|
|
||||||
//=== How does this work?
|
== Resources
|
||||||
|
=== Documentation
|
||||||
|
|
||||||
//=== Pitfalls
|
* Java Language Updates - https://docs.oracle.com/en/java/javase/22/language/unnamed-variables-and-patterns.html[Unnamed Variables and Patterns]
|
||||||
|
|
||||||
//=== Going the extra mile
|
|
||||||
|
|
||||||
|
|
||||||
//== Resources
|
|
||||||
//=== Documentation
|
|
||||||
//=== Articles & blog posts
|
|
||||||
//=== Conference presentations
|
|
||||||
//=== Standards
|
|
||||||
//=== External coding guidelines
|
|
||||||
//=== Benchmarks
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user