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

fix: no break in single-block switch case #636

Conversation

jtkiesel
Copy link
Contributor

What changed with this PR:

Switch cases whose block statements consists of a single block no longer have that block broken and indented. This aligns such switch cases with the way Prettier JavaScript formats them, and no longer violates the Checkstyle that Prettier Java provides.

Example

Input

class Example {

  void example() {
    switch (a) {
      case 1:
        {}
      case 2:
        {
          b();
        }
      case 3:
        {
          c();
        }
        {
          d();
        }
      case 4:
        e();
        {
          f();
        }
      case 5:
        {
          g();
        }
        h();
    }
  }
}

Output

class Example {

  void example() {
    switch (a) {
      case 1: {}
      case 2: {
        b();
      }
      case 3:
        {
          c();
        }
        {
          d();
        }
      case 4:
        e();
        {
          f();
        }
      case 5:
        {
          g();
        }
        h();
    }
  }
}

Relative issues or prs:

Closes #635

@jtkiesel jtkiesel force-pushed the fix/no-break-in-single-block-switch-case branch from ad86a80 to b2ceb47 Compare January 17, 2024 07:19
@clementdessoude clementdessoude merged commit 0f08bbf into jhipster:main Feb 13, 2024
6 checks passed
@jtkiesel jtkiesel deleted the fix/no-break-in-single-block-switch-case branch February 14, 2024 02:02
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.

(switch) case with braces not consistent with checkstyle
2 participants