From b28e0a7aba39c4e11952fedad5ee57abfd934e60 Mon Sep 17 00:00:00 2001 From: Ganesh Tiwari Date: Mon, 24 Apr 2023 20:44:41 -0500 Subject: [PATCH] added nullaway plugin + dep updates --- README.md | 18 ++++--- pom.xml | 60 ++++++++++++++++++----- src/main/java/gt/app/Application.java | 2 +- src/main/java/gt/app/PojoA.java | 13 ++++- src/test/groovy/gt/app/SpockExSpec.groovy | 4 +- src/test/java/gt/app/ApplicationTest.java | 5 +- 6 files changed, 74 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 0512de6..16cb28a 100644 --- a/README.md +++ b/README.md @@ -21,11 +21,13 @@ ### SonarQube scan Run sonarqube server using docker -`docker run -e SONAR_ES_BOOTSTRAP_CHECKS_DISABLE=true -p 9000:9000 sonarqube:latest` + + docker run -e SONAR_ES_BOOTSTRAP_CHECKS_DISABLE=true -p 9000:9000 sonarqube:latest Perform scan: -`mvnw sonar:sonar` -mvnw sonar:sonar -Dsonar.login=admin -Dsonar.password=admin + + ./mvnw sonar:sonar + ./mvnw sonar:sonar -Dsonar.login=admin -Dsonar.password=admin View Reports in SonarQube web ui: @@ -38,15 +40,17 @@ View Reports in SonarQube web ui: #### Running unit tests only (it uses maven surefire plugin) -`mvnw compiler:testCompile resources:testResources surefire:test` + + ./mvnw compiler:testCompile resources:testResources surefire:test #### Running integration tests only (it uses maven-failsafe-plugin) -`mvnw compiler:testCompile resources:testResources failsafe:integration-test` + + ./mvnw compiler:testCompile resources:testResources failsafe:integration-test ### Dependency/plugin version checker - mvnw versions:display-dependency-updates - mvnw versions:display-plugin-updates + ./mvnw versions:display-dependency-updates + ./mvnw versions:display-plugin-updates ## Future plan: diff --git a/pom.xml b/pom.xml index 7e3e79a..b14b9a4 100644 --- a/pom.xml +++ b/pom.xml @@ -15,7 +15,9 @@ UTF-8 UTF-8 + 1.5.2.Final 1.18.26 + 2.4-M1-groovy-4.0 ${project.build.directory}/test-results @@ -37,22 +39,28 @@ 1.0.1 3.9.1.2184 - 0.8.8 - 3.1.2 - 10.7.0 - 2.14.0 - 1.13.1 - 2.5.0 - 4.7.3.0 + 0.8.9 + 3.2.2 + 10.9.3 + 2.18.0 + 2.1.0 + 2.6.0 + 4.7.3.4 1.12.0 - 7.4.7 - 8.0.2 + 7.6.0 + 8.2.1 org.slf4j slf4j-simple + 2.0.7 + + + com.google.code.findbugs + jsr305 + 3.0.2 org.projectlombok @@ -94,7 +102,7 @@ org.springframework.boot spring-boot-starter-parent - 3.0.2 + 3.0.6 pom import @@ -113,10 +121,13 @@ ${java.version} ${java.version} + -Xlint:all,-options + -Xdoclint:all/protected -XDcompilePolicy=simple - -Xplugin:ErrorProne + -Xplugin:ErrorProne -Xep:NullAway:ERROR -XepOpt:NullAway:AnnotatedPackages=gt.app + - -Amapstruct.defaultComponentModel=spring + -Amapstruct.defaultComponentModel=default -Amapstruct.defaultInjectionStrategy=constructor @@ -130,6 +141,11 @@ lombok ${lombok.version} + + com.uber.nullaway + nullaway + 0.10.10 + @@ -319,6 +335,26 @@ jacoco-maven-plugin ${jacoco-maven-plugin.version} + + jacoco-check + + check + + + + + PACKAGE + + + LINE + COVEREDRATIO + 0.9 + + + + + + pre-unit-tests diff --git a/src/main/java/gt/app/Application.java b/src/main/java/gt/app/Application.java index 3717167..09671ba 100644 --- a/src/main/java/gt/app/Application.java +++ b/src/main/java/gt/app/Application.java @@ -8,7 +8,7 @@ public class Application { @SneakyThrows public static void main(String[] args) { - log.info("Application started , params: {}", args); + log.info("Application started , params: {}", (Object) args); } } diff --git a/src/main/java/gt/app/PojoA.java b/src/main/java/gt/app/PojoA.java index da07148..aff380e 100644 --- a/src/main/java/gt/app/PojoA.java +++ b/src/main/java/gt/app/PojoA.java @@ -1,14 +1,23 @@ package gt.app; -import lombok.Builder; import lombok.Data; +import javax.annotation.Nullable; + @Data -@Builder public class PojoA { + @Nullable String firstName; + @Nullable String lastName; int age; + @Nullable String country; + @Nullable String language; + + public PojoA(@Nullable String firstName, int age) { + this.firstName = firstName; + this.age = age; + } } diff --git a/src/test/groovy/gt/app/SpockExSpec.groovy b/src/test/groovy/gt/app/SpockExSpec.groovy index 4de8e21..4aa968e 100644 --- a/src/test/groovy/gt/app/SpockExSpec.groovy +++ b/src/test/groovy/gt/app/SpockExSpec.groovy @@ -7,9 +7,7 @@ class SpockExSpec extends Specification { def 'test1'() { given: - var p = PojoA.builder() - .firstName("Bob").age(2) - .build() + var p = new PojoA("Bob", 2) when: String fName = p.getFirstName() diff --git a/src/test/java/gt/app/ApplicationTest.java b/src/test/java/gt/app/ApplicationTest.java index 40ea4cf..48a9c52 100644 --- a/src/test/java/gt/app/ApplicationTest.java +++ b/src/test/java/gt/app/ApplicationTest.java @@ -9,9 +9,8 @@ class ApplicationTest { @Test void testLombokData() { //given - var p = PojoA.builder() - .firstName("Bob").age(2) - .build(); + var p = new PojoA("Bob", 2); + //when: String fName = p.getFirstName();