How to enforce all UPPERCASE letter for static variables in intellij?

Viewed 1102

I'm trying to enforce (using a hint in the editor) capital letters for static variables (constants!).

If I write private static final float decayFactor = 0.5f; it should hint that static variables should be capital letters.

Tried looking in the Preferences->code style, but didn't find something like that. Inspections don't seem to have something relevant either, as you can see from the screenshot:

code generation screen shot

1 Answers

Intellij does that ;-)

Go to Inspections > Java > Naming conventions > Field naming convention.

Check this inspection, and check "'static' field" into the options of the inspection. You'll be able to define the regex used to validate the naming of the static variables. By default, it is [A-Z][A-Z_\d]*, which is what you want.

Related