Inconsistency of linting between Checkstyle and Spotless #2
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
For Spotless this code is formatted correctly.
Source
However, in the latest pipeline run related to this commit, Checkstyle flagged it as
Extra separation in import group before 'org.junit.jupiter.api.Test'and complained about the order.Spotless is meant to automatically format the code, to comply with Checkstyle.
This is not the case here.
mentioned in commit
08dc94b4b0Furthermore the code (linted by Checkstyle before with no issues)
is re-formatted by Spotless to
As an aftermath, Checkstyle now complains
assigned to @lars.winzer
created branch
issue/2-inconsistency-of-linting-between-checkstyle-and-spotlessto address this issueSpotless follows the Google Java Style Guide while Checkstyle uses custom defined rules.
The order in which imports have to be sorted is outlined here:
A possible solution is to change the formatting of Checkstyle to match the rules outlined by the Google Java Style Guide.
After doing some research, I came across the following issue.
The rules defined for Checkstyle, particularly regarding indentation, differ from how Spotless calculates indentation.
One possible solution is to use an additional Checkstyle configuration file, maintained by the official Checkstyle GitHub repository, which follows the Google Java Style Guide.
The alternative would be to include Spotless as an additional job in the CI pipeline. However, this comes with the drawback that Spotless does not generate a machine-readable output, making it difficult to embed the results as a code quality report in merge requests.
There are online reports of someone managing to parse the output using a Python script, but this is not a stable solution, as the output format could change at any time. Furthermore, only the locations are specified and how they should look, not exactly which rule was violated.
Given the issues, I have decided not to make any changes to the current pipeline.
mentioned in merge request !38
mentioned in commit
3581406833