rspec/rules/S5663/java/rule.adoc

36 lines
720 B
Plaintext
Raw Normal View History

2021-04-28 16:49:39 +02:00
If a string fits on a single line, without concatenation and escaped newlines, you should probably continue to use a string literal.
2021-04-28 16:49:39 +02:00
== Noncompliant Code Example
2022-02-04 17:28:24 +01:00
[source,java]
2021-04-28 16:49:39 +02:00
----
String question = """
What's the point, really?""";
----
2021-04-28 16:49:39 +02:00
== Compliant Solution
2022-02-04 17:28:24 +01:00
[source,java]
2021-04-28 16:49:39 +02:00
----
String question = "What's the point, really?";
----
2021-04-28 16:49:39 +02:00
== See
* https://openjdk.java.net/jeps/378[JEP 378: Text Blocks]
* https://cr.openjdk.java.net/~jlaskey/Strings/TextBlocksGuide_v9.html[Programmer's Guide To Text Blocks], by Jim Laskey and Stuart Marks
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::message.adoc[]
endif::env-github,rspecator-view[]