rspec/rules/S3740/java/rule.adoc
Fred Tingaud 16f6c0aecf
Inline adoc when include has no additional value (#1940)
Inline adoc files when they are included exactly once.

Also fix language tags because this inlining gives us better information
on what language the code is written in.
2023-05-25 14:18:12 +02:00

52 lines
963 B
Plaintext

== Why is this an issue?
Generic types shouldn't be used raw (without type parameters) in variable declarations or return values. Doing so bypasses generic type checking, and defers the catch of unsafe code to runtime.
=== Noncompliant code example
[source,java]
----
List myList; // Noncompliant
Set mySet; // Noncompliant
----
=== Compliant solution
[source,java]
----
List<String> myList;
Set<? extends Number> mySet;
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Provide the parametrised type for this generic.
=== Highlighting
type name
'''
== Comments And Links
(visible only on this page)
=== on 31 Oct 2018, 09:35:37 Nicolas Peru wrote:
\[~alexandre.gigleux] I would suggest title to be reworked to : Don't use raw types. The wording seems dodgy.
=== on 31 Oct 2018, 12:31:09 Ann Campbell wrote:
"Raw types should not be used"?
endif::env-github,rspecator-view[]