inspection warning text improvements

GitOrigin-RevId: 9aaad61ae52463727c77930af532258ea16dd1da
This commit is contained in:
Bas Leijdekkers
2020-09-02 21:26:26 +02:00
committed by intellij-monorepo-bot
parent b5161d18f5
commit e310b0c94c
49 changed files with 127 additions and 118 deletions

View File

@@ -1,4 +1,4 @@
// "Replace with 'Arrays.copyOfRange'" "true"
// "Replace with 'Arrays.copyOfRange()'" "true"
import java.util.Arrays;
class Test {

View File

@@ -1,4 +1,4 @@
// "Replace with 'Arrays.copyOfRange'" "true"
// "Replace with 'Arrays.copyOfRange()'" "true"
import java.util.Arrays;
class Test {

View File

@@ -1,4 +1,4 @@
// "Replace with 'Arrays.copyOf'" "true"
// "Replace with 'Arrays.copyOf()'" "true"
import java.util.Arrays;
class Test {

View File

@@ -1,4 +1,4 @@
// "Replace with 'Arrays.copyOf'" "true"
// "Replace with 'Arrays.copyOf()'" "true"
import java.util.Arrays;
class Test {

View File

@@ -1,4 +1,4 @@
// "Remove the 'contains' check" "true"
// "Remove 'contains()' check" "true"
import java.util.*;
class Test {

View File

@@ -1,4 +1,4 @@
// "Replace with 'contains'" "true"
// "Replace with 'contains()'" "true"
import java.util.*;
class Test {

View File

@@ -1,4 +1,4 @@
// "Remove the 'containsKey' check" "true"
// "Remove 'containsKey()' check" "true"
import java.util.Map;
class Test {

View File

@@ -1,4 +1,4 @@
// "Remove the 'contains' check" "true"
// "Remove 'contains()' check" "true"
import java.util.List;
class Test {

View File

@@ -1,4 +1,4 @@
// "Remove the 'contains' check" "true"
// "Remove 'contains()' check" "true"
import java.util.List;
class Test {

View File

@@ -1,4 +1,4 @@
// "Remove the 'contains' check" "true"
// "Remove 'contains()' check" "true"
import java.util.List;
class Test {

View File

@@ -1,4 +1,4 @@
// "Replace with 'Objects.equals'" "true"
// "Replace with 'Objects.equals()'" "true"
import java.util.*;
class Test {

View File

@@ -1,4 +1,4 @@
// "Replace with 'Arrays.copyOfRange'" "true"
// "Replace with 'Arrays.copyOfRange()'" "true"
import java.util.Arrays;
class Test {

View File

@@ -1,4 +1,4 @@
// "Replace with 'Arrays.copyOfRange'" "true"
// "Replace with 'Arrays.copyOfRange()'" "true"
import java.util.Arrays;
class Test {

View File

@@ -1,4 +1,4 @@
// "Replace with 'Arrays.copyOfRange'" "false"
// "Replace with 'Arrays.copyOfRange()'" "false"
import java.util.Arrays;
class Test {

View File

@@ -1,4 +1,4 @@
// "Replace with 'Arrays.copyOf'" "true"
// "Replace with 'Arrays.copyOf()'" "true"
import java.util.Arrays;
class Test {

View File

@@ -1,4 +1,4 @@
// "Replace with 'Arrays.copyOf'" "true"
// "Replace with 'Arrays.copyOf()'" "true"
import java.util.Arrays;
class Test {

View File

@@ -1,4 +1,4 @@
// "Remove the 'contains' check" "true"
// "Remove 'contains()' check" "true"
import java.util.*;
class Test {

View File

@@ -1,4 +1,4 @@
// "Remove the 'contains' check" "false"
// "Remove 'contains()' check" "false"
import java.util.*;
class Test {

View File

@@ -1,4 +1,4 @@
// "Remove the 'contains' check" "false"
// "Remove 'contains()' check" "false"
import java.util.*;
class Test {

View File

@@ -1,4 +1,4 @@
// "Replace with 'contains'" "true"
// "Replace with 'contains()'" "true"
import java.util.*;
class Test {

View File

@@ -1,4 +1,4 @@
// "Remove the 'containsKey' check" "true"
// "Remove 'containsKey()' check" "true"
import java.util.Map;
class Test {

View File

@@ -1,4 +1,4 @@
// "Remove the 'contains' check" "true"
// "Remove 'contains()' check" "true"
import java.util.List;
class Test {

View File

@@ -1,4 +1,4 @@
// "Remove the 'contains' check" "true"
// "Remove 'contains()' check" "true"
import java.util.List;
class Test {

View File

@@ -1,4 +1,4 @@
// "Remove the 'contains' check" "true"
// "Remove 'contains()' check" "true"
import java.util.List;
class Test {

View File

@@ -1,4 +1,4 @@
// "Remove the 'contains' check" "false"
// "Remove 'contains()' check" "false"
import java.util.List;
class Test {

View File

@@ -1,4 +1,4 @@
// "Remove the 'contains' check" "false"
// "Remove 'contains()' check" "false"
import java.util.List;
class Test {

View File

@@ -1,4 +1,4 @@
// "Replace with 'Objects.equals'" "true"
// "Replace with 'Objects.equals()'" "true"
import java.util.*;
class Test {

View File

@@ -1,4 +1,4 @@
// "Fix all 'Redundant 'compare' method call' problems in file" "true"
// "Fix all 'Redundant 'compare()' method call' problems in file" "true"
class CompareTest {
int testInteger(int a, int b) {
if(a < b) return 1;

View File

@@ -1,4 +1,4 @@
// "Fix all 'Redundant 'compare' method call' problems in file" "true"
// "Fix all 'Redundant 'compare()' method call' problems in file" "true"
class CompareTest {
int testInteger(int a, int b) {
if(Integer.c<caret>ompare(a, b) < 0) return 1;

View File

@@ -1,4 +1,4 @@
// "Remove folded 'ifPresent' call" "true"
// "Remove folded 'ifPresent()' call" "true"
import java.util.Optional;

View File

@@ -1,4 +1,4 @@
// "Remove folded 'ifPresent' call" "true"
// "Remove folded 'ifPresent()' call" "true"
import java.util.*;
class Test {

View File

@@ -1,4 +1,4 @@
// "Remove folded 'ifPresent' call" "true"
// "Remove folded 'ifPresent()' call" "true"
import java.util.*;
class Test {

View File

@@ -1,4 +1,4 @@
// "Remove folded 'ifPresent' call" "false"
// "Remove folded 'ifPresent()' call" "false"
import java.util.Optional;
class Sample {

View File

@@ -1,4 +1,4 @@
// "Remove folded 'ifPresent' call" "true"
// "Remove folded 'ifPresent()' call" "true"
import java.util.Optional;

View File

@@ -1,4 +1,4 @@
// "Remove folded 'ifPresent' call" "true"
// "Remove folded 'ifPresent()' call" "true"
import java.util.*;
class Test {

View File

@@ -1,4 +1,4 @@
// "Remove folded 'ifPresent' call" "true"
// "Remove folded 'ifPresent()' call" "true"
import java.util.*;
class Test {

View File

@@ -80,7 +80,7 @@ equals.between.inconvertible.types.problem.descriptor=<code>#ref</code> between
equals.between.inconvertible.types.no.mutual.subclass.problem.descriptor=No class found which is a subtype of both ''{0}'' and ''{1}'' #loc
equals.between.inconvertible.types.mutual.subclass.option=Warn if no mutual subclass found
equals.called.on.suspicious.object.display.name='equals()' called on StringBuilder
equals.called.on.suspicious.object.problem.descriptor=Suspicious call ''equals'' on ''{0}'' object
equals.called.on.suspicious.object.problem.descriptor=Suspicious call to ''equals()'' on ''{0}'' object
non.final.field.in.equals.display.name=Non-final field referenced in 'equals()'
non.final.field.in.equals.problem.descriptor=Non-final field <code>#ref</code> accessed in 'equals()' #loc
equals.doesnt.check.class.parameter.display.name='equals()' method which does not check class of parameter
@@ -503,11 +503,13 @@ readobject.initialization.problem.descriptor=Instance field <code>#ref</code> ma
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.problem.descriptor=The <code>#ref</code> can be annotated with @Serial annotation
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
serial.annotation.used.on.wrong.member.problem.descriptor=Annotated member is not a part of the serialization mechanism
serializable.record.contains.ignored.members.display.name=Serializable record contains ignored members
serializable.record.contains.ignored.members.problem.descriptor=The <code>#ref</code> is ignored during record serialization
serializable.record.contains.ignored.field.problem.descriptor=<code>#ref</code> will be ignored during record serialization
serializable.record.contains.ignored.method.problem.descriptor=<code>#ref()</code> will be ignored during record serialization
serialpersistentfields.with.wrong.signature.display.name='serialPersistentFields' field not declared 'private static final ObjectStreamField[]'
serialpersistentfields.with.wrong.signature.problem.descriptor=<code>#ref</code> field of a Serializable class is not declared 'private static final ObjectStreamField[]' #loc
serialversionuid.private.static.final.long.display.name='serialVersionUID' field not declared 'private static final long'
@@ -1005,7 +1007,7 @@ for.can.be.foreach.problem.descriptor=<code>#ref</code> loop replaceable with en
while.can.be.foreach.problem.descriptor=<code>#ref</code> loop replaceable with enhanced 'for' #loc
too.broad.scope.problem.descriptor=Scope of variable <code>#ref</code> is too broad #loc
return.this.problem.descriptor=Return of <code>#ref</code> #loc
constant.on.side.of.comparison.display.name=Constant on the wrong side of comparison
constant.on.side.of.comparison.display.name=Constant on wrong side of comparison
constant.on.lhs.of.comparison.problem.descriptor=Constant <code>#ref</code> on left side of comparison #loc
constant.on.rhs.of.comparison.problem.descriptor=Constant <code>#ref</code> on right side of comparison #loc
control.flow.statement.without.braces.problem.descriptor=<code>{0}</code> without braces #loc
@@ -1038,7 +1040,7 @@ wait.called.on.condition.problem.descriptor=Call to <code>#ref()</code> on Condi
notify.called.on.condition.problem.descriptor=Call to <code>#ref()</code> on Condition object #loc
wait.while.holding.two.locks.problem.descriptor=Call to <code>#ref()</code> is made while holding two locks #loc
thread.run.problem.descriptor=Calls to <code>#ref()</code> should probably be replaced with 'start()' #loc
thread.start.in.construction.problem.descriptor=Call to <code>#ref</code> during object construction #loc
thread.start.in.construction.problem.descriptor=Call to <code>#ref()</code> during object construction #loc
synchronize.on.lock.problem.descriptor=Synchronization on a ''{0}'' object is unlikely to be intentional #loc
synchronized.on.literal.object.problem.descriptor=Synchronization on {0} <code>#ref</code> which is initialized by a literal #loc
synchronized.on.direct.literal.object.problem.descriptor=Synchronization on {0} literal <code>#ref</code> #loc
@@ -1441,13 +1443,13 @@ static.method.only.used.in.one.class.ignore.utility.classes=Ignore members locat
unary.plus.display.name=Unary plus
unary.plus.problem.descriptor=Unary <code>#ref</code> operator #loc
await.without.corresponding.signal.display.name='await()' without corresponding 'signal()'
await.without.corresponding.signal.problem.descriptor=Call to <code>#ref</code> without corresponding <code>signal()</code> or <code>signalAll()</code> #loc
await.without.corresponding.signal.problem.descriptor=Call to <code>#ref()</code> without corresponding <code>signal()</code> or <code>signalAll()</code> #loc
signal.without.corresponding.await.display.name='signal()' without corresponding 'await()'
signal.without.corresponding.await.problem.descriptor=Call to <code>#ref</code> without corresponding <code>await()</code> #loc
signal.without.corresponding.await.problem.descriptor=Call to <code>#ref()</code> without corresponding <code>await()</code> #loc
wait.without.corresponding.notify.display.name='wait()' without corresponding 'notify()'
wait.without.corresponding.notify.problem.descriptor=Call to <code>#ref</code> without corresponding <code>notify()</code> or <code>notifyAll()</code> #loc
wait.without.corresponding.notify.problem.descriptor=Call to <code>#ref()</code> without corresponding <code>notify()</code> or <code>notifyAll()</code> #loc
notify.without.corresponding.wait.display.name='notify()' without corresponding 'wait()'
notify.without.corresponding.wait.problem.descriptor=Call to <code>#ref</code> without corresponding <code>wait()</code> #loc
notify.without.corresponding.wait.problem.descriptor=Call to <code>#ref()</code> without corresponding <code>wait()</code> #loc
integer.multiplication.implicit.cast.to.long.display.name=Integer multiplication or shift implicitly cast to long
integer.multiplication.implicit.cast.to.long.problem.descriptor=#ref: integer multiplication implicitly cast to long #loc
integer.multiplication.implicit.cast.to.long.quickfix=Cast to long
@@ -1555,7 +1557,7 @@ comparable.implemented.but.equals.not.overridden.fix.generate.equals.name=Genera
unqualified.field.access.display.name=Instance field access not qualified with 'this'
unqualified.field.access.problem.descriptor=Instance field access <code>#ref</code> is not qualified with 'this' #loc
unqualified.method.access.display.name=Instance method call not qualified with 'this'
unqualified.method.access.problem.descriptor=Instance method call <code>#ref</code> is not qualified with 'this' #loc
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
@@ -1614,7 +1616,7 @@ suspicious.comparator.compare.descriptor.non.reflexive=Comparator does not retur
to.array.call.style.display.name='Collection.toArray()' call style
to.array.call.style.problem.descriptor.zero=Call to <code>#ref()</code> with empty array argument ''{0}'' #loc
to.array.call.style.problem.descriptor.presized=Call to <code>#ref()</code> with pre-sized array argument ''{0}'' #loc
to.array.call.style.quickfix.family.name=Fix size of the array passed to 'toArray' call
to.array.call.style.quickfix.family.name=Fix size of array passed to 'toArray()' call
to.array.call.style.quickfix.make.presized=Replace argument with pre-sized array
to.array.call.style.quickfix.make.zero=Replace argument with empty array
throwable.instance.never.thrown.runtime.exception.problem.descriptor=Runtime exception instance <code>#ref</code> is not thrown #loc
@@ -1967,8 +1969,8 @@ non.final.utility.class.problem.descriptor=Utility class <code>#ref</code> is no
0.will.no.longer.be.visible.from.overriding.1={0} will no longer be visible from overriding {1}
make.private.quickfix=Make 'private'
arrays.as.list.with.zero.or.one.argument.display.name=Call to 'Arrays.asList()' with too few arguments
arrays.as.list.with.one.argument.problem.descriptor=Call to <code>#ref</code> with only one argument #loc
arrays.as.list.with.zero.arguments.problem.descriptor=Call to <code>#ref</code> to create an empty List #loc
arrays.as.list.with.one.argument.problem.descriptor=Call to <code>#ref()</code> with only one argument #loc
arrays.as.list.with.zero.arguments.problem.descriptor=Call to <code>#ref()</code> to create an empty List #loc
string.concatenation.argument.to.log.call.display.name=Non-constant string concatenation as argument to logging call
string.concatenation.argument.to.log.call.problem.descriptor=Non-constant string concatenation as argument to <code>#ref()</code> logging call #loc
string.concatenation.argument.to.log.call.quickfix=Replace concatenation with parameterized log message
@@ -2225,15 +2227,15 @@ ignore.private.methods.option=Ignore assignments in and returns from private met
inspection.redundant.string.operation.display.name=Redundant String operation
inspection.redundant.string.remove.fix.name=Remove redundant ''{0}()'' call
inspection.redundant.string.fix.family.name=Remove redundant call
inspection.redundant.string.call.message=Call to <code>#ref</code> is redundant #loc
inspection.redundant.string.call.message=Call to <code>#ref()</code> is redundant #loc
inspection.redundant.string.argument.message=Unnecessary empty string argument
inspection.redundant.string.remove.argument.fix.name=Remove argument
inspection.redundant.string.intern.on.constant.message=Call to <code>#ref</code> on compile-time constant is unnecessary #loc
inspection.redundant.string.intern.on.constant.message=Call to <code>#ref()</code> on compile-time constant is unnecessary #loc
inspection.redundant.string.constructor.message=<code>#ref</code> is redundant #loc
inspection.redundant.string.replace.with.arg.fix.name=Replace with argument
inspection.redundant.string.replace.with.empty.fix.name=Replace with empty string
inspection.redundant.string.option.do.not.report.string.constructors=Do not report String constructors
inspection.x.call.can.be.replaced.with.y=The ''{0}'' call can be replaced with ''{1}''
inspection.x.call.can.be.replaced.with.y=''{0}'' call can be replaced with ''{1}''
inspection.type.may.be.weakened.display.name=Type may be weakened
inspection.type.may.be.weakened.problem.descriptor=Type of variable <code>#ref</code> may be weakened to {0} #loc
@@ -2274,8 +2276,8 @@ inspection.redundant.collection.operation.fix.family.name=Simplify collection op
inspection.redundant.collection.operation.problem.arraycopy=Unnecessary collection created to copy an array
inspection.redundant.collection.removal.by.index.problem=Removal by index can be replaced with removal by object
inspection.redundant.collection.removal.by.index.fix=Use removal by object
inspection.redundant.collection.unnecessary.contains.problem=Unnecessary ''{0}'' check
inspection.redundant.collection.unnecessary.contains.fix=Remove the ''{0}'' check
inspection.redundant.collection.unnecessary.contains.problem=Unnecessary ''{0}()'' check
inspection.redundant.collection.unnecessary.contains.fix=Remove ''{0}()'' check
comments.as.content.option=Comments count as content
copy.constructor.misses.field.display.name=Copy constructor misses field
@@ -2293,8 +2295,8 @@ inspection.constant.expression.fix.name=Compute constant value of ''{0}''
inspection.constant.expression.fix.name.with.value=Replace ''{0}'' with constant value ''{1}''
inspection.constant.expression.fix.family.name=Compute constant value
inspection.redundant.compare.call.display.name=Redundant 'compare' method call
inspection.redundant.compare.call.fix.name=Inline 'compare' call
inspection.redundant.compare.call.display.name=Redundant 'compare()' method call
inspection.redundant.compare.call.fix.name=Inline 'compare()' call
inspection.simplifiable.if.statement.display.name=If statement can be replaced with ?:, \\&\\&, ||, ==, or != expression
inspection.simplifiable.if.statement.message=If statement can be replaced with ''{0}''
@@ -2307,7 +2309,7 @@ inspection.list.remove.in.loop.message=Can be replaced with 'List.subList().clea
implicit.default.charset.usage.fix.family.name=Specify UTF-8 charset
inspection.redundant.class.call.display.name=Redundant 'isInstance' or 'cast' call
inspection.redundant.class.call.display.name=Redundant 'isInstance()' or 'cast()' call
inspection.new.object.equality.display.name=New object is compared using '=='
inspection.new.object.equality.message=New object is compared using ''{0}''
inspection.excessive.range.check.message=Can be replaced with ''{0}''
@@ -2327,8 +2329,8 @@ inspection.suspicious.date.format.message.lower=Lowercase ''{0}'' ({1}) pattern
fix.replace.map.with.flat.map.description='map()' can be replaced with 'flatMap()'
fix.eliminate.folded.if.present.name=Remove folded 'ifPresent' call
fix.eliminate.folded.if.present.description=Folded 'ifPresent' call can be eliminated
fix.eliminate.folded.if.present.name=Remove folded 'ifPresent()' call
fix.eliminate.folded.if.present.description=Folded 'ifPresent()' call can be eliminated
inspection.pattern.variable.can.be.used.display.name=Pattern variable can be used
inspection.pattern.variable.can.be.used.message=Variable ''{0}'' can be replaced with pattern variable
@@ -2337,9 +2339,9 @@ inspection.pattern.variable.can.be.used.fix.name=Replace ''{0}'' with pattern va
array.hash.code.fix.family.name=Replace with implicit 'hashCode'
unqualified.static.access.fix.family.name=Qualify static access
replace.field.reference.fix.family.name=Replace Field Reference
replace.field.reference.fix.family.name=Replace field reference
replace.field.reference.fix.text=Replace field reference with {0}
replace.method.call.fix.family.name=Replace Method Call
replace.method.call.fix.family.name=Replace method call
replace.method.call.fix.text=Replace method call with {0}
delete.unnecessary.statement.fix.family.name=Remove redundant statement
increment.decrement.used.as.expression.fix.family.name=Extract to separate statement
@@ -2459,7 +2461,7 @@ inspection.condition.covered.by.further.condition.descr=Condition ''{0}'' covere
inspection.parameterized.parameters.static.collection.display.name=@RunWith(Parameterized.class) without data provider
create.missing.switch.branch=Create missing switch branch ''{0}''
create.missing.switch.branches=Create missing branches: {0}
redundant.as.list.for.iteration.problem=Unnecessary 'Arrays.asList' call
redundant.as.list.for.iteration.problem=Unnecessary 'Arrays.asList()' call
redundant.as.list.for.iteration.fix.name=Unwrap
assert.with.side.effects.call.mutates.expression=call to ''{0}()'' mutates ''{1}''
assert.with.side.effects.call.mutates.field=call to ''{0}()'' mutates field ''{1}''

View File

@@ -27,7 +27,13 @@ public class MissingSerialAnnotationInspection extends BaseInspection {
@Override
protected @NotNull @InspectionMessage String buildErrorString(Object... infos) {
return InspectionGadgetsBundle.message("missing.serial.annotation.problem.descriptor", infos[0]);
final Object member = infos[0];
if (member instanceof PsiField) {
return InspectionGadgetsBundle.message("missing.serial.annotation.on.field.problem.descriptor", member);
}
else {
return InspectionGadgetsBundle.message("missing.serial.annotation.on.method.problem.descriptor", member);
}
}
@Override
@@ -55,7 +61,7 @@ public class MissingSerialAnnotationInspection extends BaseInspection {
SerializationUtils.isSerialPersistentFields(field);
}
if (candidateToBeAnnotated) {
registerError(field.getNameIdentifier(), field);
registerFieldError(field, field);
}
}
@@ -76,9 +82,7 @@ public class MissingSerialAnnotationInspection extends BaseInspection {
: isSerialMethodInSerializable(method);
}
if (candidateToBeAnnotated) {
PsiIdentifier methodIdentifier = method.getNameIdentifier();
if (methodIdentifier == null) return;
registerError(methodIdentifier, method);
registerMethodError(method, method);
}
}
}

View File

@@ -19,7 +19,13 @@ public class SerializableRecordContainsIgnoredMembersInspection extends BaseInsp
@Override
protected @NotNull @InspectionMessage String buildErrorString(Object... infos) {
return InspectionGadgetsBundle.message("serializable.record.contains.ignored.members.problem.descriptor", infos[0]);
final Object member = infos[0];
if (member instanceof PsiField) {
return InspectionGadgetsBundle.message("serializable.record.contains.ignored.field.problem.descriptor", member);
}
else {
return InspectionGadgetsBundle.message("serializable.record.contains.ignored.method.problem.descriptor", member);
}
}
@Override
@@ -40,7 +46,7 @@ public class SerializableRecordContainsIgnoredMembersInspection extends BaseInsp
if (SerializationUtils.isExternalizable(psiClass)) return;
if (SerializationUtils.isSerialPersistentFields(field)) {
registerError(field.getNameIdentifier(), field);
registerFieldError(field, field);
}
}
@@ -50,19 +56,16 @@ public class SerializableRecordContainsIgnoredMembersInspection extends BaseInsp
PsiClass psiClass = MissingSerialAnnotationInspection.getSerializablePsiClass(method);
if (psiClass == null || !psiClass.isRecord()) return;
PsiIdentifier methodIdentifier = method.getNameIdentifier();
if (methodIdentifier == null) return;
if (SerializationUtils.isExternalizable(psiClass) && method.hasModifierProperty(PsiModifier.PUBLIC) &&
(SerializationUtils.isReadExternal(method) ||
SerializationUtils.isWriteExternal(method))) {
registerError(methodIdentifier, method);
registerMethodError(method, method);
}
else if (SerializationUtils.isSerializable(psiClass) && method.hasModifierProperty(PsiModifier.PRIVATE) &&
(SerializationUtils.isWriteObject(method) ||
SerializationUtils.isReadObject(method) ||
SerializationUtils.isReadObjectNoData(method))) {
registerError(methodIdentifier, method);
registerMethodError(method, method);
}
}
}

View File

@@ -266,10 +266,10 @@ public class RedundantCollectionOperationInspection extends AbstractBaseJavaLoca
myReplacementMethod = "clone()";
}
else if (ExpressionUtils.isZero(from)) {
myReplacementMethod = "Arrays.copyOf";
myReplacementMethod = "Arrays.copyOf()";
}
else {
myReplacementMethod = "Arrays.copyOfRange";
myReplacementMethod = "Arrays.copyOfRange()";
}
}
@@ -367,7 +367,7 @@ public class RedundantCollectionOperationInspection extends AbstractBaseJavaLoca
private static class ContainsAllSingletonHandler implements RedundantCollectionOperationHandler {
@Override
public @NotNull @NlsSafe String getReplacement() {
return "contains";
return "contains()";
}
@Override
@@ -394,7 +394,7 @@ public class RedundantCollectionOperationInspection extends AbstractBaseJavaLoca
@NotNull
@Override
public String getReplacement() {
return "Objects.equals";
return "Objects.equals()";
}
@Override

View File

@@ -17,13 +17,13 @@ import java.util.Objects;
public class EqualsOnSuspiciousObject {
public void test(StringBuilder sb1, StringBuilder sb2) {
if(sb1.<warning descr="Suspicious call 'equals' on 'StringBuilder' object">equals</warning>(sb2)) {
if(sb1.<warning descr="Suspicious call to 'equals()' on 'StringBuilder' object">equals</warning>(sb2)) {
System.out.println("Strange");
}
if("xyz".<warning descr="Suspicious call 'equals' on 'StringBuilder' object">equals</warning>(sb1)) {
if("xyz".<warning descr="Suspicious call to 'equals()' on 'StringBuilder' object">equals</warning>(sb1)) {
System.out.println("Strange");
}
if(Objects.<warning descr="Suspicious call 'equals' on 'StringBuilder' object">equals</warning>(sb1, sb2)) {
if(Objects.<warning descr="Suspicious call to 'equals()' on 'StringBuilder' object">equals</warning>(sb1, sb2)) {
System.out.println("Strange");
}
}

View File

@@ -4,12 +4,12 @@ import java.util.Arrays;
import java.util.List;
class ArraysAsListWithZeroOrOneArgument {{
Arrays.<warning descr="Call to 'asList' to create an empty List">asList</warning>();
Arrays.<warning descr="Call to 'asList' with only one argument">asList</warning>("one");
Arrays.<warning descr="Call to 'asList()' to create an empty List">asList</warning>();
Arrays.<warning descr="Call to 'asList()' with only one argument">asList</warning>("one");
Arrays.asList("one", "two");
Arrays.asList(new String[] {"asdf", "foo"});
List<String[]> arr = Arrays.<String[]><warning descr="Call to 'asList' with only one argument">asList</warning>(new String[10]);
List<String[]> arr = Arrays.<String[]><warning descr="Call to 'asList()' with only one argument">asList</warning>(new String[10]);
List<String> arr1 = Arrays.asList(new String[10]);
List<String> arr2 = Arrays.<warning descr="Call to 'asList' to create an empty List">asList</warning>(new String[0]);
List<String> arr3 = Arrays.<warning descr="Call to 'asList' to create an empty List">asList</warning>(new String[] {});
List<String> arr2 = Arrays.<warning descr="Call to 'asList()' to create an empty List">asList</warning>(new String[0]);
List<String> arr3 = Arrays.<warning descr="Call to 'asList()' to create an empty List">asList</warning>(new String[] {});
}}

View File

@@ -2,15 +2,15 @@
public class SubstringInAppend {
static {
StringBuilder sb = new StringBuilder();
sb.append("xxx".<warning descr="Call to 'substring' is redundant">substring</warning>(3, 5));
sb.append("xxx".<warning descr="Call to 'substring()' is redundant">substring</warning>(3, 5));
}
SubstringInAppend() {
StringBuilder sb = new StringBuilder();
sb.append("xxx".<warning descr="Call to 'substring' is redundant">substring</warning>(3, 5));
sb.append("xxx".<warning descr="Call to 'substring()' is redundant">substring</warning>(3, 5));
}
public void doWork(StringBuilder sb) {
sb.append("xxx".<warning descr="Call to 'substring' is redundant">substring</warning>(3, 5));
sb.append("xxx".<warning descr="Call to 'substring()' is redundant">substring</warning>(3, 5));
}
}

View File

@@ -2,13 +2,13 @@ import java.io.*;
class Test implements Externalizable {
private static final long <warning descr="The 'serialVersionUID' can be annotated with @Serial annotation">serialVersionUID</warning> = 7874493593505141603L;
private static final long <warning descr="'serialVersionUID' can be annotated with @Serial annotation">serialVersionUID</warning> = 7874493593505141603L;
public Object <warning descr="The 'writeReplace' can be annotated with @Serial annotation">writeReplace</warning>() throws ObjectStreamException {
public Object <warning descr="'writeReplace()' can be annotated with @Serial annotation">writeReplace</warning>() throws ObjectStreamException {
return 1;
}
protected Object <warning descr="The 'readResolve' can be annotated with @Serial annotation">readResolve</warning>() throws ObjectStreamException {
protected Object <warning descr="'readResolve()' can be annotated with @Serial annotation">readResolve</warning>() throws ObjectStreamException {
return 1;
}
@@ -22,13 +22,13 @@ class Test implements Externalizable {
}
record R() implements Externalizable {
private static final long <warning descr="The 'serialVersionUID' can be annotated with @Serial annotation">serialVersionUID</warning> = 7874493593505141603L;
private static final long <warning descr="'serialVersionUID' can be annotated with @Serial annotation">serialVersionUID</warning> = 7874493593505141603L;
public Object <warning descr="The 'writeReplace' can be annotated with @Serial annotation">writeReplace</warning>() throws ObjectStreamException {
public Object <warning descr="'writeReplace()' can be annotated with @Serial annotation">writeReplace</warning>() throws ObjectStreamException {
return 1;
}
protected Object <warning descr="The 'readResolve' can be annotated with @Serial annotation">readResolve</warning>() throws ObjectStreamException {
protected Object <warning descr="'readResolve()' can be annotated with @Serial annotation">readResolve</warning>() throws ObjectStreamException {
return 1;
}

View File

@@ -2,36 +2,36 @@ import java.io.*;
class Test implements Serializable {
private static final long <warning descr="The 'serialVersionUID' can be annotated with @Serial annotation">serialVersionUID</warning> = 7874493593505141603L;
private static final ObjectStreamField[] <warning descr="The 'serialPersistentFields' can be annotated with @Serial annotation">serialPersistentFields</warning> = new ObjectStreamField[0];
private static final long <warning descr="'serialVersionUID' can be annotated with @Serial annotation">serialVersionUID</warning> = 7874493593505141603L;
private static final ObjectStreamField[] <warning descr="'serialPersistentFields' can be annotated with @Serial annotation">serialPersistentFields</warning> = new ObjectStreamField[0];
private void <warning descr="The 'writeObject' can be annotated with @Serial annotation">writeObject</warning>(ObjectOutputStream out) throws IOException {
private void <warning descr="'writeObject()' can be annotated with @Serial annotation">writeObject</warning>(ObjectOutputStream out) throws IOException {
}
private void <warning descr="The 'readObject' can be annotated with @Serial annotation">readObject</warning>(ObjectInputStream in) throws IOException, ClassNotFoundException {
private void <warning descr="'readObject()' can be annotated with @Serial annotation">readObject</warning>(ObjectInputStream in) throws IOException, ClassNotFoundException {
}
private void <warning descr="The 'readObjectNoData' can be annotated with @Serial annotation">readObjectNoData</warning>() throws ObjectStreamException {
private void <warning descr="'readObjectNoData()' can be annotated with @Serial annotation">readObjectNoData</warning>() throws ObjectStreamException {
}
public Object <warning descr="The 'writeReplace' can be annotated with @Serial annotation">writeReplace</warning>() throws ObjectStreamException {
public Object <warning descr="'writeReplace()' can be annotated with @Serial annotation">writeReplace</warning>() throws ObjectStreamException {
return 1;
}
protected Object <warning descr="The 'readResolve' can be annotated with @Serial annotation">readResolve</warning>() throws ObjectStreamException {
protected Object <warning descr="'readResolve()' can be annotated with @Serial annotation">readResolve</warning>() throws ObjectStreamException {
return 1;
}
}
record R() implements Serializable {
private static final long <warning descr="The 'serialVersionUID' can be annotated with @Serial annotation">serialVersionUID</warning> = 7874493593505141603L;
private static final long <warning descr="'serialVersionUID' can be annotated with @Serial annotation">serialVersionUID</warning> = 7874493593505141603L;
private static final ObjectStreamField[] serialPersistentFields = new ObjectStreamField[0];
public Object <warning descr="The 'writeReplace' can be annotated with @Serial annotation">writeReplace</warning>() throws ObjectStreamException {
public Object <warning descr="'writeReplace()' can be annotated with @Serial annotation">writeReplace</warning>() throws ObjectStreamException {
return 1;
}
protected Object <warning descr="The 'readResolve' can be annotated with @Serial annotation">readResolve</warning>() throws ObjectStreamException {
protected Object <warning descr="'readResolve()' can be annotated with @Serial annotation">readResolve</warning>() throws ObjectStreamException {
return 1;
}

View File

@@ -7,11 +7,11 @@ record R1() implements Externalizable {
private static final ObjectStreamField[] serialPersistentFields = new ObjectStreamField[0];
@Override
public void <warning descr="The 'writeExternal' is ignored during record serialization">writeExternal</warning>(ObjectOutput out) throws IOException {
public void <warning descr="'writeExternal()' will be ignored during record serialization">writeExternal</warning>(ObjectOutput out) throws IOException {
}
@Override
public void <warning descr="The 'readExternal' is ignored during record serialization">readExternal</warning>(ObjectInput in) throws IOException, ClassNotFoundException {
public void <warning descr="'readExternal()' will be ignored during record serialization">readExternal</warning>(ObjectInput in) throws IOException, ClassNotFoundException {
}
@Serial

View File

@@ -4,18 +4,18 @@ record R1() implements Serializable {
@Serial
private static final long serialVersionUID = 7874493593505141603L;
@Serial
private static final ObjectStreamField[] <warning descr="The 'serialPersistentFields' is ignored during record serialization">serialPersistentFields</warning> = new ObjectStreamField[0];
private static final ObjectStreamField[] <warning descr="'serialPersistentFields' will be ignored during record serialization">serialPersistentFields</warning> = new ObjectStreamField[0];
@Serial
private void <warning descr="The 'writeObject' is ignored during record serialization">writeObject</warning>(ObjectOutputStream out) throws IOException {
private void <warning descr="'writeObject()' will be ignored during record serialization">writeObject</warning>(ObjectOutputStream out) throws IOException {
}
@Serial
private void <warning descr="The 'readObject' is ignored during record serialization">readObject</warning>(ObjectInputStream in) throws IOException, ClassNotFoundException {
private void <warning descr="'readObject()' will be ignored during record serialization">readObject</warning>(ObjectInputStream in) throws IOException, ClassNotFoundException {
}
@Serial
private void <warning descr="The 'readObjectNoData' is ignored during record serialization">readObjectNoData</warning>() throws ObjectStreamException {
private void <warning descr="'readObjectNoData()' will be ignored during record serialization">readObjectNoData</warning>() throws ObjectStreamException {
}
@Serial

View File

@@ -9,17 +9,17 @@ public class UnqualifiedMethodAccess extends JPanel {
void foo() {}
void bar() {
<warning descr="Instance method call 'foo' is not qualified with 'this'">foo</warning>();
<warning descr="Instance method call 'foo()' is not qualified with 'this'">foo</warning>();
}
void foo(String s) {
this.foo();
class A {
void a() {
<warning descr="Instance method call 'a' is not qualified with 'this'">a</warning>();
<warning descr="Instance method call 'a()' is not qualified with 'this'">a</warning>();
new Object() {
void b() {
<warning descr="Instance method call 'a' is not qualified with 'this'">a</warning>();
<warning descr="Instance method call 'a()' is not qualified with 'this'">a</warning>();
}
};
}
@@ -31,8 +31,8 @@ public class UnqualifiedMethodAccess extends JPanel {
void bar() {
new Object() {
void foo() {
<warning descr="Instance method call 'bar' is not qualified with 'this'">bar</warning>();
<warning descr="Instance method call 'foo' is not qualified with 'this'">foo</warning>();
<warning descr="Instance method call 'bar()' is not qualified with 'this'">bar</warning>();
<warning descr="Instance method call 'foo()' is not qualified with 'this'">foo</warning>();
}
};
}

View File

@@ -22,7 +22,7 @@ public class AddSerialAnnotationFixTest extends LightJavaInspectionTestCase {
public void testAdditionToField() {
doTest("import java.io.*;\n" +
"class Test implements Serializable {\n" +
" private static final long <warning descr=\"The 'serialVersionUID' can be annotated with @Serial annotation\"><caret>serialVersionUID</warning> = 7874493593505141603L;\n" +
" private static final long /*'serialVersionUID' can be annotated with @Serial annotation*//*_*/serialVersionUID/**/ = 7874493593505141603L;\n" +
"}");
checkQuickFix("Annotate field 'serialVersionUID' as @Serial", "import java.io.*;\n" +
"class Test implements Serializable {\n" +
@@ -34,7 +34,7 @@ public class AddSerialAnnotationFixTest extends LightJavaInspectionTestCase {
public void testAdditionToMethod() {
doTest("import java.io.*;\n" +
"class Test implements Serializable {\n" +
" protected Object <warning descr=\"The 'readResolve' can be annotated with @Serial annotation\"><caret>readResolve</warning>() throws ObjectStreamException {\n" +
" protected Object /*'readResolve()' can be annotated with @Serial annotation*//*_*/readResolve/**/() throws ObjectStreamException {\n" +
" return 1;\n" +
" }\n" +
"}");