Eclipse Checkstyle Disable "Lline has trailing spaces"
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.
Comments
-
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
andCtrl+Alt+C
. Neither of which auto fix the trailing space automatically. -
James Oravec about 11 yearsThanks 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 over 10 yearsThere is no point gaming the system by accepting your own answer it doesn't earn you any points.
-
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 over 4 yearsFor 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="(?<!^\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).