spotify / fmt-maven-plugin

Opinionated Maven Plugin that formats your Java code.
MIT License
327 stars 62 forks source link

Support for casing? #191

Open dxps opened 1 month ago

dxps commented 1 month ago

Dear all,

First of all, tried this plugin and it works just fine. Thanks for maintaining it! :pray:

I know it's about formatting, but can this - or do you know about other plugin(s) that - can cover the casing, such as lower camel camel case for method or local variables names, please?

Thanks!

klaraward commented 1 month ago

Hi, the formatting logic itself is in https://github.com/google/google-java-format which follows https://google.github.io/styleguide/javaguide.html#s5.3-camel-case.

Easiest is probably if you check there for any functionality you think might be missing.

dxps commented 1 month ago

@klaraward Thanks, Klara!

Concretely speaking, my wish is to get an warning (or even an error aka generate a failure) when such code exists:

@RestController
public class IndexController {

  @GetMapping("/")
  public String index() {

    var some_greeting = "Welcome";

    if (System.currentTimeMillis() % 2 == 0) {
      some_greeting += "!";
    }

    return some_greeting;
  }
}

I would like to pick up the not-recommeded cases, such as using snake case for local variables.