Skip to content
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

Disable WhitespaceAround when using palantir-java-format #1603

Merged
merged 2 commits into from
Jan 7, 2021

Conversation

pkoenig10
Copy link
Member

Before this PR

The WhitespaceAround checkstyle check conflicts with how palantir-java-format (correctly) formats empty blocks in switch expressions.

The following code:

enum Case { ONE, TWO }
switch (foo) {
    case ONE -> {},
    case TWO -> {
        ...
    }
}

Results in the following errors:

WhitespaceAround: '}' is not preceded with whitespace.
WhitespaceAround: '{' is not followed by whitespace. Empty blocks may only be represented as {} when not part of a multi-block statement (4.1.3)

See internal build https://c.p.b/gh/foundry/mp/236221

After this PR

The WhitespaceAround checkstyle check is removed when using palantir-java-format.

This is similar to what we've done previously for other checks in #987, #1205, and #1278.

I've also taken the liberty to refactor this to use Java's XML tooling to make it a bit more robust and easier to read/modify. This did result in some slight formatting changes to the output. See https://g.p.b/foundry/mp/commit/acc37f76 for an example of the changes.

@changelog-app
Copy link

changelog-app bot commented Jan 6, 2021

Generate changelog in changelog/@unreleased

Type

  • Feature
  • Improvement
  • Fix
  • Break
  • Deprecation
  • Manual task
  • Migration

Description

Disable WhitespaceAround Checkstyle rule when palantir-java-format is applied.

Check the box to generate changelog(s)

  • Generate changelog entry

@policy-bot policy-bot bot requested a review from iamdanfox January 6, 2021 21:47
@pkoenig10 pkoenig10 requested a review from fawind January 6, 2021 21:47
Copy link
Contributor

@fawind fawind left a comment

Choose a reason for hiding this comment

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

Very nice, thanks for fixing!

@bulldozer-bot bulldozer-bot bot merged commit bf97133 into develop Jan 7, 2021
@bulldozer-bot bulldozer-bot bot deleted the pkoenig/whitespace branch January 7, 2021 11:18
@svc-autorelease
Copy link
Collaborator

Released 3.63.1

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

Successfully merging this pull request may close these issues.

3 participants