Introduction
During this week lab we were tasked with adding CONTRIBUTING.md
file where we should add instructions for all of the contributors on how to contribute on my project PolyglotCode. Moreover, we were supposed to add a Code Formatter
to make our code more structured, and to add a Linter
to make sure that code follows the styling.
Tools I Used
We had a list of suggested code formation tools, as my code was written in Java
I decided to use suggested formatter GoogleJavaFormat.
However, I didn't decide to pick suggested tool for Linter
. I picked Checkstyle; for the reason, that SpotBugs
wasn't available for JDK 22
.
Setting Up
To set up both of these tools I used inside of pom.xml
file.
CheckStyle
:
To set rules for CheckStyle
we need to create a file called checkstyle.xml
:
What Tools Found
GoogleJavaFormat
just changed how code looks, it has the same functionality as Prettier
. CheckStyle
found couple of issue with not used imports.
For the reason, that I use Maven
I used the commands:
mvn spotless:apply
and
mvn checkstyle:check
How To Integrate With IDE
To integrate it all with IDE we use Intellij IDEA Marketplace and download them all.
What Did I learn
Today I learned that it is pretty important to have tools like Code Formatter
and Linter
to make sure that other contributors upon finishing their contribution are able to keep the same code style.
Top comments (0)