Skip to content

Replace checkstyle with Spotless & Google Java Style#624

Merged
rymurr merged 3 commits intoprojectnessie:mainfrom
snazy:spotless
Jun 11, 2021
Merged

Replace checkstyle with Spotless & Google Java Style#624
rymurr merged 3 commits intoprojectnessie:mainfrom
snazy:spotless

Conversation

@snazy
Copy link
Copy Markdown
Member

@snazy snazy commented Dec 28, 2020

@codecov
Copy link
Copy Markdown

codecov bot commented Dec 28, 2020

Codecov Report

Merging #624 (c9c5b6b) into main (751eade) will increase coverage by 3.33%.
The diff coverage is 63.13%.

Impacted file tree graph

@@             Coverage Diff              @@
##               main     #624      +/-   ##
============================================
+ Coverage     69.34%   72.68%   +3.33%     
- Complexity      142      143       +1     
============================================
  Files           254      254              
  Lines          9807    10814    +1007     
  Branches        898      911      +13     
============================================
+ Hits           6801     7860    +1059     
+ Misses         2567     2484      -83     
- Partials        439      470      +31     
Flag Coverage Δ
java 71.61% <63.13%> (+3.80%) ⬆️
python 83.95% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...java/org/projectnessie/client/ClientConfigApi.java 100.00% <ø> (ø)
...n/java/org/projectnessie/client/StreamingUtil.java 0.00% <0.00%> (ø)
...in/java/org/projectnessie/client/auth/AwsAuth.java 0.00% <0.00%> (ø)
...org/projectnessie/client/auth/BasicAuthFilter.java 100.00% <ø> (ø)
...ie/client/http/HttpClientReadTimeoutException.java 25.00% <ø> (ø)
...va/org/projectnessie/client/http/HttpResponse.java 75.00% <ø> (ø)
.../java/org/projectnessie/client/http/HttpUtils.java 100.00% <ø> (ø)
.../org/projectnessie/client/http/RequestContext.java 88.23% <ø> (ø)
...projectnessie/client/http/ResponseContextImpl.java 100.00% <ø> (ø)
...e/client/rest/NessieBackendThrottledException.java 0.00% <ø> (ø)
... and 310 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 751eade...c9c5b6b. Read the comment docs.

@laurentgo
Copy link
Copy Markdown
Contributor

I'm not sure I'm a big fan of Google style (especially the 100 characters limit): it seems to force every statement to be wrapped. Are they other alternatives with good support for IDE (I checked the Eclipse plugin for google formatter, which seems to install easily although manually. I've no idea if it also works with version of the google plugin.

@snazy snazy force-pushed the spotless branch 2 times, most recently from 1dbd729 to 46fa2c5 Compare May 21, 2021 09:30
@snazy snazy marked this pull request as ready for review May 21, 2021 10:13
@snazy
Copy link
Copy Markdown
Member Author

snazy commented May 21, 2021

If everyone fine with this PR, we should probably merge it manually to keep the separate commits for 1. the text file + pom changes and 2. the "automatic spotless:apply".

nastra
nastra previously approved these changes May 21, 2021
Copy link
Copy Markdown
Contributor

@nastra nastra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (I only reviewed the first commit). I agree it would make sense to merge those 2 commits without squashing them

nastra
nastra previously approved these changes May 21, 2021
@nastra
Copy link
Copy Markdown
Contributor

nastra commented May 21, 2021

lgtm

nastra
nastra previously approved these changes May 21, 2021
rymurr
rymurr previously approved these changes May 25, 2021
Copy link
Copy Markdown
Contributor

@rymurr rymurr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I don't like the big change I am happy to move to spotless. @laurengo any thoughts?

@snazy is there any instructions for how to switch from checkstyle to spotless as a dev? Or is it pretty straighforward

@laurentgo
Copy link
Copy Markdown
Contributor

I noticed this morning that the plugin complained about some files found under the site directory (where I put my python virtualenv). Maybe we need some exclusions?

@snazy
Copy link
Copy Markdown
Member Author

snazy commented May 25, 2021

I noticed this morning that the plugin complained about some files found under the site directory (where I put my python virtualenv). Maybe we need some exclusions?

Huh? Haven't seen it complain about anything in venv or so. Do you have some details?

@laurentgo
Copy link
Copy Markdown
Contributor

laurentgo commented May 26, 2021

While trying spotless more, I found a couple of issues:

  • No skip flag (surprisingly): there's an open issue for it at Maven plugin should support skip diffplug/spotless#491
  • spotless (google formatter) only looks at formatting issues, but not all issues detected by checkstyle are detected by spotless/google formatter. For example, using a camel case package name is flagged by checkstyle but not by spotless

Maybe we should keep checkstyle for now? The lack of skip is kind of annoying to me (sometimes while I'm developing, I have temporary files which like logs which are often flagged by tools, but usually I use skip until I'm ready to clean up things before pushing my changes).

Copy link
Copy Markdown
Contributor

@laurentgo laurentgo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 616 files reviewed, 2 unresolved discussions (waiting on @laurentgo and @snazy)


pom.xml, line 994 at r2 (raw file):

            <format>
              <includes>
                <include>**/*.xml</include>

This causes all the XML files across all modules to be checked once by the top level module and then latter by the owning module. Tbh, it feels too broad, and maybe we should only check things under ${project.basedir}/src

@snazy
Copy link
Copy Markdown
Member Author

snazy commented May 27, 2021

While trying spotless more, I found a couple of issues:

  • No skip flag (surprisingly): there's an open issue for it at diffplug/spotless#491
  • spotless (google formatter) only looks at formatting issues, but not all issues detected by checkstyle are detected by spotless/google formatter. For example, using a camel case package name is flagged by checkstyle but not by spotless

Maybe we should keep checkstyle for now? The lack of skip is kind of annoying to me (sometimes while I'm developing, I have temporary files which like logs which are often flagged by tools, but usually I use skip until I'm ready to clean up things before pushing my changes).

Moved the spotless-plugin into a new profile, which can be deactivated with -DskipSpotless.

Not sure whether the name-style checks are that much of a problem. It's something that can be spotted in reviews.

Copy link
Copy Markdown
Member Author

@snazy snazy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 616 files reviewed, 2 unresolved discussions (waiting on @laurentgo)


pom.xml, line 994 at r2 (raw file):

Previously, laurentgo (Laurent Goujon) wrote…

This causes all the XML files across all modules to be checked once by the top level module and then latter by the owning module. Tbh, it feels too broad, and maybe we should only check things under ${project.basedir}/src

Done.

@snazy snazy force-pushed the spotless branch 2 times, most recently from b7b6142 to d098f30 Compare May 28, 2021 08:29
@snazy
Copy link
Copy Markdown
Member Author

snazy commented May 28, 2021

As discussed in the stand-up, I've re-added the Checkstyle plugin but removed the "pure code formatting" checks from the checkstyle-configs.

Nits:

  • moved all code-style related configs to a new codestyle/ folder (for both spotless + checkstyle)
  • also added spotless to the Gradle plugin build

<component name="CopyrightManager">
<copyright>
<option name="notice" value="Copyright (C) 2020 Dremio&#10;&#10;Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);&#10;you may not use this file except in compliance with the License.&#10;You may obtain a copy of the License at&#10;&#10;http://www.apache.org/licenses/LICENSE-2.0&#10;&#10;Unless required by applicable law or agreed to in writing, software&#10;distributed under the License is distributed on an &quot;AS IS&quot; BASIS,&#10;WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.&#10;See the License for the specific language governing permissions and&#10;limitations under the License." />
<option name="notice" value="Copyright (C) &amp;#36;today.year Dremio&#10;&#10;Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);&#10;you may not use this file except in compliance with the License.&#10;You may obtain a copy of the License at&#10;&#10;http://www.apache.org/licenses/LICENSE-2.0&#10;&#10;Unless required by applicable law or agreed to in writing, software&#10;distributed under the License is distributed on an &quot;AS IS&quot; BASIS,&#10;WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.&#10;See the License for the specific language governing permissions and&#10;limitations under the License." />
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this mean once a year we will have a big diff which re-writes all headers or we will have a mixed copywrite year depending on when the source was created

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope. It just inserts the current year, when the license is not present.
A "new year" has no effect. However, if you change the copyright text, it will complain.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so we will have a mix of 2020, 2021 etc as the copyright year right? That sounds odd to me. Most repos have Copyright <year> or Copyright <year1>-<year2> right? And they are always uniform across the repo.

@snazy snazy force-pushed the spotless branch 3 times, most recently from 32c2633 to fe49a23 Compare May 28, 2021 14:08
rymurr
rymurr previously approved these changes May 28, 2021
Copy link
Copy Markdown
Contributor

@rymurr rymurr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. @laurentgo wdyt

@snazy snazy force-pushed the spotless branch 3 times, most recently from ea0b3e2 to f5d45bf Compare June 1, 2021 19:52
snazy added 3 commits June 10, 2021 19:27
Checkstyle is still used to check certain code patterns.

Formats `*.java`, `*.scala` and `*.xml` files.

Does not format markdown or typescript or python or CSS or HTML files.
For typescript: it feels easier to add some tslint/eslint into the node build process.
For python: it feels easier to add (actually: leave) it to the python linter (or flake8 or whatever).
CSS/HTML: there's not much for format right now, and Eclipse WTP fails to format typescript-ish CSS files.

Spotless can use Prettier, but it does an `npm install` for every module, starts a prettier server and shuts it down - takes quite long.

Allow `-DskipSpotless`
Copy link
Copy Markdown
Contributor

@nastra nastra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants