Skip to content

Commit 44e03ee

Browse files
SONARJAVA-3454 FP in S2970 when "assertThatThrownBy" is used alone
1 parent defc8ee commit 44e03ee

2 files changed

Lines changed: 2 additions & 3 deletions

File tree

java-checks-test-sources/src/main/java/checks/AssertionsCompletenessCheck.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,9 @@ public void assertj_assertions() {
9898
org.assertj.core.api.Assertions.assertThat(1).usingDefaultComparator(); // Noncompliant
9999
org.assertj.core.api.Assertions.assertThatObject(null).extracting("name"); // Noncompliant
100100
org.assertj.core.api.Assertions.assertThatObject(null).extracting("name").isEqualTo("Paul");
101-
org.assertj.core.api.Assertions.assertThatThrownBy(() -> {}).describedAs(""); // Noncompliant
101+
org.assertj.core.api.Assertions.assertThatThrownBy(() -> {}).describedAs(""); // Compliant, can be used alone (will fail if not exception is used).
102102
org.assertj.core.api.Assertions.assertThatThrownBy(() -> {}).describedAs("").hasMessage("42");
103-
org.assertj.core.api.Assertions.assertThatThrownBy(() -> {}, "desc", 42).usingComparator(null); // Noncompliant
103+
org.assertj.core.api.Assertions.assertThatThrownBy(() -> {}, "desc", 42).usingComparator(null); // Compliant
104104
org.assertj.core.api.Assertions.assertThatThrownBy(() -> {}, "desc", 42).usingComparator(null).isInstanceOf(IllegalStateException.class);
105105
org.assertj.core.api.Assertions.assertThatCode(() -> {}); // Noncompliant
106106
org.assertj.core.api.Assertions.assertThatCode(() -> {}).isInstanceOf(IllegalStateException.class);

java-checks/src/main/java/org/sonar/java/checks/tests/AssertionsCompletenessCheck.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ public class AssertionsCompletenessCheck extends BaseTreeVisitor implements Java
9999
"org.assertj.core.api.Assertions")
100100
.names(
101101
"assertThatObject",
102-
"assertThatThrownBy",
103102
"assertThatCode",
104103
"assertThatExceptionOfType",
105104
"assertThatNullPointerException",

0 commit comments

Comments
 (0)