Fixing code style errors with Spotless and Maven

In previous post related to coding style I’ve described how to validate the code and generate report with Checkstyle. This time I would like to focus on Spotless which not only offers the same functionality as Checkstyle, but also can fix code style errors automatically.

Checking code style with Maven and Checkstyle

Keeping code clean and formatted in standardised way is one of the keys to successful project. It makes code easier to read, makes code easier to understand and allows new joiners to familiarize themselves with the project faster, especially when project’s coding standard is one of publicity available. In this post I will show how to configure Maven to run Checkstyle plugin, generate and review report and show few options that are not enabled by default but worth to check. Before we will start take a look on code below and try to find code style validation errors.

Finding duplicated code with Maven and PMD

One of the rules of clean code and software development principle is the DRY - Don’t repeat yourself. One of the assumption of this principle tells that developers should not repeat the same code in many places. This is the theory, but in practice developers tend to copy and paste some parts of the code from time to time (especially in bigger projects). Not following the DRY rule may cause a lot of problems: the codebase is bigger, the maintenance is harder, and it may lead to introducing a bugs if someone will forget to update the copied blocks of code.

Preparing the release with Maven

The moment has finally come, all features implemented, bugs fixed - your application is ready to be published. You want to mark current code as production ready and prepare code base for next development iteration. But where to start? And what actually should be done? Manual release might be time-consuming and error-prone. Thankfully we have Maven and the Release plugin! In this post I will show how to perform all tasks required to configure and perform release using Maven Release plugin.

Create executable JAR with Maven

This short post show step-by-step how to create executable JAR. Thanks to Maven and Shade plugin it is really easy to achieve this.

Code coverage reports with Maven and Jacoco

Today I would like to focus on code coverage. In few steps I will show how to configure Maven to generate code coverage report using Jacoco.

Configuring Maven to run JUnit5 unit and integration tests

In this post I will show how to set up Maven to run unit tests and integration tests correctly. This seemingly simple task requires some effort, but once done correctly you can sleep well and be sure that no one will complain about it. To show the step-by-step process I’ve created simple Maven project.