analytically / innerbuilder

IntelliJ IDEA plugin which generates an inner builder class

Home Page:https://plugins.jetbrains.com/plugin/7354-innerbuilder/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Builder methods should respect Checkstyle parameter rules

yiweig opened this issue · comments

The current Builder template breaks Checkstyle rules for parameters, namely the hidden field rule. For example, public Builder name(String name) {...} generates a Checkstyle violation that states 'name' hides a field.

There should be an option to prefix the generated parameter names with something, such as "new" so that the above example becomes: public Builder name(String newName) {...} so that the Checkstyle violation is resolved.

In my opinion it's better to name parameters for such Builder methods as val or value as was described in Effective Java 2nd edition Item 2 (http://www.informit.com/articles/article.aspx?p=1216151&seqNum=2). Because from name of the builder method it's already obvious for what this parameter stands for, also it makes shorter signatures for method avoiding duplication for naming.

That's fine; what I'm saying is that the current template needs to at least give the option to change the parameter name to something other than what the field/method is. That way the generated builder classes won't break Checkstyle rules.

I merged the PR, would you be able to test the .jar?

Sure thing! Just let me know what to do

Manually install the plugin from git and test if the generated builders satisfy your requirement.

Yup it works great! Would it be okay if I made a PR with some code suggestions as well? Never mind, this is excellent! You guys are awesome

+1 Thanks for fixing! This was an issue for myself as well.

Absolutely.