0

At some point, my IntelliJ started to automatically add this to the final members of the class.

And it seems like it does it when clicking outside of the code window.

So it automatically changes

class My{
  private final Dog dog;
  ...
  dog.eat()
}

To

class My{
  private final Dog dog;
  ...
  this.dog.eat()
}

How can I make this stop?

riorio
  • 6,500
  • 7
  • 47
  • 100

1 Answers1

1

Very likely, you have Reformat Code, Rearrange Code, or Cleanup enabled in the "Before Commit" config section. It reformats the current file according to your code style settings before committing the changes.

If that's not the case, check for any plugins that might trigger such behavior on saving, such as "save action" or "swiss-as dev-tools" plugins.

knittl
  • 246,190
  • 53
  • 318
  • 364
  • The "reformat code" is turned off. The "perform code analysis" was turned on, but turning it also off, did not make IntelliJ stop this. – riorio Apr 07 '21 at 12:42
  • @riorio is rearrange or cleanup enabled? – knittl Apr 07 '21 at 12:46
  • No. only the "optimize imports". I'm adding a screenshot to the post. – riorio Apr 07 '21 at 12:51
  • @riorio and it only does this when committing through IntelliJ? In other words: when committing from the command line, `this.` is not added? – knittl Apr 07 '21 at 12:53
  • Turns out it adds the `this` even without a commit. I remove it from the code, click outside of the code window and it adds it. I'm updating the post. – riorio Apr 07 '21 at 12:57