Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add forbidden api checker #418

Merged
merged 10 commits into from
Jun 22, 2024
21 changes: 21 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ plugins {
id("jacoco-report-aggregation")
id("org.sonarqube")
id("com.github.ben-manes.versions") version "0.51.0"
id("de.thetaphi.forbiddenapis") version "3.7"
}

description = "pg-index-health build"
Expand Down Expand Up @@ -68,3 +69,23 @@ tasks.named<DependencyUpdatesTask>("dependencyUpdates").configure {
isNonStable(candidate.version)
}
}

forbiddenApis {
bundledSignatures = setOf("jdk-deprecated", "jdk-non-portable")
mfvanek marked this conversation as resolved.
Show resolved Hide resolved
signaturesFiles = files("/config/forbidden-apis/forbidden-apis.txt")
ignoreFailures = false
}

subprojects {
mfvanek marked this conversation as resolved.
Show resolved Hide resolved
apply(plugin = "de.thetaphi.forbiddenapis")

forbiddenApis {
bundledSignatures = setOf("jdk-deprecated", "jdk-non-portable")
signaturesFiles = files("${rootDir}/config/forbidden-apis/forbidden-apis.txt")
ignoreFailures = false
}

tasks.named("check") {
dependsOn("forbiddenApis")
}
}
5 changes: 0 additions & 5 deletions config/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -302,10 +302,5 @@
<module name="CommentsIndentation">
<property name="tokens" value="SINGLE_LINE_COMMENT, BLOCK_COMMENT_BEGIN"/>
</module>
<module name="IllegalMethodCall">
mfvanek marked this conversation as resolved.
Show resolved Hide resolved
<property name="illegalMethodNames"
value="emptyList,emptyMap,emptySet,emptyNavigableMap,emptyNavigableSet,emptySortedMap,emptySortedSet,singleton,singletonList,singletonMap,asList,unmodifiableList,unmodifiableSet"/>
<property name="excludedQualifiers" value=""/>
</module>
</module>
</module>
14 changes: 14 additions & 0 deletions config/forbidden-apis/forbidden-apis.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@defaultMessage Avoid using these methods, consider alternative approaches
java.util.Collections#emptyList()
java.util.Collections#emptyMap()
java.util.Collections#emptySet()
java.util.Collections#emptyNavigableMap()
java.util.Collections#emptyNavigableSet()
java.util.Collections#emptySortedMap()
java.util.Collections#emptySortedSet()
java.util.Collections#singleton(java.lang.Object)
java.util.Collections#singletonList(java.lang.Object)
java.util.Collections#singletonMap(java.lang.Object,java.lang.Object)
java.util.Arrays#asList(java.lang.Object[])
java.util.Collections#unmodifiableList(java.util.List)
java.util.Collections#unmodifiableSet(java.util.Set)