mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 15:19:59 +07:00
java: improve some inspection texts
GitOrigin-RevId: 5a0670e84850599d8107f206b76eee1f8f84de17
This commit is contained in:
committed by
intellij-monorepo-bot
parent
57b1788fa5
commit
cfbb00fa01
@@ -495,7 +495,7 @@ readobject.initialization.display.name=Instance field may not be initialized by
|
||||
readobject.initialization.problem.descriptor=Instance field <code>#ref</code> may not be initialized during 'readObject()' call #loc
|
||||
readresolve.writereplace.protected.display.name='readResolve()' or 'writeReplace()' not declared 'protected'
|
||||
readresolve.writereplace.protected.problem.descriptor=<code>#ref()</code> not declared 'protected' #loc
|
||||
missing.serial.annotation.display.name='@Serial' annotation could be used
|
||||
missing.serial.annotation.display.name='@Serial' annotation can be used
|
||||
missing.serial.annotation.on.field.problem.descriptor=<code>#ref</code> can be annotated with '@Serial' annotation
|
||||
missing.serial.annotation.on.method.problem.descriptor=<code>#ref()</code> can be annotated with '@Serial' annotation
|
||||
serial.annotation.used.on.wrong.member.display.name='@Serial' annotation used on wrong member
|
||||
@@ -1243,7 +1243,7 @@ overly.complex.boolean.expression.max.terms.option=Maximum number of terms:
|
||||
pointless.boolean.expression.ignore.option=Ignore named constants in determining pointless expressions
|
||||
simplifiable.conditional.expression.problem.descriptor=<code>{1}</code> can be simplified to ''{0}'' #loc
|
||||
switch.statement.density.min.option=Minimum density of branches: %
|
||||
switch.statement.density.problem.descriptor=<code>#ref</code> has too low of a branch density ({0}%) #loc
|
||||
switch.statement.density.problem.descriptor=<code>#ref</code> branch density is too low ({0}%) #loc
|
||||
switch.statement.with.too.few.branches.min.option=Minimum number of branches:
|
||||
switch.statement.with.too.few.branches.ignore.pattern.option=Do not report pattern switch statements
|
||||
switch.statement.with.too.few.branches.problem.descriptor=''switch'' statement has too few case labels ({0}), and should probably be replaced with an ''if'' statement #loc
|
||||
@@ -1329,7 +1329,7 @@ value.of.post.increment.problem.descriptor=Value of post-increment expression <c
|
||||
value.of.post.decrement.problem.descriptor=Value of post-decrement expression <code>#ref</code> is used #loc
|
||||
value.of.pre.increment.problem.descriptor=Value of pre-increment expression <code>#ref</code> is used #loc
|
||||
value.of.pre.decrement.problem.descriptor=Value of pre-decrement expression <code>#ref</code> is used #loc
|
||||
assignment.replaceable.with.operator.assignment.problem.descriptor=<code>#ref</code> could be simplified to ''{0}'' #loc
|
||||
assignment.replaceable.with.operator.assignment.problem.descriptor=<code>#ref</code> can be simplified to ''{0}'' #loc
|
||||
assignment.replaceable.with.operator.assignment.ignore.conditional.operators.option=Ignore conditional operators
|
||||
assignment.replaceable.with.operator.assignment.ignore.obscure.operators.option=Ignore the obscure ^ and % operators
|
||||
object.equality.ignore.between.objects.of.a.type.with.only.private.constructors.option=Ignore '==' between objects of a type with only 'private' constructors
|
||||
@@ -1349,7 +1349,7 @@ pointless.indexof.comparison.always.true.problem.descriptor=<code>#ref</code> is
|
||||
pointless.indexof.comparison.always.false.problem.descriptor=<code>#ref</code> is always false #loc
|
||||
reuse.of.local.variable.problem.descriptor=Reuse of local variable <code>#ref</code> #loc
|
||||
single.character.startswith.display.name=Single character 'startsWith()' or 'endsWith()'
|
||||
single.character.startswith.problem.descriptor=Single character <code>#ref()</code> could be replaced with 'charAt()' expression #loc
|
||||
single.character.startswith.problem.descriptor=Single character <code>#ref()</code> can be replaced with 'charAt()' expression #loc
|
||||
list.indexof.replaceable.by.contains.display.name='List.indexOf()' expression can be replaced with 'contains()'
|
||||
string.indexof.replaceable.by.contains.display.name='String.indexOf()' expression can be replaced with 'contains()'
|
||||
overloaded.methods.with.same.number.parameters.problem.descriptor=Multiple methods named <code>#ref</code> with the same number of parameters #loc
|
||||
@@ -1520,7 +1520,7 @@ unqualified.method.access.display.name=Instance method call not qualified with '
|
||||
unqualified.method.access.problem.descriptor=Instance method call <code>#ref()</code> is not qualified with 'this' #loc
|
||||
add.this.qualifier.quickfix=Add 'this' qualifier
|
||||
while.loop.spins.on.field.ignore.non.empty.loops.option=Only warn if the loop is empty
|
||||
method.may.be.synchronized.problem.descriptor=Method <code>#ref()</code> with synchronized block could be synchronized method #loc
|
||||
method.may.be.synchronized.problem.descriptor=Method <code>#ref()</code> with synchronized block can be synchronized method #loc
|
||||
method.may.be.synchronized.display.name=Method with single 'synchronized' block can be replaced with 'synchronized' method
|
||||
method.may.be.synchronized.quickfix=Make method synchronized and remove synchronized block
|
||||
fallthru.in.switch.statement.quickfix=Add ''{0}''
|
||||
@@ -1654,8 +1654,8 @@ ignore.overflowing.byte.casts.option=Ignore casts from int 128-255 to byte
|
||||
variable.not.used.inside.if.display.name=Reference checked for 'null' is not used inside 'if'
|
||||
variable.not.used.inside.if.problem.descriptor=<code>#ref</code> checked for 'null' is not used inside 'if' #loc
|
||||
variable.not.used.inside.conditional.problem.descriptor=<code>#ref</code> checked for 'null' is not used inside conditional #loc
|
||||
boolean.expression.may.be.conditional.display.name=Boolean expression could be replaced with conditional expression
|
||||
if.may.be.conditional.problem.descriptor=<code>#ref</code> could be replaced with conditional expression #loc
|
||||
boolean.expression.may.be.conditional.display.name=Boolean expression can be replaced with conditional expression
|
||||
if.may.be.conditional.problem.descriptor=<code>#ref</code> can be replaced with conditional expression #loc
|
||||
if.may.be.conditional.quickfix=Replace with conditional expression
|
||||
expression.may.be.factorized.display.name=Expression can be factorized
|
||||
if.may.be.factorized.problem.descriptor=<code>#ref</code> can be factorized #loc
|
||||
@@ -1673,7 +1673,7 @@ redundant.string.formatted.call.quickfix=Remove redundant call to 'String.format
|
||||
equals.called.on.enum.constant.display.name='equals()' called on enum value
|
||||
equals.called.on.enum.constant.problem.descriptor=<code>#ref()</code> called on enum value #loc
|
||||
int.literal.may.be.long.literal.display.name=Cast to 'long' can be 'long' literal
|
||||
int.literal.may.be.long.literal.problem.descriptor=<code>#ref</code> could be replaced with ''{0}'' #loc
|
||||
int.literal.may.be.long.literal.problem.descriptor=<code>#ref</code> can be replaced with ''{0}'' #loc
|
||||
constant.assert.condition.display.name=Constant condition in 'assert' statement
|
||||
constant.assert.condition.problem.descriptor=Assert condition <code>#ref</code> is constant #loc
|
||||
assert.with.side.effects.display.name='assert' statement with side effects
|
||||
@@ -1681,8 +1681,8 @@ assert.with.side.effects.problem.descriptor=<code>#ref</code> has side effects:
|
||||
method.count.ignore.getters.setters.option=&Ignore simple getter and setter methods
|
||||
class.new.instance.display.name=Unsafe call to 'Class.newInstance()'
|
||||
class.new.instance.problem.descriptor=Call to <code>#ref()</code> may throw undeclared checked exceptions #loc
|
||||
dynamic.regex.replaceable.by.compiled.pattern.display.name=Dynamic regular expression could be replaced by compiled 'Pattern'
|
||||
dynamic.regex.replaceable.by.compiled.pattern.problem.descriptor=<code>#ref()</code> could be replaced with compiled 'java.util.regex.Pattern' construct #loc
|
||||
dynamic.regex.replaceable.by.compiled.pattern.display.name=Dynamic regular expression can be replaced by compiled 'Pattern'
|
||||
dynamic.regex.replaceable.by.compiled.pattern.problem.descriptor=<code>#ref()</code> can be replaced with compiled 'java.util.regex.Pattern' construct #loc
|
||||
dynamic.regex.replaceable.by.compiled.pattern.quickfix=Replace with call to method of compiled 'Pattern' constant
|
||||
ignore.serializable.option=Ignore 'java.io.Serializable'
|
||||
ignore.cloneable.option=Ignore 'java.lang.Cloneable'
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
class MyTest {
|
||||
|
||||
boolean x(String s) {
|
||||
return s.<warning descr="Single character 'startsWith()' could be replaced with 'charAt()' expression"><caret>startsWith</warning>/*c1*/("x")//c2
|
||||
&&
|
||||
!s.<warning descr="Single character 'endsWith()' could be replaced with 'charAt()' expression">endsWith</warning>("x");
|
||||
return s.<warning descr="Single character 'startsWith()' can be replaced with 'charAt()' expression"><caret>startsWith</warning>/*c1*/("x")//c2
|
||||
&&
|
||||
!s.<warning descr="Single character 'endsWith()' can be replaced with 'charAt()' expression">endsWith</warning>("x");
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
class useisEmptyMethod {
|
||||
|
||||
boolean x(String s) {
|
||||
return s.<warning descr="Single character 'startsWith()' could be replaced with 'charAt()' expression"><caret>startsWith</warning>("x");
|
||||
return s.<warning descr="Single character 'startsWith()' can be replaced with 'charAt()' expression"><caret>startsWith</warning>("x");
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
class UseLengthMethod {
|
||||
|
||||
boolean x(String s) {
|
||||
return s.<warning descr="Single character 'startsWith()' could be replaced with 'charAt()' expression"><caret>startsWith</warning>("x");
|
||||
return s.<warning descr="Single character 'startsWith()' can be replaced with 'charAt()' expression"><caret>startsWith</warning>("x");
|
||||
}
|
||||
}
|
||||
@@ -11,11 +11,11 @@ public class ReplaceAssignmentWithOperatorAssignment
|
||||
public void foo()
|
||||
{
|
||||
int x = 0;
|
||||
<warning descr="'x = x + 3' could be simplified to 'x += 3'">x = x + 3</warning>;
|
||||
<warning descr="'x = x * 3' could be simplified to 'x *= 3'">x = x * 3</warning>;
|
||||
<warning descr="'x = x / 3' could be simplified to 'x /= 3'">x = x / 3</warning>;
|
||||
<warning descr="'x = x - 3' could be simplified to 'x -= 3'">x = x - 3</warning>;
|
||||
<warning descr="'x = x + 2 + 2 + 2' could be simplified to 'x += 2 + 2 + 2'">x = x + 2 + 2 + 2</warning>;
|
||||
<warning descr="'x = x + 3' can be simplified to 'x += 3'">x = x + 3</warning>;
|
||||
<warning descr="'x = x * 3' can be simplified to 'x *= 3'">x = x * 3</warning>;
|
||||
<warning descr="'x = x / 3' can be simplified to 'x /= 3'">x = x / 3</warning>;
|
||||
<warning descr="'x = x - 3' can be simplified to 'x -= 3'">x = x - 3</warning>;
|
||||
<warning descr="'x = x + 2 + 2 + 2' can be simplified to 'x += 2 + 2 + 2'">x = x + 2 + 2 + 2</warning>;
|
||||
|
||||
System.out.println("x = " + x);
|
||||
|
||||
@@ -24,12 +24,12 @@ public class ReplaceAssignmentWithOperatorAssignment
|
||||
|
||||
x = x / 2 / 4;
|
||||
x = x >> 1 >> 1;
|
||||
<warning descr="'x = x * 2 * 2' could be simplified to 'x *= 2 * 2'">x = x * 2 * 2</warning>;
|
||||
<warning descr="'x = x * 2 * 2' can be simplified to 'x *= 2 * 2'">x = x * 2 * 2</warning>;
|
||||
float f = 1;
|
||||
f = f * 2 * 2;
|
||||
int a = Integer.MAX_VALUE;
|
||||
double d = Double.MAX_VALUE;
|
||||
(a) = (byte)(a + (d - d));// should not warn here
|
||||
<warning descr="'(a) = (int)(a + (d - d))' could be simplified to '(a) += (d - d)'">(a) = (int)(a + (d - d))</warning>;// should warn here
|
||||
<warning descr="'(a) = (int)(a + (d - d))' can be simplified to '(a) += (d - d)'">(a) = (int)(a + (d - d))</warning>;// should warn here
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ public class SwitchStatementDensity
|
||||
public void fooBar()
|
||||
{
|
||||
final int bar = m_bar;
|
||||
<warning descr="'switch' has too low of a branch density (19%)">switch</warning>(bar)
|
||||
<warning descr="'switch' branch density is too low (19%)">switch</warning>(bar)
|
||||
{
|
||||
case 3:
|
||||
case 4:
|
||||
@@ -48,7 +48,7 @@ public class SwitchStatementDensity
|
||||
}
|
||||
|
||||
public int switchExpression(int e) {
|
||||
return <warning descr="'switch' has too low of a branch density (11%)">switch</warning> (e) {
|
||||
return <warning descr="'switch' branch density is too low (11%)">switch</warning> (e) {
|
||||
case 1:
|
||||
System.out.println(e);
|
||||
System.out.println(e);
|
||||
@@ -76,7 +76,7 @@ public class SwitchStatementDensity
|
||||
}
|
||||
|
||||
public void ruleBaseSwitch(String s) {
|
||||
<warning descr="'switch' has too low of a branch density (9%)">switch</warning> (s) {
|
||||
<warning descr="'switch' branch density is too low (9%)">switch</warning> (s) {
|
||||
case "one" -> {
|
||||
System.out.println(1);
|
||||
System.out.println(1);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
class DoubleLiteralMayBeFloatLiteral {
|
||||
|
||||
void literal() {
|
||||
System.out.println(<warning descr="'(float)1.1' could be replaced with '1.1f'">(float)1.1</warning>);
|
||||
System.out.println(<warning descr="'(float)-7.3' could be replaced with '-7.3f'">(float)-7.3</warning>);
|
||||
System.out.println(<warning descr="'(float)-(-((4.2)))' could be replaced with '-(-((4.2f)))'">(float)-(-((4.2)))</warning>);
|
||||
System.out.println(<warning descr="'(float)1.1' can be replaced with '1.1f'">(float)1.1</warning>);
|
||||
System.out.println(<warning descr="'(float)-7.3' can be replaced with '-7.3f'">(float)-7.3</warning>);
|
||||
System.out.println(<warning descr="'(float)-(-((4.2)))' can be replaced with '-(-((4.2f)))'">(float)-(-((4.2)))</warning>);
|
||||
}
|
||||
|
||||
void error() {
|
||||
@@ -11,6 +11,6 @@ class DoubleLiteralMayBeFloatLiteral {
|
||||
}
|
||||
|
||||
Float boxed() {
|
||||
return <warning descr="'(float) 2.0' could be replaced with '2.0f'">(float) 2.0</warning>;
|
||||
return <warning descr="'(float) 2.0' can be replaced with '2.0f'">(float) 2.0</warning>;
|
||||
}
|
||||
}
|
||||
@@ -3,9 +3,9 @@ package com.siyeh.igtest.numeric.int_literal_may_be_long;
|
||||
public class IntLiteralMayBeLongLiteral {
|
||||
|
||||
void foo() {
|
||||
System.out.println(<warning descr="'(long) 1' could be replaced with '1L'">(long) 1</warning>);
|
||||
System.out.println(<warning descr="'(long) -/*yes, minus*/1' could be replaced with '-1L'">(long) -/*yes, minus*/1</warning>);
|
||||
System.out.println(<warning descr="'(long)-(-(6))' could be replaced with '-(-(6L))'">(long)-(-(6))</warning>);
|
||||
System.out.println(<warning descr="'(long) 1' can be replaced with '1L'">(long) 1</warning>);
|
||||
System.out.println(<warning descr="'(long) -/*yes, minus*/1' can be replaced with '-1L'">(long) -/*yes, minus*/1</warning>);
|
||||
System.out.println(<warning descr="'(long)-(-(6))' can be replaced with '-(-(6L))'">(long)-(-(6))</warning>);
|
||||
}
|
||||
|
||||
void error() {
|
||||
@@ -13,6 +13,6 @@ public class IntLiteralMayBeLongLiteral {
|
||||
}
|
||||
|
||||
Long boxed() {
|
||||
return <warning descr="'(long) -5' could be replaced with '-5L'">(long) -5</warning>;
|
||||
return <warning descr="'(long) -5' can be replaced with '-5L'">(long) -5</warning>;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,10 +2,10 @@ package com.siyeh.igtest.performance.dynamic_regex_replaceable_by_compiled_patte
|
||||
|
||||
class DynamicRegex {
|
||||
void m(String s) {
|
||||
"asdf::asdf".<warning descr="'split()' could be replaced with compiled 'java.util.regex.Pattern' construct">split</warning>("::");
|
||||
s.<warning descr="'matches()' could be replaced with compiled 'java.util.regex.Pattern' construct">matches</warning>("test");
|
||||
s.<warning descr="'replaceAll()' could be replaced with compiled 'java.util.regex.Pattern' construct">replaceAll</warning>("all", "nothing");
|
||||
s.<warning descr="'replaceFirst()' could be replaced with compiled 'java.util.regex.Pattern' construct">replaceFirst</warning>("first", "second");
|
||||
"asdf::asdf".<warning descr="'split()' can be replaced with compiled 'java.util.regex.Pattern' construct">split</warning>("::");
|
||||
s.<warning descr="'matches()' can be replaced with compiled 'java.util.regex.Pattern' construct">matches</warning>("test");
|
||||
s.<warning descr="'replaceAll()' can be replaced with compiled 'java.util.regex.Pattern' construct">replaceAll</warning>("all", "nothing");
|
||||
s.<warning descr="'replaceFirst()' can be replaced with compiled 'java.util.regex.Pattern' construct">replaceFirst</warning>("first", "second");
|
||||
s.split("a");
|
||||
s.split("\\\\");
|
||||
"abba".replace("bb", "aa");
|
||||
|
||||
@@ -2,13 +2,13 @@ package com.siyeh.igtest.performance.dynamic_regex_replaceable_by_compiled_patte
|
||||
|
||||
class DynamicRegex {
|
||||
void m(String s) {
|
||||
"asdf::asdf".<warning descr="'split()' could be replaced with compiled 'java.util.regex.Pattern' construct">split</warning>("::");
|
||||
s.<warning descr="'matches()' could be replaced with compiled 'java.util.regex.Pattern' construct">matches</warning>("test");
|
||||
s.<warning descr="'replaceAll()' could be replaced with compiled 'java.util.regex.Pattern' construct">replaceAll</warning>("all", "nothing");
|
||||
s.<warning descr="'replaceFirst()' could be replaced with compiled 'java.util.regex.Pattern' construct">replaceFirst</warning>("first", "second");
|
||||
s.<warning descr="'split()' could be replaced with compiled 'java.util.regex.Pattern' construct">split</warning>("a");
|
||||
s.<warning descr="'split()' could be replaced with compiled 'java.util.regex.Pattern' construct">split</warning>("\\\\");
|
||||
"abba".<warning descr="'replace()' could be replaced with compiled 'java.util.regex.Pattern' construct">replace</warning>("bb", "aa");
|
||||
"asdf::asdf".<warning descr="'split()' can be replaced with compiled 'java.util.regex.Pattern' construct">split</warning>("::");
|
||||
s.<warning descr="'matches()' can be replaced with compiled 'java.util.regex.Pattern' construct">matches</warning>("test");
|
||||
s.<warning descr="'replaceAll()' can be replaced with compiled 'java.util.regex.Pattern' construct">replaceAll</warning>("all", "nothing");
|
||||
s.<warning descr="'replaceFirst()' can be replaced with compiled 'java.util.regex.Pattern' construct">replaceFirst</warning>("first", "second");
|
||||
s.<warning descr="'split()' can be replaced with compiled 'java.util.regex.Pattern' construct">split</warning>("a");
|
||||
s.<warning descr="'split()' can be replaced with compiled 'java.util.regex.Pattern' construct">split</warning>("\\\\");
|
||||
"abba".<warning descr="'replace()' can be replaced with compiled 'java.util.regex.Pattern' construct">replace</warning>("bb", "aa");
|
||||
"abba".replace('b', 'a');
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
class MethodMayBeSynchronized {
|
||||
public int <warning descr="Method 'generateInt()' with synchronized block could be synchronized method">generateInt<caret></warning>(int x) {
|
||||
public int <warning descr="Method 'generateInt()' with synchronized block can be synchronized method">generateInt<caret></warning>(int x) {
|
||||
// 1
|
||||
synchronized/*2*/ (/*3*/this/*4*/) { // 5
|
||||
// 6
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.siyeh.ig.fixes.performance;
|
||||
|
||||
import com.intellij.codeInspection.InspectionsBundle;
|
||||
import com.intellij.testFramework.IdeaTestUtil;
|
||||
import com.intellij.testFramework.builders.JavaModuleFixtureBuilder;
|
||||
import com.siyeh.InspectionGadgetsBundle;
|
||||
@@ -9,17 +10,20 @@ import com.siyeh.ig.performance.DynamicRegexReplaceableByCompiledPatternInspecti
|
||||
|
||||
public class DynamicRegexReplaceableByCompiledPatternFixTest extends IGQuickFixesTestCase {
|
||||
|
||||
private DynamicRegexReplaceableByCompiledPatternInspection myInspection;
|
||||
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
myFixture.enableInspections(new DynamicRegexReplaceableByCompiledPatternInspection());
|
||||
myInspection = new DynamicRegexReplaceableByCompiledPatternInspection();
|
||||
myFixture.enableInspections(myInspection);
|
||||
myRelativePath = "performance/replace_with_compiled_pattern";
|
||||
myDefaultHint = InspectionGadgetsBundle.message("dynamic.regex.replaceable.by.compiled.pattern.quickfix");
|
||||
}
|
||||
|
||||
public void testLiteral() { doTest(); }
|
||||
public void testLiteralLiteral() { doTest(); }
|
||||
public void testReplaceAll() { doTest("Fix all 'Dynamic regular expression could be replaced by compiled 'Pattern'' problems in file"); }
|
||||
public void testReplaceAll() { doTest(InspectionsBundle.message("fix.all.inspection.problems.in.file", myInspection.getDisplayName())); }
|
||||
|
||||
@Override
|
||||
protected void tuneFixture(JavaModuleFixtureBuilder builder) throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user