Skip to content

Commit

Permalink
Merge pull request #221 from mfvanek/feature/forbiddenapis
Browse files Browse the repository at this point in the history
Add de.thetaphi.forbiddenapis
  • Loading branch information
mfvanek authored Jun 23, 2024
2 parents 2fbfe84 + 8b99a8c commit 0128349
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 13 deletions.
1 change: 1 addition & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ dependencies {
implementation("info.solidsoft.gradle.pitest:gradle-pitest-plugin:1.15.0")
implementation("org.gradle:test-retry-gradle-plugin:1.5.9")
implementation("io.freefair.gradle:lombok-plugin:8.6")
implementation("de.thetaphi:forbiddenapis:3.7")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import de.thetaphi.forbiddenapis.gradle.CheckForbiddenApis

plugins {
id("java")
id("de.thetaphi.forbiddenapis")
}

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

tasks {
test {
dependsOn(withType<CheckForbiddenApis>())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ dependencies {
testImplementation(platform("org.junit:junit-bom:5.10.2"))
testImplementation(platform("org.assertj:assertj-bom:3.26.0"))

checkstyle("com.thomasjensen.checkstyle.addons:checkstyle-addons:7.0.1")

errorprone("com.google.errorprone:error_prone_core:2.27.1")
errorprone("jp.skypencil.errorprone.slf4j:errorprone-slf4j:0.1.24")

Expand Down Expand Up @@ -76,23 +74,23 @@ lombok {
}

checkstyle {
toolVersion = "10.16.0"
configFile = file("../config/checkstyle/checkstyle.xml")
toolVersion = "10.17.0"
configFile = file("${rootDir}/config/checkstyle/checkstyle.xml")
isIgnoreFailures = false
maxWarnings = 0
maxErrors = 0
}

pmd {
toolVersion = "7.1.0"
toolVersion = "7.2.0"
isConsoleOutput = true
ruleSetFiles = files("../config/pmd/pmd.xml")
ruleSetFiles = files("${rootDir}/config/pmd/pmd.xml")
ruleSets = listOf()
}

spotbugs {
showProgress.set(true)
effort.set(Effort.MAX)
reportLevel.set(Confidence.LOW)
excludeFilter.set(file("../config/spotbugs/exclude.xml"))
excludeFilter.set(file("${rootDir}/config/spotbugs/exclude.xml"))
}
5 changes: 0 additions & 5 deletions config/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -308,10 +308,5 @@
<module name="CommentsIndentation">
<property name="tokens" value="SINGLE_LINE_COMMENT, BLOCK_COMMENT_BEGIN"/>
</module>
<module name="IllegalMethodCall">
<property name="illegalMethodNames"
value="emptyList,emptyMap,emptySet,emptyNavigableMap,emptyNavigableSet,emptySortedMap,emptySortedSet,singleton,singletonList,singletonMap,asList,unmodifiableList"/>
<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)
1 change: 1 addition & 0 deletions pg-index-health-demo-without-spring/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ plugins {
id("java")
id("pg-index-health-demo.java-compilation")
id("pg-index-health-demo.java-conventions")
id("pg-index-health-demo.forbidden-apis")
id("pg-index-health-demo.pitest")
}

Expand Down
1 change: 1 addition & 0 deletions pg-index-health-spring-boot-demo/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ plugins {
id("java")
id("pg-index-health-demo.java-compilation")
id("pg-index-health-demo.java-conventions")
id("pg-index-health-demo.forbidden-apis")
id("pg-index-health-demo.pitest")
id("org.springframework.boot") version "2.7.18"
id("com.google.osdetector") version "1.7.3"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import org.junit.jupiter.api.Test;
import org.springframework.http.MediaType;

import java.util.Locale;

import static org.assertj.core.api.Assertions.assertThat;

class DefaultControllerTest extends BasePgIndexHealthDemoSpringBootTest {
Expand All @@ -22,7 +24,7 @@ void rootPageShouldRedirectToSwaggerUi() {
.accept(MediaType.APPLICATION_JSON)
.exchange()
.expectStatus().isFound()
.expectHeader().location(String.format("http://localhost:%d/actuator/swaggerui", port))
.expectHeader().location(String.format(Locale.ROOT, "http://localhost:%d/actuator/swaggerui", port))
.expectBody()
.returnResult()
.getResponseBody();
Expand Down

0 comments on commit 0128349

Please sign in to comment.