javaeclipsesettingsformattereclipse-formatter

Eclipse - don't automatically add parenthesis


We use a shared Java - Code Style - Formatter, Checkstyle and some other settings across all projects in Eclipse for all developers, which is great.
I'm annoyed by one of the settings however and want to change it, but I don't know where this setting is.

It's currently changing something like this:

if (something > 0 || something <= x) {
  ...
}

automatically to this:

if ((something > 0) || (something <= x)) {
  ...
}

Does anyone know where in Eclipse I can change this setting so it keeps the first (or even better, change the latter to the first)?


Solution

  • enter image description here

    You can set this setting using Preferences--> Java --> Editor--> Save Actions--> Code Style. Deselect "Use parentheses in expressions". It will solve your problem.