Eclipse Checkstyle Disable "Lline has trailing spaces"

12,101

Solution 1

Found the way to disable it in checkstyle:

Preferences -> CheckStyle -> Regexp -> RegexpSingleLine (Disable)

Solution 2

Window->Preferences->Java->Editor->Save Actions.

Press Configure button.

On Code Organizing tab check Remove trailing whitespace.

Share:
12,101
James Oravec
Author by

James Oravec

I like egg rolls.

Updated on June 18, 2022

Comments

  • James Oravec
    James Oravec almost 2 years

    I'm using eclipse on Win 7. I'm also using checkstyle and find that checkstyle is complaining about trailing white space in comments.

    I wish to disable this check in checkstyle, not make any modifications to my environment as I wish to share the check style file with other developers in the office an ensure everyone can see the code in the same checkstyle "light" :)

    I'm okay with other built in features that would solve this problem. I've tried: Ctrl+Shift+F and Ctrl+Alt+C. Neither of which auto fix the trailing space automatically.

    enter image description here

  • James Oravec
    James Oravec about 11 years
    Thanks Alexander, this changes my environment though and not the check style settings. The check style settings are contained in an xml file which I can share with other developers. I found the answer to my question and will post the steps.
  • Martin Spamer
    Martin Spamer over 10 years
    There is no point gaming the system by accepting your own answer it doesn't earn you any points.
  • Jeffrey Martinez
    Jeffrey Martinez over 10 years
    @MartinSpamer, don't know the original intentions, but SO encourages folks to post questions and answers if it will be useful on the site (stackoverflow.com/help/self-answer)
  • MZS
    MZS over 4 years
    For the format property, I found I had to use a negative lookbehind instead of a negative lookahead. I also think [^$] matches everything but a dollar sign, not a newline. This worked for me: <property name="format" value="(?&lt;!^\s+\*)\s+$"/> It's not perfect, because it will ignore trailing whitespace on any line that starts with an asterisk (regardless of whether you're inside a Javadoc comment).