eclipse : Filtering for System.out.print calls

I want to have a check in place so that any print commands donot get checked into svn when i checkin my code. I installed "Checkstyle " plugin on eclipse but problem is that it gives error even if print command has been commented out.

My requirement is to ignore print commands in comments but not in main code.

Any info in this regard will be of gr8 help.

Regards Lokesh

Answers


As you told me in the comments, you used a custom rule using the regular expression "System\.out\.println". This seems to match every line that contains that string even if there are comments before it. You have to change your regex to match only lines that doesn't contain // before the command. "(?!//).*System\.out\.println" should work.

EDIT

Just remembered that PMD has an integrated rule for using System.out.println(). You could use that as an alternative to a custom checkstyle rule. Sadly the Eclipse plugin is not available for Juno yet but if you use an earlier version you should be fine.


I was able to resolve this by using "Regex" option under "Miscellaneous" [Preferences -> checkstyle->Miscellaneous->Regex] as it has option to ignore comments.

Thanks all for help.


Need Your Help

Google Maps Android API v2, Marker title/snippet wrong display

android google-maps internationalization google-places-api

I use Google Maps Android API v2 with Android to show current position with nearby markers.