question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Space before comma in multi-value switch expression case label

See original GitHub issue

Prettier-Java 1.0.0

# Options (if any):
--print-width 80

Input:

// code snippet
enum TestEnum {
  FOO,
  BAR,
  BAZ,
}

public class Test {

  public void test(TestEnum testEnum) {
    switch (testEnum) {
      case FOO -> System.out.println("Foo!");
      case BAR, BAZ -> System.out.println("Not Foo!");
    }
  }
}

Output:

// code snippet
enum TestEnum {
  FOO,
  BAR,
  BAZ,
}

public class Test {

  public void test(TestEnum testEnum) {
    switch (testEnum) {
      case FOO -> System.out.println("Foo!");
      case BAR ,BAZ -> System.out.println("Not Foo!");
    }
  }
}

Expected behavior: No changes made. Specifically, case BAR, BAZ does not become case BAR ,BAZ

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
clementdessoudecommented, Nov 27, 2020

I will release it tomorrow I think

0reactions
DanielFrancommented, Nov 27, 2020

We update master a few days ago, so we might need to rollback prior the V7 release

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using two values for one switch case statement - Stack Overflow
Each break statement terminates the enclosing switch statement. ... can make use of the new form of the switch label using a comma...
Read more >
Multivalue eval functions - Splunk Documentation
This function filters a multivalue field based on an arbitrary Boolean expression X. The Boolean expression X can reference ONLY ONE field at...
Read more >
Comma-separated labels should be used in Switch with colon ...
This rule reports an issue when multiple cases in a Switch can be grouped into a single comma-separated case. Noncompliant Code Example. //...
Read more >
Token Editor using Apply Index for "all values separated by a ...
What you want is the Apply Function area and then choose Split. You can then enter the comma as the split character/string.
Read more >
Golang program that uses switch, multiple value cases
A switch statement using multiple value cases correspond to using more than one value in a single case. This is achieved by separating...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found