From 6fb23ea89cce0e63e7dd831d337b5f022d69af50 Mon Sep 17 00:00:00 2001 From: chrisly42 Date: Sat, 4 May 2019 15:36:04 +0200 Subject: [PATCH] Heavily reworked inspections for edge cases, such as multiple isEqualTo() calls inside a single statement. Corrected highlighting for most inspections. Lots of refactorings, tweakings. Added travis-ci file (untested). Added jacoco. --- .travis.yml | 11 ++ README.md | 5 + build.gradle | 24 ++- .../plugins/cajon/AssertJClassNames.kt | 9 +- .../intellij/plugins/cajon/CommonMatchers.kt | 15 ++ .../intellij/plugins/cajon/Extensions.kt | 113 ++++++++++-- .../platon42/intellij/plugins/cajon/Helper.kt | 8 + .../intellij/plugins/cajon/MethodNames.kt | 12 +- .../inspections/AbstractAssertJInspection.kt | 91 +++------- .../AbstractJUnitAssertInspection.kt | 4 - .../AssertThatBinaryExpressionInspection.kt | 28 ++- .../AssertThatBooleanConditionInspection.kt | 3 +- .../AssertThatEnumerableIsEmptyInspection.kt | 3 +- .../AssertThatGuavaOptionalInspection.kt | 144 +++++++-------- .../AssertThatInstanceOfInspection.kt | 33 ++-- ...tThatInvertedBooleanConditionInspection.kt | 31 +--- .../AssertThatJava8OptionalInspection.kt | 77 ++++---- .../inspections/AssertThatSizeInspection.kt | 166 +++++++++++------- .../AssertThatStringExpressionInspection.kt | 56 ++---- .../AssertThatStringIsEmptyInspection.kt | 3 +- .../JUnitAssertToAssertJInspection.kt | 4 +- .../JoinAssertThatStatementsInspection.kt | 6 +- .../quickfixes/AbstractCommonQuickFix.kt | 3 +- .../cajon/quickfixes/ForGuavaPostFix.kt | 3 +- .../InvertUnaryStatementQuickFix.kt | 37 ++++ .../quickfixes/JoinStatementsQuickFix.kt | 7 +- ...ActualOuterExpressionMethodCallQuickFix.kt | 22 --- .../MoveOutInstanceOfExpressionQuickFix.kt | 44 +++++ .../MoveOutMethodCallExpressionQuickFix.kt | 37 ++++ .../quickfixes/QuickFixWithPostfixDelegate.kt | 4 + .../RemoveActualOutmostMethodCallQuickFix.kt | 29 ++- .../RemoveInstanceOfExpressionQuickFix.kt | 32 ---- .../RemoveUnaryExpressionQuickFix.kt | 27 --- .../ReplaceHasSizeMethodCallQuickFix.kt | 35 ++++ .../ReplaceJUnitAssertMethodCallQuickFix.kt | 8 + ...placeJUnitDeltaAssertMethodCallQuickFix.kt | 8 + .../ReplaceSimpleMethodCallQuickFix.kt | 8 + .../ReplaceSizeMethodCallQuickFix.kt | 32 ++-- ...SplitBinaryExpressionMethodCallQuickFix.kt | 35 ++-- .../UnwrapExpectedStaticMethodCallQuickFix.kt | 8 + .../ExtractorReferenceContributor.kt | 5 +- .../intellij/playground/Playground.java | 1 + .../plugins/cajon/AbstractCajonTest.kt | 4 +- ...ssertThatBinaryExpressionInspectionTest.kt | 4 +- .../AssertThatGuavaOptionalInspectionTest.kt | 25 ++- .../AssertThatInstanceOfInspectionTest.kt | 4 +- ...tInvertedBooleanConditionInspectionTest.kt | 2 +- .../AssertThatJava8OptionalInspectionTest.kt | 14 +- .../AssertThatSizeInspectionTest.kt | 6 +- ...ssertThatStringExpressionInspectionTest.kt | 28 +-- .../AssertThatStringIsEmptyInspectionTest.kt | 7 + .../JUnitAssertToAssertJInspectionTest.kt | 2 +- .../org/assertj/core/api/AssertJExtensions.kt | 19 ++ .../BinaryExpressionAfter.java | 41 +++-- .../BinaryExpressionBefore.java | 41 +++-- .../GuavaOptional/GuavaOptionalAfter.java | 23 +-- .../GuavaOptional/GuavaOptionalBefore.java | 19 +- .../InstanceOf/InstanceOfAfter.java | 7 +- .../InstanceOf/InstanceOfBefore.java | 7 +- .../InvertedBooleanConditionAfter.java | 13 +- .../InvertedBooleanConditionBefore.java | 13 +- .../Java8Optional/Java8OptionalAfter.java | 13 +- .../Java8Optional/Java8OptionalBefore.java | 13 +- .../JoinStatements/JoinStatementsAfter.java | 2 + .../JoinStatements/JoinStatementsBefore.java | 2 + .../resources/inspections/Size/SizeAfter.java | 4 + .../inspections/Size/SizeBefore.java | 4 + .../StringExpressionAfter.java | 8 +- .../StringExpressionBefore.java | 12 +- 69 files changed, 944 insertions(+), 624 deletions(-) create mode 100644 .travis.yml create mode 100644 src/main/java/de/platon42/intellij/plugins/cajon/quickfixes/InvertUnaryStatementQuickFix.kt delete mode 100644 src/main/java/de/platon42/intellij/plugins/cajon/quickfixes/MoveActualOuterExpressionMethodCallQuickFix.kt create mode 100644 src/main/java/de/platon42/intellij/plugins/cajon/quickfixes/MoveOutInstanceOfExpressionQuickFix.kt create mode 100644 src/main/java/de/platon42/intellij/plugins/cajon/quickfixes/MoveOutMethodCallExpressionQuickFix.kt delete mode 100644 src/main/java/de/platon42/intellij/plugins/cajon/quickfixes/RemoveInstanceOfExpressionQuickFix.kt delete mode 100644 src/main/java/de/platon42/intellij/plugins/cajon/quickfixes/RemoveUnaryExpressionQuickFix.kt create mode 100644 src/main/java/de/platon42/intellij/plugins/cajon/quickfixes/ReplaceHasSizeMethodCallQuickFix.kt create mode 100644 src/test/java/org/assertj/core/api/AssertJExtensions.kt diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..39d6c9f --- /dev/null +++ b/.travis.yml @@ -0,0 +1,11 @@ +language: java +jdk: + - oraclejdk8 + - openjdk8 + +before_script: + - chmod +x gradlew + - chmod +x gradle/wrapper/gradle-wrapper.jar + +script: + - ./gradlew clean test \ No newline at end of file diff --git a/README.md b/README.md index bf58809..980d993 100644 --- a/README.md +++ b/README.md @@ -346,6 +346,11 @@ Feel free to use the code (in package de.platon42.intellij.jupiter) for your pro #### V0.8 (unreleased) - Fixed missing description for JoinAssertThatStatements and detection of equivalent expressions (sorry, released it too hastily). - Fixed ```isEmpty()``` for enumerables and strings and ```isNull()``` for object conversions to be applied only if it is the terminal method call as ```isEmpty()``` and ```isNull()``` return void. +- Heavily reworked inspections for edge cases, such as multiple ```isEqualTo()``` calls inside a single statement. +- Some inspections could generate bogus code for weird situations, this has been made more fool-proof. +- Corrected highlighting for many inspections. +- Fixed family names for inspections in batch mode. +- Reworded many inspection messages for better understanding. #### V0.7 (28-Apr-19) - Another fix for AssertThatGuavaOptional inspection regarding using the same family name for slightly different quick fix executions diff --git a/build.gradle b/build.gradle index 8fc348a..ddf12f1 100644 --- a/build.gradle +++ b/build.gradle @@ -2,6 +2,7 @@ plugins { id 'java' id 'org.jetbrains.intellij' version '0.4.8' id 'org.jetbrains.kotlin.jvm' version '1.3.31' + id 'jacoco' } group 'de.platon42' @@ -44,6 +45,11 @@ patchPluginXml {

V0.7 (28-Apr-19)