diff options
author | Tor Norbye <tnorbye@google.com> | 2013-04-24 10:43:41 -0700 |
---|---|---|
committer | Tor Norbye <tnorbye@google.com> | 2013-04-24 10:43:41 -0700 |
commit | b17587c84879dd2ea42495f1fbdadbc806b9475b (patch) | |
tree | b4d9014f69cb8289627ddc75339a6b0b3fe1bc5e /plugins/InspectionGadgets/test/com/siyeh/igtest | |
parent | b569bc6aa78f6eacf72e8b90622d300e1a9db25f (diff) | |
download | idea-b17587c84879dd2ea42495f1fbdadbc806b9475b.tar.gz |
Snapshot e242282deb41c328afbe971fc167e47ddfb26df9 from master branch of git://git.jetbrains.org/idea/community.git
Change-Id: Ifdc1818cde7b63f6d7bf42801f18c7f1557b8d85
Diffstat (limited to 'plugins/InspectionGadgets/test/com/siyeh/igtest')
4 files changed, 83 insertions, 0 deletions
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/style/unnecessary_tostring/UnnecessaryToString.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/style/unnecessary_tostring/UnnecessaryToString.java new file mode 100644 index 000000000000..a77660ab714a --- /dev/null +++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/style/unnecessary_tostring/UnnecessaryToString.java @@ -0,0 +1,30 @@ +package com.siyeh.igtest.style.unnecessary_tostring; + +public class UnnecessaryToString { + + String foo(Object o) { + return "star" + o.toString(); + } + + String bar() { + char[] cs = {'!'}; + return "wars" + cs.toString(); + } + + void fizzz(Object o) { + boolean c = true; + System.out.println(o.toString() + c); + } + + void polyadic(Object s) { + s = "abc" + s.toString() + "efg"; + } + + void printStream(Object o) { + System.out.print(o.toString()); + } + + void builder(StringBuilder builder, Object o) { + builder.append(o.toString()); + } +}
\ No newline at end of file diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/style/unnecessary_tostring/expected.xml b/plugins/InspectionGadgets/test/com/siyeh/igtest/style/unnecessary_tostring/expected.xml new file mode 100644 index 000000000000..9aea4d234a81 --- /dev/null +++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/style/unnecessary_tostring/expected.xml @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8"?> +<problems> + + <problem> + <file>UnnecessaryToString.java</file> + <line>6</line> + <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Unnecessary call to '.toString()'</problem_class> + <description>Unnecessary <code>toString()</code> call #loc</description> + </problem> + + <problem> + <file>UnnecessaryToString.java</file> + <line>20</line> + <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Unnecessary call to '.toString()'</problem_class> + <description>Unnecessary <code>toString()</code> call #loc</description> + </problem> + + <problem> + <file>UnnecessaryToString.java</file> + <line>24</line> + <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Unnecessary call to '.toString()'</problem_class> + <description>Unnecessary <code>toString()</code> call #loc</description> + </problem> + + <problem> + <file>UnnecessaryToString.java</file> + <line>28</line> + <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Unnecessary call to '.toString()'</problem_class> + <description>Unnecessary <code>toString()</code> call #loc</description> + </problem> + +</problems>
\ No newline at end of file diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/style/unnecessary_valueof/UnnecessaryCallToStringValueOf.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/style/unnecessary_valueof/UnnecessaryCallToStringValueOf.java index cf3f87cfae7a..023d86fef245 100644 --- a/plugins/InspectionGadgets/test/com/siyeh/igtest/style/unnecessary_valueof/UnnecessaryCallToStringValueOf.java +++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/style/unnecessary_valueof/UnnecessaryCallToStringValueOf.java @@ -21,4 +21,11 @@ public class UnnecessaryCallToStringValueOf { s = "abc" + String.valueOf('d') + "efg"; } + void printStream() { + System.out.print(String.valueOf(7)); + } + + void builder(StringBuilder builder) { + builder.append(String.valueOf(0x8)); + } }
\ No newline at end of file diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/style/unnecessary_valueof/expected.xml b/plugins/InspectionGadgets/test/com/siyeh/igtest/style/unnecessary_valueof/expected.xml index 315e44ea81b7..c453124dc5ca 100644 --- a/plugins/InspectionGadgets/test/com/siyeh/igtest/style/unnecessary_valueof/expected.xml +++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/style/unnecessary_valueof/expected.xml @@ -15,4 +15,18 @@ <description><code>String.valueOf('d')</code> can be simplified to ''d'' #loc</description> </problem> + <problem> + <file>UnnecessaryCallToStringValueOf.java</file> + <line>25</line> + <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Unnecessary call to 'String.valueOf()'</problem_class> + <description><code>String.valueOf(7)</code> can be simplified to '7' #loc</description> + </problem> + + <problem> + <file>UnnecessaryCallToStringValueOf.java</file> + <line>29</line> + <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Unnecessary call to 'String.valueOf()'</problem_class> + <description><code>String.valueOf(0x8)</code> can be simplified to '0x8' #loc</description> + </problem> + </problems>
\ No newline at end of file |