Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automatically add "this." to instance variables

We have started to implement checkstyle as a way to provide a consistent code style across developers. One of the checks requires that all instance variables be references using "this.". I have not been in the habit of using "this.", and so have thousands of instances that need to be fixed.

Is there a tool or IntelliJ plugin that can just run through and add the appropriate code?

like image 611
Phyxx Avatar asked Dec 21 '22 10:12

Phyxx


1 Answers

One of the checks requires that all instance variables be referenced using "this."

So 'checkstyle' is mistaken.

I have not been in the habit of using "this."

Quite right. It's redundant. Good for you.

so have thousands of instances that need to be fixed.

So you are mistaken.

You don't have any instances that 'need to be fixed'.

Don't do it. It's redundant. Don't perform redundant work. Nobody wants to pay for it, and why should they? Modify your checkstyle configuration so as not to require it. Don't let tools tell you how to spend money, and don't be fooled that a 'consistent code style across developers' is essential to delivering a working product. It isn't, as long as the code is legible and maintainable. I have seen more time and money wasted on this issue than I care to think about.

like image 88
user207421 Avatar answered Dec 26 '22 11:12

user207421