| Summary: | Add cleanup for redundant string operations | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Karsten Thoms <karsten.thoms> |
| Component: | UI | Assignee: | JDT-UI-Inbox <jdt-ui-inbox> |
| Status: | CLOSED DUPLICATE | QA Contact: | |
| Severity: | enhancement | ||
| Priority: | P3 | CC: | carsten.hammer, Lars.Vogel |
| Version: | 4.8 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Mac OS X | ||
| Whiteboard: | |||
+1, Karsten are you planning to provide a Gerrit? Not sure yet, but I'm interested. If someone picks this up earlier leave a note here. Parts of it is solved in Bug 568472 in the meantime *** This bug has been marked as a duplicate of bug 568472 *** |
The following code contains several examples for redundant string operations. They should be removable by a cleanup operation. Additionally an "Unnecessary code" warning could be raised and quick fix provided. public class RedundantStringOperations { private static final String FOO = "Foo"; public static void main(String[] args) { System.out.println(FOO.toString()); // toString on String is redundant System.out.println(FOO.intern()); // intern on a constant is redundant StringBuilder sb = new StringBuilder(""); // empty string param is superfluous sb.append(""); // statement is a noop System.out.print(""); // statement is a noop } }