rspec/rules/S1153/java/rule.adoc
2023-06-09 16:36:32 +02:00

60 lines
1.3 KiB
Plaintext

== Why is this an issue?
Appending `String.valueOf()` to a `String` decreases the code readability.
The argument passed to `String.valueOf()` should be directly appended instead.
=== Noncompliant code example
[source,java,diff-id=1,diff-type=noncompliant]
----
String message = "Output is " + String.valueOf(12);
----
=== Compliant solution
[source,java,diff-id=1,diff-type=compliant]
----
String message = "Output is " + 12;
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Directly append the argument of String.valueOf().
'''
== Comments And Links
(visible only on this page)
=== on 16 Aug 2013, 12:51:37 Dinesh Bolkensteyn wrote:
\[~ann.campbell.2] I though you didn't like 'source code' ... but here it is "and decreases the readability of the source code" ;-)
=== on 16 Aug 2013, 14:30:04 Dinesh Bolkensteyn wrote:
The deprecatied rule covered also this case AFAIK:
----
String a = String.valueOf("foo");
----
which will not be covered by this rule.
=== on 16 Aug 2013, 15:20:24 Dinesh Bolkensteyn wrote:
Implemented by \http://jira.codehaus.org/browse/SONARJAVA-241
=== on 17 Aug 2013, 15:54:50 Ann Campbell wrote:
I don't [~dinesh.bolkensteyn]], but without a list of rules, I try to conform to what appears to be the established standard. :-)
endif::env-github,rspecator-view[]