Skip to content

Commit

Permalink
added nullaway plugin + dep updates
Browse files Browse the repository at this point in the history
  • Loading branch information
gtiwari333 committed Apr 25, 2023
1 parent 7e9453a commit b28e0a7
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 28 deletions.
18 changes: 11 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand All @@ -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:

Expand Down
60 changes: 48 additions & 12 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

<mapstruct.version>1.5.2.Final</mapstruct.version>
<lombok.version>1.18.26</lombok.version>
<spock.version>2.4-M1-groovy-4.0</spock.version>

<!-- test properties -->
<project.testresult.directory>${project.build.directory}/test-results</project.testresult.directory>
Expand All @@ -37,22 +39,28 @@
<!-- code quality -->
<archunit-junit5.version>1.0.1</archunit-junit5.version>
<sonar-maven-plugin.version>3.9.1.2184</sonar-maven-plugin.version>
<jacoco-maven-plugin.version>0.8.8</jacoco-maven-plugin.version>
<checkstyle.plugin.version>3.1.2</checkstyle.plugin.version>
<puppycrawl.checkstyle.version>10.7.0</puppycrawl.checkstyle.version>
<google.error-prone.compiler.version>2.14.0</google.error-prone.compiler.version>
<groovy.maven.plugin.version>1.13.1</groovy.maven.plugin.version>
<modernizer-maven-plugin.version>2.5.0</modernizer-maven-plugin.version>
<spotbugs.plugin.version>4.7.3.0</spotbugs.plugin.version>
<jacoco-maven-plugin.version>0.8.9</jacoco-maven-plugin.version>
<checkstyle.plugin.version>3.2.2</checkstyle.plugin.version>
<puppycrawl.checkstyle.version>10.9.3</puppycrawl.checkstyle.version>
<google.error-prone.compiler.version>2.18.0</google.error-prone.compiler.version>
<groovy.maven.plugin.version>2.1.0</groovy.maven.plugin.version>
<modernizer-maven-plugin.version>2.6.0</modernizer-maven-plugin.version>
<spotbugs.plugin.version>4.7.3.4</spotbugs.plugin.version>
<findsecbugs-plugin.version>1.12.0</findsecbugs-plugin.version>
<sb-contrib-plugin.version>7.4.7</sb-contrib-plugin.version>
<owasp-dependency-check-plugin.version>8.0.2</owasp-dependency-check-plugin.version>
<sb-contrib-plugin.version>7.6.0</sb-contrib-plugin.version>
<owasp-dependency-check-plugin.version>8.2.1</owasp-dependency-check-plugin.version>
</properties>

<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>2.0.7</version>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>3.0.2</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
Expand Down Expand Up @@ -94,7 +102,7 @@
<!-- feeling too lazy to define my own versions.. let's use spring boot's dependency management .. -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.0.2</version>
<version>3.0.6</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand All @@ -113,10 +121,13 @@
<source>${java.version}</source>
<target>${java.version}</target>
<compilerArgs>
<arg>-Xlint:all,-options</arg>
<arg>-Xdoclint:all/protected</arg>
<arg>-XDcompilePolicy=simple</arg>
<arg>-Xplugin:ErrorProne</arg>
<arg>-Xplugin:ErrorProne -Xep:NullAway:ERROR -XepOpt:NullAway:AnnotatedPackages=gt.app</arg>

<!-- this will fix mapstruct -->
<arg>-Amapstruct.defaultComponentModel=spring</arg>
<arg>-Amapstruct.defaultComponentModel=default</arg>
<arg>-Amapstruct.defaultInjectionStrategy=constructor</arg>
</compilerArgs>
<annotationProcessorPaths>
Expand All @@ -130,6 +141,11 @@
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</path>
<path>
<groupId>com.uber.nullaway</groupId>
<artifactId>nullaway</artifactId>
<version>0.10.10</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
Expand Down Expand Up @@ -319,6 +335,26 @@
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco-maven-plugin.version}</version>
<executions>
<execution>
<id>jacoco-check</id>
<goals>
<goal>check</goal>
</goals>
<configuration>
<rules>
<rule>
<element>PACKAGE</element>
<limits>
<limit>
<counter>LINE</counter>
<value>COVEREDRATIO</value>
<minimum>0.9</minimum>
</limit>
</limits>
</rule>
</rules>
</configuration>
</execution>
<execution>
<id>pre-unit-tests</id>
<goals>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/gt/app/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

}
13 changes: 11 additions & 2 deletions src/main/java/gt/app/PojoA.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
4 changes: 1 addition & 3 deletions src/test/groovy/gt/app/SpockExSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
5 changes: 2 additions & 3 deletions src/test/java/gt/app/ApplicationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit b28e0a7

Please sign in to comment.