rspec/rules/S2788/java/rule.adoc

31 lines
760 B
Plaintext
Raw Normal View History

2021-04-28 16:49:39 +02:00
Different formatters use different formatting symbols, and it can be easy to confuse one for the other. But get it wrong, and your output may be useless.
This rule logs an issue when the wrong type of format string is used for Guava, slf4j, logback or ``++MessageFormat++`` strings.
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 message = MessageFormat.format("Now is the %s %d all good people", "time", 4); // Noncompliant
----
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 message = MessageFormat.format("Now is the {1} {2} all good people", "time", 4); // Noncompliant
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::message.adoc[]
endif::env-github,rspecator-view[]