Rename "Result is Result" inspection to "Direct use of result type"

This commit is contained in:
Mikhail Glukhikh
2018-11-30 12:07:10 +03:00
parent 5237079c5d
commit d909162a89
31 changed files with 83 additions and 83 deletions
+2 -2
View File
@@ -3019,8 +3019,8 @@
language="kotlin"
/>
<localInspection implementationClass="org.jetbrains.kotlin.idea.inspections.coroutines.ResultIsResultInspection"
displayName="Function returning Result"
<localInspection implementationClass="org.jetbrains.kotlin.idea.inspections.coroutines.DirectUseOfResultTypeInspection"
displayName="Function returning Result directly"
groupPath="Kotlin"
groupName="Style issues"
enabledByDefault="false"
@@ -33,7 +33,7 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
import org.jetbrains.kotlin.resolve.scopes.MemberScope
import org.jetbrains.kotlin.types.KotlinType
class ResultIsResultInspection : AbstractKotlinInspection() {
class DirectUseOfResultTypeInspection : AbstractKotlinInspection() {
private fun MemberScope.hasCorrespondingNonCatchingFunction(
nameWithoutCatching: String,
@@ -5,7 +5,7 @@
<module>light_idea_test_case</module>
<package>&lt;default&gt;</package>
<entry_point TYPE="file" FQNAME="temp:///src/test.kt" />
<problem_class severity="WEAK WARNING" attribute_key="INFO_ATTRIBUTES">Function returning Result</problem_class>
<problem_class severity="WEAK WARNING" attribute_key="INFO_ATTRIBUTES">Function returning Result directly</problem_class>
<description>Function returning Result with a name that does not end with Catching</description>
</problem>
<problem>
@@ -14,7 +14,7 @@
<module>light_idea_test_case</module>
<package>&lt;default&gt;</package>
<entry_point TYPE="file" FQNAME="temp:///src/test.kt" />
<problem_class severity="WEAK WARNING" attribute_key="INFO_ATTRIBUTES">Function returning Result</problem_class>
<problem_class severity="WEAK WARNING" attribute_key="INFO_ATTRIBUTES">Function returning Result directly</problem_class>
<description>Function returning Result with a name that does not end with Catching</description>
</problem>
<problem>
@@ -23,7 +23,7 @@
<module>light_idea_test_case</module>
<package>&lt;default&gt;</package>
<entry_point TYPE="file" FQNAME="temp:///src/test.kt" />
<problem_class severity="WEAK WARNING" attribute_key="INFO_ATTRIBUTES">Function returning Result</problem_class>
<problem_class severity="WEAK WARNING" attribute_key="INFO_ATTRIBUTES">Function returning Result directly</problem_class>
<description>Function 'incorrectCatching' returning 'Result&lt;Double&gt;' without the corresponding function 'incorrect' returning 'Double'</description>
</problem>
<problem>
@@ -32,7 +32,7 @@
<module>light_idea_test_case</module>
<package>&lt;default&gt;</package>
<entry_point TYPE="file" FQNAME="temp:///src/test.kt" />
<problem_class severity="WEAK WARNING" attribute_key="INFO_ATTRIBUTES">Function returning Result</problem_class>
<problem_class severity="WEAK WARNING" attribute_key="INFO_ATTRIBUTES">Function returning Result directly</problem_class>
<description>Function 'strangeCatching' returning 'Result&lt;Boolean&gt;' without the corresponding function 'strange' returning 'Boolean'</description>
</problem>
<problem>
@@ -41,7 +41,7 @@
<module>light_idea_test_case</module>
<package>&lt;default&gt;</package>
<entry_point TYPE="file" FQNAME="temp:///src/test.kt" />
<problem_class severity="WEAK WARNING" attribute_key="INFO_ATTRIBUTES">Function returning Result</problem_class>
<problem_class severity="WEAK WARNING" attribute_key="INFO_ATTRIBUTES">Function returning Result directly</problem_class>
<description>Function returning Result with a name that does not end with Catching</description>
</problem>
<problem>
@@ -50,7 +50,7 @@
<module>light_idea_test_case</module>
<package>&lt;default&gt;</package>
<entry_point TYPE="file" FQNAME="temp:///src/test.kt" />
<problem_class severity="WEAK WARNING" attribute_key="INFO_ATTRIBUTES">Function returning Result</problem_class>
<problem_class severity="WEAK WARNING" attribute_key="INFO_ATTRIBUTES">Function returning Result directly</problem_class>
<description>Function returning Result with a name that does not end with Catching</description>
</problem>
<problem>
@@ -59,7 +59,7 @@
<module>light_idea_test_case</module>
<package>&lt;default&gt;</package>
<entry_point TYPE="file" FQNAME="temp:///src/test.kt" />
<problem_class severity="WEAK WARNING" attribute_key="INFO_ATTRIBUTES">Function returning Result</problem_class>
<problem_class severity="WEAK WARNING" attribute_key="INFO_ATTRIBUTES">Function returning Result directly</problem_class>
<description>Function 'classIncorrectCatching' returning 'Result&lt;Double&gt;' without the corresponding function 'classIncorrect' returning 'Double'</description>
</problem>
<problem>
@@ -68,7 +68,7 @@
<module>light_idea_test_case</module>
<package>&lt;default&gt;</package>
<entry_point TYPE="file" FQNAME="temp:///src/test.kt" />
<problem_class severity="WEAK WARNING" attribute_key="INFO_ATTRIBUTES">Function returning Result</problem_class>
<problem_class severity="WEAK WARNING" attribute_key="INFO_ATTRIBUTES">Function returning Result directly</problem_class>
<description>Function returning Result with a name that does not end with Catching</description>
</problem>
<problem>
@@ -77,7 +77,7 @@
<module>light_idea_test_case</module>
<package>&lt;default&gt;</package>
<entry_point TYPE="file" FQNAME="temp:///src/test.kt" />
<problem_class severity="WEAK WARNING" attribute_key="INFO_ATTRIBUTES">Function returning Result</problem_class>
<problem_class severity="WEAK WARNING" attribute_key="INFO_ATTRIBUTES">Function returning Result directly</problem_class>
<description>Function returning Result with a name that does not end with Catching</description>
</problem>
<problem>
@@ -86,7 +86,7 @@
<module>light_idea_test_case</module>
<package>&lt;default&gt;</package>
<entry_point TYPE="file" FQNAME="temp:///src/test.kt" />
<problem_class severity="WEAK WARNING" attribute_key="INFO_ATTRIBUTES">Function returning Result</problem_class>
<problem_class severity="WEAK WARNING" attribute_key="INFO_ATTRIBUTES">Function returning Result directly</problem_class>
<description>Function returning Result with a name that does not end with Catching</description>
</problem>
<problem>
@@ -95,7 +95,7 @@
<module>light_idea_test_case</module>
<package>&lt;default&gt;</package>
<entry_point TYPE="file" FQNAME="temp:///src/test.kt" />
<problem_class severity="WEAK WARNING" attribute_key="INFO_ATTRIBUTES">Function returning Result</problem_class>
<problem_class severity="WEAK WARNING" attribute_key="INFO_ATTRIBUTES">Function returning Result directly</problem_class>
<description>Function 'calcComplexCatching' returning 'Result&lt;Double&gt;' without the corresponding function 'calcComplex' returning 'Double'</description>
</problem>
<problem>
@@ -104,7 +104,7 @@
<module>light_idea_test_case</module>
<package>&lt;default&gt;</package>
<entry_point TYPE="file" FQNAME="temp:///src/test.kt" />
<problem_class severity="WEAK WARNING" attribute_key="INFO_ATTRIBUTES">Function returning Result</problem_class>
<problem_class severity="WEAK WARNING" attribute_key="INFO_ATTRIBUTES">Function returning Result directly</problem_class>
<description>Function 'extensionActCatching' returning 'Result&lt;Int&gt;' without the corresponding function 'extensionAct' returning 'Int'</description>
</problem>
</problems>
@@ -1 +1 @@
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.inspections.coroutines.ResultIsResultInspection
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.inspections.coroutines.DirectUseOfResultTypeInspection
@@ -0,0 +1 @@
org.jetbrains.kotlin.idea.inspections.coroutines.DirectUseOfResultTypeInspection
@@ -1 +0,0 @@
org.jetbrains.kotlin.idea.inspections.coroutines.ResultIsResultInspection
@@ -144,9 +144,9 @@ public class InspectionTestGenerated extends AbstractInspectionTest {
runTest("idea/testData/inspections/coroutines/asyncResultUnused/inspectionData/inspections.test");
}
@TestMetadata("coroutines/resultIsSuccessOrFailure/inspectionData/inspections.test")
public void testCoroutines_resultIsSuccessOrFailure_inspectionData_Inspections_test() throws Exception {
runTest("idea/testData/inspections/coroutines/resultIsSuccessOrFailure/inspectionData/inspections.test");
@TestMetadata("coroutines/directUseOfResultType/inspectionData/inspections.test")
public void testCoroutines_directUseOfResultType_inspectionData_Inspections_test() throws Exception {
runTest("idea/testData/inspections/coroutines/directUseOfResultType/inspectionData/inspections.test");
}
@TestMetadata("dataClassPrivateConstructor/inspectionData/inspections.test")
@@ -1990,6 +1990,69 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/inspectionsLocal/coroutines"), Pattern.compile("^([\\w\\-_]+)\\.(kt|kts)$"), TargetBackend.ANY, true);
}
@TestMetadata("idea/testData/inspectionsLocal/coroutines/directUseOfResultType")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class DirectUseOfResultType extends AbstractLocalInspectionTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
}
@TestMetadata("abstract.kt")
public void testAbstract() throws Exception {
runTest("idea/testData/inspectionsLocal/coroutines/directUseOfResultType/abstract.kt");
}
public void testAllFilesPresentInDirectUseOfResultType() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/inspectionsLocal/coroutines/directUseOfResultType"), Pattern.compile("^([\\w\\-_]+)\\.(kt|kts)$"), TargetBackend.ANY, true);
}
@TestMetadata("anonymous.kt")
public void testAnonymous() throws Exception {
runTest("idea/testData/inspectionsLocal/coroutines/directUseOfResultType/anonymous.kt");
}
@TestMetadata("complexBlock.kt")
public void testComplexBlock() throws Exception {
runTest("idea/testData/inspectionsLocal/coroutines/directUseOfResultType/complexBlock.kt");
}
@TestMetadata("lambdaSimple.kt")
public void testLambdaSimple() throws Exception {
runTest("idea/testData/inspectionsLocal/coroutines/directUseOfResultType/lambdaSimple.kt");
}
@TestMetadata("lambdaWithPartialReturn.kt")
public void testLambdaWithPartialReturn() throws Exception {
runTest("idea/testData/inspectionsLocal/coroutines/directUseOfResultType/lambdaWithPartialReturn.kt");
}
@TestMetadata("lambdaWithReturn.kt")
public void testLambdaWithReturn() throws Exception {
runTest("idea/testData/inspectionsLocal/coroutines/directUseOfResultType/lambdaWithReturn.kt");
}
@TestMetadata("needParentheses.kt")
public void testNeedParentheses() throws Exception {
runTest("idea/testData/inspectionsLocal/coroutines/directUseOfResultType/needParentheses.kt");
}
@TestMetadata("rename.kt")
public void testRename() throws Exception {
runTest("idea/testData/inspectionsLocal/coroutines/directUseOfResultType/rename.kt");
}
@TestMetadata("simple.kt")
public void testSimple() throws Exception {
runTest("idea/testData/inspectionsLocal/coroutines/directUseOfResultType/simple.kt");
}
@TestMetadata("simpleBlock.kt")
public void testSimpleBlock() throws Exception {
runTest("idea/testData/inspectionsLocal/coroutines/directUseOfResultType/simpleBlock.kt");
}
}
@TestMetadata("idea/testData/inspectionsLocal/coroutines/redundantAsync")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -2055,69 +2118,6 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest {
runTest("idea/testData/inspectionsLocal/coroutines/redundantRunCatching/simple.kt");
}
}
@TestMetadata("idea/testData/inspectionsLocal/coroutines/resultIsSuccessOrFailure")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class ResultIsSuccessOrFailure extends AbstractLocalInspectionTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
}
@TestMetadata("abstract.kt")
public void testAbstract() throws Exception {
runTest("idea/testData/inspectionsLocal/coroutines/resultIsSuccessOrFailure/abstract.kt");
}
public void testAllFilesPresentInResultIsSuccessOrFailure() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/inspectionsLocal/coroutines/resultIsSuccessOrFailure"), Pattern.compile("^([\\w\\-_]+)\\.(kt|kts)$"), TargetBackend.ANY, true);
}
@TestMetadata("anonymous.kt")
public void testAnonymous() throws Exception {
runTest("idea/testData/inspectionsLocal/coroutines/resultIsSuccessOrFailure/anonymous.kt");
}
@TestMetadata("complexBlock.kt")
public void testComplexBlock() throws Exception {
runTest("idea/testData/inspectionsLocal/coroutines/resultIsSuccessOrFailure/complexBlock.kt");
}
@TestMetadata("lambdaSimple.kt")
public void testLambdaSimple() throws Exception {
runTest("idea/testData/inspectionsLocal/coroutines/resultIsSuccessOrFailure/lambdaSimple.kt");
}
@TestMetadata("lambdaWithPartialReturn.kt")
public void testLambdaWithPartialReturn() throws Exception {
runTest("idea/testData/inspectionsLocal/coroutines/resultIsSuccessOrFailure/lambdaWithPartialReturn.kt");
}
@TestMetadata("lambdaWithReturn.kt")
public void testLambdaWithReturn() throws Exception {
runTest("idea/testData/inspectionsLocal/coroutines/resultIsSuccessOrFailure/lambdaWithReturn.kt");
}
@TestMetadata("needParentheses.kt")
public void testNeedParentheses() throws Exception {
runTest("idea/testData/inspectionsLocal/coroutines/resultIsSuccessOrFailure/needParentheses.kt");
}
@TestMetadata("rename.kt")
public void testRename() throws Exception {
runTest("idea/testData/inspectionsLocal/coroutines/resultIsSuccessOrFailure/rename.kt");
}
@TestMetadata("simple.kt")
public void testSimple() throws Exception {
runTest("idea/testData/inspectionsLocal/coroutines/resultIsSuccessOrFailure/simple.kt");
}
@TestMetadata("simpleBlock.kt")
public void testSimpleBlock() throws Exception {
runTest("idea/testData/inspectionsLocal/coroutines/resultIsSuccessOrFailure/simpleBlock.kt");
}
}
}
@TestMetadata("idea/testData/inspectionsLocal/delegationToVarProperty")