Search code examples
intellij-ideaintellij-plugin

How to create my custom inspection for variable naming rule?


I want to create naming convention rule for member variable in inspection profile of IntelliJ. for example: if developer gives member variable name as "test" then it should complain using my custom inspection and suggests the naming should be "m_test".

How do I achieve it in IntelliJ? I checked in existing inspection profile and couldn't able to find any rule regarding this.


Solution

  • There is a built-in inspection for this; you don't need to write a new one. The inspection is under Java | Naming conventions | Instance field naming convention. You can specify the regular expression for the name in the "Pattern" field.