Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions assertj-error-prone/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ dependencies {
implementation 'com.google.code.findbugs:jsr305'
implementation 'com.google.errorprone:error_prone_annotation'
implementation 'com.google.errorprone:error_prone_check_api'
implementation 'com.google.errorprone:javac'
implementation 'com.google.guava:guava'
implementation 'org.assertj:assertj-core'

Expand All @@ -19,10 +18,17 @@ dependencies {
compileOnly 'com.google.auto.service:auto-service'
}

// Incorrectly identifies tests as junit4 usage
tasks.checkJUnitDependencies.enabled = false
tasks.withType(JavaCompile) {
options.errorprone.disable 'StrictUnusedVariable', 'PreferSafeLoggingPreconditions'
moduleJvmArgs {
exports = [
'jdk.compiler/com.sun.tools.javac.api',
'jdk.compiler/com.sun.tools.javac.code',
'jdk.compiler/com.sun.tools.javac.comp',
'jdk.compiler/com.sun.tools.javac.file',
'jdk.compiler/com.sun.tools.javac.main',
'jdk.compiler/com.sun.tools.javac.model',
'jdk.compiler/com.sun.tools.javac.parser',
'jdk.compiler/com.sun.tools.javac.processing',
'jdk.compiler/com.sun.tools.javac.tree',
'jdk.compiler/com.sun.tools.javac.util',
]
}


Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public final class AssertjBooleanConjunction implements AssertjChecker {
private static final Matcher<ExpressionTree> isTrue = MethodMatchers.instanceMethod()
.onDescendantOf("org.assertj.core.api.AbstractBooleanAssert")
.named("isTrue")
.withParameters();
.withNoParameters();

private static final Matcher<Tree> isStatement =
Matchers.parentNode(Matchers.kindIs(Tree.Kind.EXPRESSION_STATEMENT));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ public final class AssertjPrimitiveComparison implements AssertjChecker {
private static final Matcher<ExpressionTree> IS_TRUE = MethodMatchers.instanceMethod()
.onDescendantOf("org.assertj.core.api.Assert")
.named("isTrue")
.withParameters();
.withNoParameters();

private static final Matcher<ExpressionTree> IS_FALSE = MethodMatchers.instanceMethod()
.onDescendantOf("org.assertj.core.api.Assert")
.named("isFalse")
.withParameters();
.withNoParameters();

private static final Matcher<ExpressionTree> BOOLEAN_ASSERT = Matchers.anyOf(IS_TRUE, IS_FALSE);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public final class AssertjSameSizeAs implements AssertjChecker {
MethodMatchers.instanceMethod()
.onDescendantOf(Collection.class.getName())
.named("size")
.withParameters(),
.withNoParameters(),
(Matcher<ExpressionTree>) (expressionTree, state) -> {
Symbol symbol = ASTHelpers.getSymbol(expressionTree);
return symbol != null
Expand All @@ -72,12 +72,12 @@ public final class AssertjSameSizeAs implements AssertjChecker {
TypePredicates.isDescendantOf(Map.class.getName()),
TypePredicates.not(TypePredicates.isDescendantOf(Iterable.class.getName()))))
.named("size")
.withParameters());
.withNoParameters());

private static final Matcher<ExpressionTree> csSizeMatcher = Matchers.ignoreParens(MethodMatchers.instanceMethod()
.onDescendantOf(CharSequence.class.getName())
.named("length")
.withParameters());
.withNoParameters());

private static final Matcher<ExpressionTree> matcher = Matchers.anyOf(
Matchers.methodInvocation(hasSizeMatcher, ChildMultiMatcher.MatchType.ALL, Matchers.anyOf(sizeMatcher)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,19 @@ public final class AssertjSize implements AssertjChecker {
MethodMatchers.instanceMethod()
.onDescendantOf(CharSequence.class.getName())
.named("length")
.withParameters(),
.withNoParameters(),
MethodMatchers.instanceMethod()
// Avoid refactoring maps which implement iterable due to ambiguity between assertThat(Iterable)
// and assertThat(Map). This could be improved in a later change to cast to a Map and refactor.
.onClass(TypePredicates.allOf(
TypePredicates.isDescendantOf(Map.class.getName()),
TypePredicates.not(TypePredicates.isDescendantOf(Iterable.class.getName()))))
.named("size")
.withParameters(),
.withNoParameters(),
MethodMatchers.instanceMethod()
.onDescendantOf(Collection.class.getName())
.named("size")
.withParameters(),
.withNoParameters(),
(Matcher<ExpressionTree>) (expressionTree, state) -> {
Symbol symbol = ASTHelpers.getSymbol(expressionTree);
return symbol != null
Expand Down Expand Up @@ -83,11 +83,11 @@ public final class AssertjSize implements AssertjChecker {
private static final Matcher<ExpressionTree> isZero = MethodMatchers.instanceMethod()
.onDescendantOf("org.assertj.core.api.Assert")
.namedAnyOf("isZero")
.withParameters();
.withNoParameters();
private static final Matcher<ExpressionTree> isNotZero = MethodMatchers.instanceMethod()
.onDescendantOf("org.assertj.core.api.Assert")
.namedAnyOf("isNotZero")
.withParameters();
.withNoParameters();
private static final Matcher<ExpressionTree> comparisonTo =
Matchers.anyOf(isEqualTo, isLessThan, isLessThanOrEqualTo, isGreaterThan, isGreaterThanOrEqualTo);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public final class PreferAssertj extends BugChecker
private static final Matcher<ExpressionTree> FAIL = MethodMatchers.staticMethod()
.onClassAny(LEGACY_ASSERT_CLASSES)
.named("fail")
.withParameters();
.withNoParameters();

private static final Matcher<ExpressionTree> FAIL_DESCRIPTION = MethodMatchers.staticMethod()
.onClassAny(LEGACY_ASSERT_CLASSES)
Expand Down Expand Up @@ -887,7 +887,7 @@ public boolean apply(Type type, VisitorState state) {
MethodMatchers.staticMethod()
.onClass(MATCHERS)
.named("nullValue")
.withParameters(),
.withNoParameters(),
MethodMatchers.staticMethod()
.onClass(MATCHERS)
.named("nullValue")
Expand All @@ -897,7 +897,7 @@ public boolean apply(Type type, VisitorState state) {
MethodMatchers.staticMethod()
.onClass(MATCHERS)
.named("notNullValue")
.withParameters(),
.withNoParameters(),
MethodMatchers.staticMethod()
.onClass(MATCHERS)
.named("notNullValue")
Expand Down Expand Up @@ -928,7 +928,7 @@ public boolean apply(Type type, VisitorState state) {
MethodMatchers.staticMethod()
.onClass(MATCHERS)
.namedAnyOf("empty", "emptyIterable", "emptyArray", "anEmptyMap")
.withParameters(),
.withNoParameters(),
MethodMatchers.staticMethod()
.onClass(MATCHERS)
.namedAnyOf("emptyCollectionOf", "emptyIterableOf")
Expand Down
Loading