Java Code Reviews
Java Style Guide
Developers should follow the Google Java Style Guide.
Code Analysis / Linting
We strongly believe that consistent style increases readability and maintainability of a code base. Hence, we are recommending analyzers to enforce consistency and style rules.
Automatic Code Formatting
Eclipse, and other Java IDEs, support automatic code formatting. If using Maven, some developers also make use of the formatter-maven-plugin.
It's important to enforce your code style and rules in the CI to avoid any team members merging code that does not comply with standards into your git repo. If building using Azure DevOps, Azure DevOps support Maven and Gradle build tasks using PMD, Checkstyle, and FindBugs code analysis tools as part of every build.
Here is an example yaml for a Maven build task with all three analysis tools enabled:
- task: Maven@3 displayName: 'Maven pom.xml' inputs: mavenPomFile: '$(Parameters.mavenPOMFile)' checkStyleRunAnalysis: true pmdRunAnalysis: true findBugsRunAnalysis: true
Here is an example yaml for a Gradle build task with all three analysis tools enabled:
- task: Gradle@2 displayName: 'gradlew build' inputs: checkStyleRunAnalysis: true findBugsRunAnalysis: true pmdRunAnalysis: true
Code Review Checklist
In addition to the Code Review Checklist you should also look for these Java specific code review items
- Does the project use Lambda to make code cleaner?
- Is dependency injection (DI) used? Is it setup correctly?
- If the code uses Spring Boot, are you using @Inject instead of @Autowire?
- Does the code handle exceptions correctly?
- Is the Azul Zulu OpenJDK being used?
- Is a build automation and package management tool (Gradle or Maven) being used?