rspec/rules/S3677/java/rule.adoc

42 lines
648 B
Plaintext
Raw Normal View History

== Why is this an issue?
2021-04-28 16:49:39 +02:00
Using a type parameter when you don't have to simply obfuscates the code. Qualifying an inner type with a type parameter will compile, but confuse maintainers.
=== Noncompliant code example
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,java]
2021-04-28 16:49:39 +02:00
----
<T extends Map> T doTheThing(T.Entry type) { // Noncompliant
//...
}
----
=== Compliant solution
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,java]
2021-04-28 16:49:39 +02:00
----
<T extends Map> T doTheThing(Map.Entry type) {
//...
}
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Use "xxx" here instead of "y".
=== Highlighting
Unnecessary type param
endif::env-github,rspecator-view[]