mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
rename "Constant 'StringBuffer' may be 'String'" inspection to "'StringBuffer' can be replaced with 'String'", move it to the Code Style Issues category and enable it by default
This commit is contained in:
@@ -1824,10 +1824,6 @@
|
||||
bundle="com.siyeh.InspectionGadgetsBundle" key="string.buffer.must.have.initial.capacity.display.name"
|
||||
groupBundle="messages.InspectionsBundle" groupKey="group.names.performance.issues" enabledByDefault="false"
|
||||
level="WARNING" implementationClass="com.siyeh.ig.performance.StringBufferMustHaveInitialCapacityInspection"/>
|
||||
<localInspection language="JAVA" shortName="StringBufferReplaceableByString" bundle="com.siyeh.InspectionGadgetsBundle"
|
||||
key="string.buffer.replaceable.by.string.display.name" groupBundle="messages.InspectionsBundle"
|
||||
groupKey="group.names.performance.issues" enabledByDefault="false" level="WARNING"
|
||||
implementationClass="com.siyeh.ig.performance.StringBufferReplaceableByStringInspection"/>
|
||||
<localInspection language="JAVA" shortName="StringBufferToStringInConcatenation" bundle="com.siyeh.InspectionGadgetsBundle"
|
||||
key="string.buffer.to.string.in.concatenation.display.name" groupBundle="messages.InspectionsBundle"
|
||||
groupKey="group.names.performance.issues" enabledByDefault="false" level="WARNING"
|
||||
@@ -2188,6 +2184,10 @@
|
||||
key="simplifiable.equals.expression.display.name" groupBundle="messages.InspectionsBundle"
|
||||
groupKey="group.names.code.style.issues" enabledByDefault="false" level="WARNING"
|
||||
implementationClass="com.siyeh.ig.style.SimplifiableEqualsExpressionInspection"/>
|
||||
<localInspection language="JAVA" shortName="StringBufferReplaceableByString" bundle="com.siyeh.InspectionGadgetsBundle"
|
||||
key="string.buffer.replaceable.by.string.display.name" groupBundle="messages.InspectionsBundle"
|
||||
groupKey="group.names.performance.issues" enabledByDefault="true" level="WARNING"
|
||||
implementationClass="com.siyeh.ig.style.StringBufferReplaceableByStringInspection"/>
|
||||
<localInspection language="JAVA" suppressId="TypeParameterExplicitlyExtendsObject" shortName="TypeParameterExtendsObject"
|
||||
bundle="com.siyeh.InspectionGadgetsBundle" key="type.parameter.extends.object.display.name"
|
||||
groupBundle="messages.InspectionsBundle" groupKey="group.names.code.style.issues" enabledByDefault="true"
|
||||
|
||||
@@ -764,7 +764,7 @@ for.loop.with.missing.component.collection.loop.option=Ignore collection iterati
|
||||
double.checked.locking.display.name=Double-checked locking
|
||||
double.checked.locking.problem.descriptor=Double-checked locking #loc
|
||||
double.checked.locking.ignore.on.volatiles.option=Ignore double-checked locking on volatile fields
|
||||
string.buffer.replaceable.by.string.display.name=Constant 'StringBuffer' may be 'String'
|
||||
string.buffer.replaceable.by.string.display.name='StringBuffer' can be replaced with 'String'
|
||||
boolean.method.name.must.start.with.question.display.name=Boolean method name must start with question word
|
||||
class.name.same.as.ancestor.name.display.name=Class name same as ancestor name
|
||||
error.rethrown.display.name='java.lang.Error' not rethrown
|
||||
@@ -1044,7 +1044,7 @@ set.replaceable.by.enum.set.problem.descriptor=<code>#ref</code> replaceable wit
|
||||
inner.class.may.be.static.problem.descriptor=Inner class <code>#ref</code> may be 'static' #loc
|
||||
string.buffer.must.have.initial.capacity.problem.descriptor=<code>#ref</code> without initial capacity #loc
|
||||
string.buffer.replaceable.by.string.builder.problem.descriptor=<code>StringBuffer #ref</code> may be declared as ''StringBuilder'' #loc
|
||||
string.buffer.replaceable.by.string.problem.descriptor=Constant <code>{0} #ref</code> may be declared as ''String'' #loc
|
||||
string.buffer.replaceable.by.string.problem.descriptor=<code>{0} #ref</code> can be replaced with ''String'' #loc
|
||||
string.replaceable.by.string.buffer.problem.descriptor=Non-constant <code>String #ref</code> should probably be declared as ''StringBuilder'' #loc
|
||||
collections.must.have.initial.capacity.problem.descriptor=<code>#ref</code> without initial capacity #loc
|
||||
string.concatenation.in.loops.problem.descriptor=String concatenation <code>#ref</code> in loop #loc
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.siyeh.ig.performance;
|
||||
package com.siyeh.ig.style;
|
||||
|
||||
import com.intellij.codeInspection.ProblemDescriptor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
+1
-1
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.siyeh.ig.performance;
|
||||
package com.siyeh.ig.style;
|
||||
|
||||
import com.intellij.psi.*;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
+3
-3
@@ -1,8 +1,8 @@
|
||||
<html>
|
||||
<body>
|
||||
This inspection reports any variables declared as <b>java.lang.StringBuffer</b>
|
||||
and <b>java.lang.StringBuilder</b> which are
|
||||
effectively constant, and may thus be declared more efficiently declared as <b>java.lang.String</b>.
|
||||
This inspection reports any variables declared as or uses of <b>java.lang.StringBuffer</b> and <b>java.lang.StringBuilder</b>
|
||||
which are effectively constant. These may be replaced with <b>java.lang.String</b> expressions which results in simpler and possibly
|
||||
more efficient code.
|
||||
<p>
|
||||
<small>Powered by InspectionGadgets</small>
|
||||
</body>
|
||||
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
package com.siyeh.igtest.performance;
|
||||
|
||||
public class StringBufferReplaceableByStringInspection {
|
||||
public void foo()
|
||||
{
|
||||
final StringBuffer buffer = new StringBuffer();
|
||||
System.out.println(buffer.toString());
|
||||
}
|
||||
|
||||
public void foo2()
|
||||
{
|
||||
final StringBuffer buffer = new StringBuffer("foo").append("bar");
|
||||
System.out.println(buffer.toString());
|
||||
}
|
||||
}
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
package com.siyeh.igtest.performance.constant_string_buffer_may_be_string;
|
||||
|
||||
public class StringBufferReplaceableByString {
|
||||
|
||||
StringBuilder foo() {
|
||||
StringBuilder builder = new StringBuilder("asdfasdfasdf");
|
||||
StringBuffer buffer = new StringBuffer("test");
|
||||
StringBuilder result = new StringBuilder("return");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
-16
@@ -1,16 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<problems>
|
||||
<problem>
|
||||
<file>StringBufferReplaceableByString.java</file>
|
||||
<line>6</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Constant StringBuffer may be String</problem_class>
|
||||
<description>Constant <code>StringBuilder builder</code> may be declared as 'String' #loc</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>StringBufferReplaceableByString.java</file>
|
||||
<line>7</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Constant StringBuffer may be String</problem_class>
|
||||
<description>Constant <code>StringBuffer buffer</code> may be declared as 'String' #loc</description>
|
||||
</problem>
|
||||
</problems>
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package com.siyeh.igtest.performance.string_buffer_replaceable_by_string;
|
||||
|
||||
public class StringBufferReplaceableByString {
|
||||
|
||||
StringBuilder foo() {
|
||||
StringBuilder builder = new StringBuilder("asdfasdfasdf");
|
||||
StringBuffer buffer = new StringBuffer("test");
|
||||
StringBuilder result = new StringBuilder("return");
|
||||
return result;
|
||||
}
|
||||
|
||||
public void foo1()
|
||||
{
|
||||
final StringBuffer buffer = new StringBuffer();
|
||||
System.out.println(buffer.toString());
|
||||
}
|
||||
|
||||
public void foo2()
|
||||
{
|
||||
final StringBuffer buffer = new StringBuffer("foo").append("bar");
|
||||
System.out.println(buffer.toString());
|
||||
}
|
||||
|
||||
public void bar(int i) {
|
||||
System.out.println(new StringBuilder("asdf").append(i).toString());
|
||||
}
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<problems>
|
||||
<problem>
|
||||
<file>StringBufferReplaceableByString.java</file>
|
||||
<line>6</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">'StringBuffer' can be replaced with 'String'</problem_class>
|
||||
<description><code>StringBuilder builder</code> can be replaced with 'String' #loc</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>StringBufferReplaceableByString.java</file>
|
||||
<line>7</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">'StringBuffer' can be replaced with 'String'</problem_class>
|
||||
<description><code>StringBuffer buffer</code> can be replaced with 'String' #loc</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>StringBufferReplaceableByString.java</file>
|
||||
<line>14</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">'StringBuffer' can be replaced with 'String'</problem_class>
|
||||
<description><code>StringBuffer buffer</code> can be replaced with 'String' #loc</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>StringBufferReplaceableByString.java</file>
|
||||
<line>20</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">'StringBuffer' can be replaced with 'String'</problem_class>
|
||||
<description><code>StringBuffer buffer</code> can be replaced with 'String' #loc</description>
|
||||
</problem>
|
||||
</problems>
|
||||
+2
-2
@@ -1,11 +1,11 @@
|
||||
package com.siyeh.ig.performance;
|
||||
package com.siyeh.ig.style;
|
||||
|
||||
import com.siyeh.ig.IGInspectionTestCase;
|
||||
|
||||
public class StringBufferReplaceableByStringInspectionTest extends IGInspectionTestCase {
|
||||
|
||||
public void test() throws Exception {
|
||||
doTest("com/siyeh/igtest/performance/constant_string_buffer_may_be_string",
|
||||
doTest("com/siyeh/igtest/performance/string_buffer_replaceable_by_string",
|
||||
new StringBufferReplaceableByStringInspection());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user