From 9b25e5018318ce7bb797a86671b4870841d0cdd5 Mon Sep 17 00:00:00 2001 From: chrisly42 Date: Mon, 17 Feb 2020 20:17:33 +0100 Subject: [PATCH] Improvements for TwistedAssertionInspection to no longer report .class types as constant to bother, nor matches() and doesNotMatch() for regexps. If both sides are constants, they will only show as weak problems. --- README.md | 14 +++++ build.gradle | 5 ++ .../inspections/TwistedAssertionInspection.kt | 57 ++++++++++++------- .../TwistedAssertionInspectionTest.kt | 2 +- .../TwistedAssertionAfter.java | 8 +++ .../TwistedAssertionBefore.java | 8 +++ 6 files changed, 73 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 97ca2c5..745219e 100644 --- a/README.md +++ b/README.md @@ -502,6 +502,15 @@ You can toggle the various inspections in the Settings/Editor/Inspections in the ``` There are, of course, more variations of the theme. + + If both sides of an assertion are constant expressions, the problem will only appear as + a weak warning without a quick fix. + + Constants used on the actual side of ```.matches()``` and ```doesNotMatch()``` will not be + reported for regular expression testing. + + Neither will a ```Class``` type be considered a constant in the classic sense, so + ```assertThat(SomeClass.class).isAssignableFrom(SomeOtherClass.class)``` will not be reported. - BogusAssertion @@ -785,6 +794,11 @@ Feel free to use the code (in package ```de.platon42.intellij.jupiter```) for yo ## Changelog #### V1.9 (unreleased) +- TwistedAssertion inspection will no longer warn for ```.matches()``` and ```doesNotMatch()``` for regular expressions. + Apparently, ```assertThat("somestring").matches(regex)``` is a valid test if the regex is what needs to be tested. + If the actual expression is of ```Class``` type, this will no longer be reported. +- If the expected expression in TwistedAssertion is also a constant, the warning will be weakened and + no quick fix will be available. - BogusAssertion inspection will no longer warn if the expression contains method calls. Moreover, for assertions of ```isEqualTo()``` and ```hasSameHashCodeAs()```, AND if the containing method name contains 'equal' or 'hashcode', the warning will be reduced to information level as the assertion may be testing ```equals()``` or ```hashCode()``` for validity. diff --git a/build.gradle b/build.gradle index 1b44ca2..ffea035 100644 --- a/build.gradle +++ b/build.gradle @@ -45,6 +45,11 @@ patchPluginXml { changeNotes """

V1.9 (unreleased)