Rename Java inspections

Imperative names changed to declarative
Keywords/method names quoted
Cosmetics
This commit is contained in:
Tagir Valeev
2018-10-05 10:29:14 +07:00
parent 960c959b39
commit 422d8fad2f
21 changed files with 60 additions and 65 deletions

View File

@@ -205,7 +205,7 @@
<globalInspection groupPath="Java" language="JAVA" shortName="UNUSED_IMPORT" bundle="messages.InspectionsBundle" key="unused.import.display.name"
groupBundle="messages.InspectionsBundle" groupKey="group.names.imports" enabledByDefault="true" level="WARNING"
implementationClass="com.intellij.codeInspection.unusedImport.UnusedImportInspection"/>
<globalInspection groupPath="Java" language="JAVA" shortName="RedundantThrows" displayName="Redundant throws clause" groupKey="group.names.declaration.redundancy" groupBundle="messages.InspectionsBundle"
<globalInspection groupPath="Java" language="JAVA" shortName="RedundantThrows" displayName="Redundant 'throws' clause" groupKey="group.names.declaration.redundancy" groupBundle="messages.InspectionsBundle"
enabledByDefault="true" level="WARNING"
implementationClass="com.intellij.codeInspection.unneededThrows.RedundantThrowsDeclarationInspection"/>
<globalInspection groupPath="Java" language="JAVA" shortName="SameReturnValue" bundle="messages.InspectionsBundle" key="inspection.same.return.value.display.name"

View File

@@ -614,7 +614,7 @@
implementationClass="com.intellij.codeInspection.IdempotentLoopBodyInspection"/>
<localInspection language="JAVA" shortName="ConditionalBreakInInfiniteLoop" enabledByDefault="true" level="WARNING"
groupPath="Java" groupBundle="messages.InspectionsBundle" groupKey="group.names.control.flow.issues"
bundle="messages.InspectionsBundle" key="inspection.conditional.break.in.infinite.loop"
bundle="messages.InspectionsBundle" key="inspection.conditional.break.in.infinite.loop.description"
implementationClass="com.intellij.codeInspection.ConditionalBreakInInfiniteLoopInspection"/>
<localInspection language="JAVA" shortName="JavaReflectionMemberAccess" enabledByDefault="true" level="WARNING"
groupPath="Java" groupBundle="messages.InspectionsBundle" groupKey="group.names.reflective.access.issues"
@@ -652,7 +652,7 @@
groupBundle="messages.InspectionsBundle"
groupKey="group.names.code.style.issues" enabledByDefault="true" level="WARNING"
implementationClass="com.intellij.codeInspection.OptionalIsPresentInspection"
displayName="Replace Optional.isPresent() checks with functional-style expressions"/>
displayName="Optional.isPresent() can be replaced with functional-style expression"/>
<localInspection groupPath="Java" language="JAVA" shortName="OptionalGetWithoutIsPresent"
groupBundle="messages.InspectionsBundle"
groupKey="group.names.probable.bugs" enabledByDefault="true" level="WARNING"
@@ -678,17 +678,17 @@
groupBundle="messages.InspectionsBundle"
groupKey="group.names.performance.issues" enabledByDefault="true" level="WARNING"
implementationClass="com.intellij.codeInspection.ReplaceInefficientStreamCountInspection"
displayName="Replace inefficient Stream API call chains ending with count()"/>
displayName="Inefficient Stream API call chains ending with count()"/>
<localInspection groupPath="Java,Java language level migration aids" language="JAVA" shortName="ComparatorCombinators"
groupBundle="messages.InspectionsBundle"
groupKey="group.names.language.level.specific.issues.and.migration.aids8" enabledByDefault="true" level="WARNING"
implementationClass="com.intellij.codeInspection.ComparatorCombinatorsInspection"
displayName="Use Comparator combinators"/>
displayName="Comparator combinator can be used"/>
<localInspection groupPath="Java" language="JAVA" shortName="UseBulkOperation"
groupBundle="messages.InspectionsBundle"
groupKey="group.names.performance.issues" enabledByDefault="true" level="WARNING"
implementationClass="com.intellij.codeInspection.bulkOperation.UseBulkOperationInspection"
displayName="Use bulk operation instead of iteration"/>
displayName="Bulk operation can be used instead of iteration"/>
<localInspection groupPath="Java" language="JAVA" shortName="SimplifyCollector"
groupBundle="messages.InspectionsBundle"
groupKey="group.names.declaration.redundancy" enabledByDefault="true" level="WARNING"
@@ -698,12 +698,12 @@
groupBundle="messages.InspectionsBundle"
groupKey="group.names.declaration.redundancy" enabledByDefault="true" level="WARNING"
implementationClass="com.intellij.codeInspection.SimplifyOptionalCallChainsInspection"
displayName="Simplify Optional call chains"/>
displayName="Optional call chain can be simplified"/>
<localInspection groupPath="Java" language="JAVA" shortName="SimplifyStreamApiCallChains"
groupBundle="messages.InspectionsBundle"
groupKey="group.names.declaration.redundancy" enabledByDefault="true" level="WARNING"
implementationClass="com.intellij.codeInspection.SimplifyStreamApiCallChainsInspection"
displayName="Simplify stream API call chains"/>
displayName="Stream API call chain can be simplified"/>
<localInspection groupPath="Java" language="JAVA" shortName="ObviousNullCheck"
groupBundle="messages.InspectionsBundle"
groupKey="group.names.declaration.redundancy" enabledByDefault="true" level="WARNING"
@@ -743,7 +743,7 @@
groupBundle="messages.InspectionsBundle"
groupKey="group.names.language.level.specific.issues.and.migration.aids8" enabledByDefault="true" level="WARNING"
implementationClass="com.intellij.codeInspection.java18api.Java8MapApiInspection"
displayName="Replace with single Map method"/>
displayName="Single Map method can be used"/>
<localInspection groupPath="Java,Java language level migration aids" language="JAVA" shortName="Java8CollectionRemoveIf"
groupBundle="messages.InspectionsBundle"
groupKey="group.names.language.level.specific.issues.and.migration.aids8" enabledByDefault="true" level="WARNING"

View File

@@ -56,7 +56,7 @@ public class RedundantExplicitCloseInspection extends AbstractBaseJavaLocalInspe
@NotNull
@Override
public String getFamilyName() {
return InspectionsBundle.message("inspection.redundant.explicit.close.fix.name");
return CommonQuickFixBundle.message("fix.remove.redundant", "close()");
}
@Override

View File

@@ -1,4 +1,4 @@
// "Remove redundant close" "true"
// "Remove redundant 'close()'" "true"
class MyAutoCloseable implements AutoCloseable {
@Override

View File

@@ -1,4 +1,4 @@
// "Remove redundant close" "true"
// "Remove redundant 'close()'" "true"
class MyAutoCloseable implements AutoCloseable {
@Override

View File

@@ -1,4 +1,4 @@
// "Remove redundant close" "true"
// "Remove redundant 'close()'" "true"
class MyAutoCloseable implements AutoCloseable {
@Override

View File

@@ -1,4 +1,4 @@
// "Remove redundant close" "true"
// "Remove redundant 'close()'" "true"
class MyAutoCloseable implements AutoCloseable {
@Override

View File

@@ -1,4 +1,4 @@
// "Remove redundant close" "false"
// "Remove redundant 'close()'" "false"
class MyAutoCloseable implements AutoCloseable {
@Override

View File

@@ -1,4 +1,4 @@
// "Remove redundant close" "true"
// "Remove redundant 'close()'" "true"
class MyAutoCloseable implements AutoCloseable {
@Override

View File

@@ -1,4 +1,4 @@
// "Remove redundant close" "true"
// "Remove redundant 'close()'" "true"
class MyAutoCloseable implements AutoCloseable {
@Override

View File

@@ -3,13 +3,7 @@ package com.intellij.java.codeInsight.daemon.quickFix;
import com.intellij.codeInsight.daemon.quickFix.LightQuickFixParameterizedTestCase;
import com.intellij.codeInspection.LocalInspectionTool;
import com.intellij.codeInspection.OptionalIsPresentInspection;
import com.intellij.codeInspection.RedundantExplicitCloseInspection;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.testFramework.IdeaTestUtil;
import com.intellij.testFramework.LightProjectDescriptor;
import com.intellij.testFramework.PsiTestUtil;
import com.intellij.testFramework.fixtures.DefaultLightProjectDescriptor;
import org.jetbrains.annotations.NotNull;

View File

@@ -7,6 +7,7 @@
fix.unwrap.statement=Unwrap ''{0}'' statement
fix.remove=Remove ''{0}''
fix.remove.redundant=Remove redundant ''{0}''
fix.remove.statement=Remove ''{0}'' statement
fix.replace.with.x=Replace with ''{0}''

View File

@@ -119,13 +119,13 @@ inspection.redundant.cast.remove.quickfix=Remove redundant cast(s)
inspection.redundant.cast.problem.descriptor=Casting {0} to {1} is redundant
#redundant throws
inspection.redundant.throws.display.name=Redundant throws clause
inspection.redundant.throws.remove.quickfix=Remove unnecessary throws declarations
inspection.redundant.throws.display.name=Redundant 'throws' clause
inspection.redundant.throws.remove.quickfix=Remove unnecessary 'throws' declarations
inspection.redundant.throws.problem.descriptor=The declared exception {0} is never thrown in method implementations
inspection.redundant.throws.problem.descriptor1=The declared exception {0} is never thrown in this method, nor in its derivables
inspection.redundant.throws.problem.descriptor2=The declared exception {0} is never thrown
inspection.equals.hashcode.display.name=equals() and hashCode() not paired
inspection.equals.hashcode.display.name='equals()' and 'hashCode()' not paired
inspection.equals.hashcode.only.one.defined.problem.descriptor=Class has {0} defined but does not define {1}
inspection.equals.hashcode.generate.equals.quickfix=Generate 'equals()'
inspection.equals.hashcode.generate.hashcode.quickfix=Generate 'hashCode()'
@@ -145,7 +145,7 @@ inspection.local.can.be.final.option4=Report variables which are implicit final
inspection.can.be.local.parameter.problem.descriptor=Parameter <code>#ref</code> can have <code>final</code> modifier
inspection.can.be.local.variable.problem.descriptor=Variable <code>#ref</code> can have <code>final</code> modifier
inspection.return.separated.from.computation.name=Return separated from computation of result
inspection.return.separated.from.computation.name='return' separated from the result computation
inspection.return.separated.from.computation.descriptor=Return separated from computation of value of ''{0}''
inspection.return.separated.from.computation.quickfix=Move ''return'' closer to computation of the value of ''{0}''
inspection.return.separated.from.computation.family.quickfix=Move 'return' closer to computation of the result
@@ -951,7 +951,7 @@ navigate.to.duplicate.fix=Navigate to duplicate
inspection.idempotent.loop.body=Idempotent loop body
inspection.undeclared.service.usage.name=Usage of service not declared in module-info
inspection.undeclared.service.usage.name=Usage of service not declared in 'module-info'
inspection.undeclared.service.usage.message=Usage of service ''{0}'' is not declared in module-info
inspection.conditional.break.in.infinite.loop=Move condition to loop
@@ -972,8 +972,7 @@ inspection.simplifiable.comparator.fix.reversed.name=Replace with ''{0}'' simpli
inspection.capturing.cleaner=Runnable passed to Cleaner.register() captures ''{0}'' reference
inspection.capturing.cleaner.description=Cleaner captures object reference
inspection.redundant.explicit.close=Redundant close
inspection.redundant.explicit.close.fix.name=Remove redundant close
inspection.redundant.explicit.close=Redundant 'close()'
inspection.fold.expression.into.stream.display.name=Expression can be folded into Stream chain
inspection.fold.expression.into.stream.fix.name=Fold expression into Stream chain
inspection.fold.expression.into.string.display.name=Expression can be folded into 'String.join'

View File

@@ -523,7 +523,7 @@ cyclomatic.complexity.display.name=Overly complex method
constant.on.lhs.of.comparison.display.name=Constant on left side of comparison
final.class.display.name='final' class
labeled.statement.display.name=Labeled statement
notify.called.on.condition.display.name='notify()' or 'notifyAll()' called on 'java.util.concurrent.locks.Condition' object
notify.called.on.condition.display.name='notify()' or 'notifyAll()' called on 'java.util.concurrent.locks.Condition' object
loop.statements.that.dont.loop.display.name=Loop statement that does not loop
thread.run.display.name=Call to 'Thread.run()'
non.synchronized.method.overrides.synchronized.method.display.name=Unsynchronized method overrides synchronized method
@@ -1599,7 +1599,7 @@ unnecessary.tostring.call.display.name=Unnecessary call to 'toString()'
unnecessary.tostring.call.problem.descriptor=Unnecessary <code>#ref()</code> call #loc
throwable.not.thrown.display.name=Throwable not thrown
throwable.result.of.method.call.ignored.problem.descriptor=Result of <code>#ref()</code> not thrown #loc
char.used.in.arithmetic.context.display.name=Char expression used in arithmetic context
char.used.in.arithmetic.context.display.name='char' expression used in arithmetic context
char.used.in.arithmetic.context.problem.descriptor='char' <code>#ref</code> used in arithmetic context #loc
char.used.in.arithmetic.context.quickfix=Convert to String literal
char.used.in.arithmetic.context.cast.quickfix=Insert cast to {0}
@@ -2119,7 +2119,7 @@ lambda.can.be.replaced.with.anonymous.name=Lambda can be replaced with anonymous
lambda.can.be.replaced.with.anonymous.quickfix=Replace lambda with anonymous class
method.ref.can.be.replaced.with.lambda.name=Method reference can be replaced with lambda
method.ref.can.be.replaced.with.lambda.quickfix=Replace method reference with lambda
try.statement.with.multiple.resources.name=Try statement with multiple resources can be split
try.statement.with.multiple.resources.name='try' statement with multiple resources can be split
try.statement.with.multiple.resources.quickfix=Split 'try' statement with multiple resources
multi.catch.can.be.split.name=Multi-catch can be split into separate catch blocks
multi.catch.can.be.split.quickfix=Split multi-catch into separate 'catch' blocks

View File

@@ -17,15 +17,15 @@
<psi.referenceContributor language="XML" implementation="com.theoryinpractice.testng.TestNGSuiteReferenceContributor"/>
<library.dependencyScopeSuggester implementation="com.theoryinpractice.testng.configuration.TestNGDependencyScopeSuggester"/>
<localInspection groupPath="Java" language="JAVA" shortName="JUnitTestNG" displayName="Convert JUnit Tests to TestNG" groupName="TestNG" enabledByDefault="false"
<localInspection groupPath="Java" language="JAVA" shortName="JUnitTestNG" displayName="JUnit Test can be converted to TestNG" groupName="TestNG" enabledByDefault="false"
level="WARNING" implementationClass="com.theoryinpractice.testng.inspection.JUnitConvertTool"/>
<localInspection groupPath="Java" language="JAVA" shortName="ConvertOldAnnotations" displayName="Convert old @Configuration TestNG annotations" groupName="TestNG"
<localInspection groupPath="Java" language="JAVA" shortName="ConvertOldAnnotations" displayName="Old TestNG annotation @Configuration is used" groupName="TestNG"
enabledByDefault="false" level="WARNING"
implementationClass="com.theoryinpractice.testng.inspection.ConvertOldAnnotationInspection"/>
<localInspection groupPath="Java" language="JAVA" shortName="ConvertJavadoc" displayName="Convert TestNG Javadoc to 1.5 annotations" groupName="TestNG"
<localInspection groupPath="Java" language="JAVA" shortName="ConvertJavadoc" displayName="TestNG Javadoc can be converted to annotations" groupName="TestNG"
enabledByDefault="false" level="WARNING"
implementationClass="com.theoryinpractice.testng.inspection.ConvertJavadocInspection"/>
<localInspection groupPath="Java" language="JAVA" shortName="dependsOnMethodTestNG" displayName="dependsOnMethods problem" groupName="TestNG" enabledByDefault="true"
<localInspection groupPath="Java" language="JAVA" shortName="dependsOnMethodTestNG" displayName="'dependsOnMethods' problem" groupName="TestNG" enabledByDefault="true"
level="WARNING" implementationClass="com.theoryinpractice.testng.inspection.DependsOnMethodInspection"/>
<localInspection groupPath="Java" language="JAVA" shortName="groupsTestNG" displayName="Groups problem" groupName="TestNG" enabledByDefault="true" level="WARNING"
implementationClass="com.theoryinpractice.testng.inspection.DependsOnGroupsInspection"/>

View File

@@ -28,7 +28,8 @@ import org.jetbrains.annotations.NotNull;
*/
public class ConvertJavadocInspection extends AbstractBaseJavaLocalInspectionTool {
@NonNls private static final String TESTNG_PREFIX = "testng.";
private static final String DISPLAY_NAME = "Convert TestNG Javadoc to 1.5 annotations";
static final String FIX_NAME = "Convert TestNG Javadoc to 1.5 annotations";
private static final String INSPECTION_NAME = "TestNG Javadoc can be converted to annotations";
@Override
@Nls
@@ -41,7 +42,7 @@ public class ConvertJavadocInspection extends AbstractBaseJavaLocalInspectionToo
@Nls
@NotNull
public String getDisplayName() {
return DISPLAY_NAME;
return INSPECTION_NAME;
}
@Override
@@ -57,7 +58,7 @@ public class ConvertJavadocInspection extends AbstractBaseJavaLocalInspectionToo
return new JavaElementVisitor() {
@Override public void visitDocTag(final PsiDocTag tag) {
if (tag.getName().startsWith(TESTNG_PREFIX)) {
holder.registerProblem(tag, DISPLAY_NAME, new ConvertJavadocQuickfix());
holder.registerProblem(tag, INSPECTION_NAME, new ConvertJavadocQuickfix());
}
}
};
@@ -69,7 +70,7 @@ public class ConvertJavadocInspection extends AbstractBaseJavaLocalInspectionToo
@Override
@NotNull
public String getFamilyName() {
return DISPLAY_NAME;
return FIX_NAME;
}
@Override
@@ -150,7 +151,7 @@ public class ConvertJavadocInspection extends AbstractBaseJavaLocalInspectionToo
try {
PsiModifierList modifierList = member.getModifierList();
PsiAnnotation annotation =
JavaPsiFacade.getInstance(tag.getProject()).getElementFactory().createAnnotationFromText(annotationText.toString(), member);
JavaPsiFacade.getElementFactory(tag.getProject()).createAnnotationFromText(annotationText.toString(), member);
final PsiElement inserted = modifierList.addBefore(annotation, modifierList.getFirstChild());
JavaCodeStyleManager.getInstance(project).shortenClassReferences(inserted);
@@ -164,7 +165,7 @@ public class ConvertJavadocInspection extends AbstractBaseJavaLocalInspectionToo
if (element instanceof PsiWhiteSpace) continue;
if (!(element instanceof PsiDocToken)) return;
PsiDocToken docToken = (PsiDocToken)element;
if (docToken.getTokenType() == JavaDocTokenType.DOC_COMMENT_DATA && docToken.getText().trim().length() > 0) {
if (docToken.getTokenType() == JavaDocTokenType.DOC_COMMENT_DATA && !docToken.getText().trim().isEmpty()) {
return;
}
}

View File

@@ -24,7 +24,8 @@ import org.jetbrains.annotations.NotNull;
* @author Hani Suleiman
*/
public class ConvertOldAnnotationInspection extends AbstractBaseJavaLocalInspectionTool {
private static final String DISPLAY_NAME = "Convert old @Configuration TestNG annotations";
private static final String DISPLAY_NAME = "Old TestNG annotation @Configuration is used";
static final String FIX_NAME = "Convert old @Configuration TestNG annotations";
@Override
@Nls
@@ -66,7 +67,7 @@ public class ConvertOldAnnotationInspection extends AbstractBaseJavaLocalInspect
@Override
@NotNull
public String getFamilyName() {
return DISPLAY_NAME;
return FIX_NAME;
}
@Override
@@ -111,13 +112,12 @@ public class ConvertOldAnnotationInspection extends AbstractBaseJavaLocalInspect
@NonNls String newAnnotation) throws IncorrectOperationException {
PsiAnnotationParameterList list = annotation.getParameterList();
Project project = annotation.getProject();
for (PsiNameValuePair pair : list.getAttributes()) {
if (attribute.equals(pair.getName())) {
final StringBuilder newAnnotationBuffer = new StringBuilder();
newAnnotationBuffer.append(newAnnotation).append('(').append(')');
final PsiElementFactory factory = JavaPsiFacade.getInstance(annotation.getProject()).getElementFactory();
final PsiAnnotation newPsiAnnotation = factory.createAnnotationFromText(newAnnotationBuffer.toString(), modifierList);
JavaCodeStyleManager.getInstance(annotation.getProject()).shortenClassReferences(modifierList.addAfter(newPsiAnnotation, null));
final PsiElementFactory factory = JavaPsiFacade.getElementFactory(project);
final PsiAnnotation newPsiAnnotation = factory.createAnnotationFromText(newAnnotation + "()", modifierList);
JavaCodeStyleManager.getInstance(project).shortenClassReferences(modifierList.addAfter(newPsiAnnotation, null));
}
}
}

View File

@@ -24,7 +24,7 @@ import java.util.regex.Pattern;
*/
public class DependsOnMethodInspection extends AbstractBaseJavaLocalInspectionTool {
private static final Logger LOGGER = Logger.getInstance("TestNG Runner");
private static final Pattern PATTERN = Pattern.compile("\"([a-zA-Z1-9_\\(\\)\\*]*)\"");
private static final Pattern PATTERN = Pattern.compile("\"([a-zA-Z1-9_()*]*)\"");
@NotNull
@Override
@@ -35,7 +35,7 @@ public class DependsOnMethodInspection extends AbstractBaseJavaLocalInspectionTo
@NotNull
@Override
public String getDisplayName() {
return "dependsOnMethods problem";
return "'dependsOnMethods' problem";
}
@NotNull
@@ -105,7 +105,7 @@ public class DependsOnMethodInspection extends AbstractBaseJavaLocalInspectionTo
List<ProblemDescriptor> problemDescriptors,
boolean onTheFly) {
LOGGER.debug("Found dependsOnMethods with text: " + methodName);
if (methodName.length() > 0 && methodName.charAt(methodName.length() - 1) == ')') {
if (!methodName.isEmpty() && methodName.charAt(methodName.length() - 1) == ')') {
LOGGER.debug("dependsOnMethods contains ()" + psiClass.getName());
// TODO Add quick fix for removing brackets on annotation

View File

@@ -29,7 +29,7 @@ import java.util.Map;
public class JUnitConvertTool extends AbstractBaseJavaLocalInspectionTool {
private static final Logger LOG = Logger.getInstance("TestNG QuickFix");
private static final String DISPLAY_NAME = "Convert JUnit Tests to TestNG";
private static final String DISPLAY_NAME = "JUnit Test can be converted to TestNG";
private static final Map<String, String> ANNOTATIONS_MAP;
public static final String QUICKFIX_NAME = "Convert TestCase to TestNG";
@@ -299,19 +299,9 @@ public class JUnitConvertTool extends AbstractBaseJavaLocalInspectionTool {
newComment = factory.createCommentFromText(commentString, null);
comment.replace(newComment);
}
else {
String commentString;
StringBuilder commentBuffer = new StringBuilder();
commentBuffer.append("/**\n");
commentBuffer.append(javaDocLine);
commentBuffer.append('\n');
commentBuffer.append(" */");
commentString = commentBuffer.toString();
newComment = factory.createCommentFromText(commentString, null);
newComment = factory.createCommentFromText("/**\n" + javaDocLine + "\n */", null);
method.addBefore(newComment, comment);
}

View File

@@ -34,6 +34,11 @@ public class ConvertJavadocInspectionTest extends BaseTestNGInspectionsTest {
doTest();
}
@Override
protected String getActionName() {
return ConvertJavadocInspection.FIX_NAME;
}
@Override
protected String getBasePath() {
return PluginPathManager.getPluginHomePathRelative("testng") + "/testData/javadoc2Annotation";

View File

@@ -27,6 +27,11 @@ public class ConvertOldAnnotationInspectionTest extends BaseTestNGInspectionsTes
return new ConvertOldAnnotationInspection();
}
@Override
protected String getActionName() {
return ConvertOldAnnotationInspection.FIX_NAME;
}
@Override
protected String getBasePath() {
return PluginPathManager.getPluginHomePathRelative("testng") + "/testData/configuration";