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

Switch expression breaks SpringLambdaCheck #300

Closed
Josef-Reichardt opened this issue Oct 6, 2021 · 1 comment
Closed

Switch expression breaks SpringLambdaCheck #300

Josef-Reichardt opened this issue Oct 6, 2021 · 1 comment
Milestone

Comments

@Josef-Reichardt
Copy link

The SpringLambdaCheck throws the following exception if the source code contains a switch expression:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:3.1.2:check (default-cli) on project spring-javaformat-maven-sample: Failed during checkstyle configuration: Exception was thrown while processing /home/reichardt/Projects/_github/SpringLambdaCheck-with-switch-expression/src/main/java/sample/SampleApplication.java: Cannot invoke "com.puppycrawl.tools.checkstyle.api.DetailAST.getChildCount(int)" because "ast" is null -> [Help 1]

Example switch expression:

String message = switch (args.length) {
case 0 -> "No arg";
case 1 -> "One arg";
default -> getText.apply(args.length);
};

Used versions:

  • Java: 16
  • spring-javaformat: 0.0.29
  • maven-checkstyle-plugin: 3.1.2
  • checkstyle: 9.0.1

Minimal demo application: https://github.com/Josef-Reichardt/SpringLambdaCheck-with-switch-expression

@philwebb philwebb added this to the 0.0.x milestone Oct 6, 2021
@philwebb
Copy link
Contributor

philwebb commented Oct 7, 2021

Thanks for reporting that one. I've updated to code to skip the check for switch "arrow case" labels.

@philwebb philwebb modified the milestones: 0.0.x, 0.0.30 Oct 7, 2021
philwebb added a commit that referenced this issue Oct 7, 2021
Update `SpringLambdaCheck` to skip switch statement "arrow case"
labels.

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

No branches or pull requests

2 participants