-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add checkstyle plugin #6901
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev-2.x
Are you sure you want to change the base?
Add checkstyle plugin #6901
Conversation
application/src/ext-test/java/org/opentripplanner/ext/fares/impl/OrcaFareServiceTest.java
Outdated
Show resolved
Hide resolved
application/src/ext-test/java/org/opentripplanner/ext/flex/FlexIntegrationTestData.java
Outdated
Show resolved
Hide resolved
application/src/ext/java/org/opentripplanner/ext/dataoverlay/GenericDataFile.java
Outdated
Show resolved
Hide resolved
application/src/ext/java/org/opentripplanner/ext/debugrastertiles/EdgeVertexTileRenderer.java
Show resolved
Hide resolved
| @@ -292,22 +287,54 @@ | |||
| </configuration> | |||
| </plugin> | |||
|
|
|||
| <plugin> | |||
| <groupId>com.diffplug.spotless</groupId> | |||
| <artifactId>spotless-maven-plugin</artifactId> | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed spotless because I thought openrewrite could do it's job. We have checks for the imports but do we want to additionally fix the issues with spotless?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we please keep the plugin and have it perhaps deactivated by default? I find it super-useful to remove all unused imports with mvn spotless:apply.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really want to still use spotless as well? I tried to limit the number of tools we use since checkstyle/openrewrite check/fix these issues as well. Although, spotless is faster than openrewrite.
| final List<FlexServiceDate> dates = new ArrayList<>(); | ||
|
|
||
| // TODO - This code id not DRY, the same logic is in RaptorRoutingRequestTransitDataCreator | ||
| for (int d = -additionalPastSearchDays; d <= additionalFutureSearchDays; ++d) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the problem being fixed here?
application/src/main/java/org/opentripplanner/apis/gtfs/generated/GraphQLDataFetchers.java
Show resolved
Hide resolved
leonardehrenfried
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now I feel that the code changes in this PR are a bit too invasive. I would start a bit more carefully with a smaller set of changes. I feel that right now that OpenRewrite and Checkstyle don't interact all that well with each other.
Checkstyle
Focusses more on style issues like braces and not initializing two variables on the same line. No automatic fixes.
OpenRewrite
Focusses on directly fixing all issues but the support for style problems is weaker.
Combining them
I feel that trying to combine right now is too much complexity at the same time. I would go with one tool and see how it feels. Personally, I would focus on OpenRewrite but it might not have the support for the style issues that @optionsome cares about.
|
Now that I said it, I took another look and there is support for the braces and the double initialization: With this clarified I would skip checkstyle and put all the effort into openrewrite. We have to enable the recipes bit by bit and figure out when it should be run because it is slower than checkstyle. |
|
I will test it out. We should have a discussion on if we only want rules that can be automatically fixed or not. |
|
I think the only relevant part here anymore is the checkstyle config, which we might partly use. |
|
I cleaned up this pr so it now just includes checkstyle configuration. Almost all of the checkstyle rules can be automatically fixed with openrewrite (which I haven't done here at least yet). One option is that we run checkstyle as normal part of the build (it's fast) and then you have to run openrewrite to fix the issues (there are some issues that openrewrite doesn't fix even though it should). You shouldn't really get these errors often unless you are new to the project and unfamiliar with our code style. |
|
If we decide to use checkstyle, I will add a profile to skip it if similarly as we have for prettier (if it's possible). |
| List<String> filterByBikeParks = null; | ||
| List<String> filterByCarParks = null; | ||
|
|
||
| // TODO implement |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // TODO implement |
| for (StreetNoteModel source : sources) { | ||
| Set<StreetNoteAndMatcher> maas2 = source.getNotes(edge); | ||
| if (maas2 != null) maas.addAll(maas2); | ||
| if (maas2 != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we still have street notes? I was under the impression that it was some feature that we already removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // Best duration 18m, | ||
| var transitAndTransit = startWalkAndL1 + endL2AndWalk + "[0:02 0:23 21m Tₓ1]"; | ||
| // Min-Duration 19m | ||
| // Best duration 18m, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // Best duration 18m, |
| // Min-Duration 19m - this is | ||
| var flexTransferTransit = startFlexAccess + endWalkAndL3 + "[0:02 0:22 20m Tₓ1 C₁2_580]"; | ||
| // Best duration 16m, | ||
| // Min-Duration 19m - this is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // Min-Duration 19m - this is |
| @@ -292,22 +287,54 @@ | |||
| </configuration> | |||
| </plugin> | |||
|
|
|||
| <plugin> | |||
| <groupId>com.diffplug.spotless</groupId> | |||
| <artifactId>spotless-maven-plugin</artifactId> | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really want to still use spotless as well? I tried to limit the number of tools we use since checkstyle/openrewrite check/fix these issues as well. Although, spotless is faster than openrewrite.
|
I would like us to add the configuration without any rules in the initial PR. Then add one rule at the time with the code fixed. If we want to make sure this works adding one rule in this PR is ok, for example |
|
#6988 Replaces this pr. I will keep this open as draft so we can copy over some rules/recipes in follow up prs from here. |
I feel there would be too much process if we add the rules one by one in prs. So I grouped the import related rules in #6988 and it's easy to review as the imports either work or don't work. |
|
I think this can be closed |
I was planning to close this after I've added in separate prs the stuff that is in this pr. |
Summary
Introduce checkstyle. This could be introduced alone or preferably with something that fixes most of the issues automatically (such as openrewrite).
I haven't fixed any of the errors yet. Almost all of them can be automatically fixed with OpenRewrite.
Issue
Related to last week's conference discussions and #6913.
Unit tests
No
Documentation
TODO
Changelog
Not sure if needed