Custom Error Messages

Custom Error Messages

I just started using checkstyle and I desparately need it for
feedback reports for student assignments. So far, it has
already been very useful.

I know it's possible to have custom error messages, but it
is not quite clear to me how to get, say, the name of an
identifier which violates the LocalVariableName rule.

I've read the [Custom Messages] example on
http://checkstyle.sourceforge.net/config.htmlbut it is (completely) not clear to me where to find, say, the
messages.properties file for the sun rules. Also I didn't find
a Tools/plugins in the distribution.

Any pointers to examples/documentation will be extremely highly
valued:-)

Thanks in advance for your help.

Regards,

Marc van Dongen

------------------------------------------------------------------------------
Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
Tap into the largest installed PC base & get more eyes on your game by
optimizing for Intel(R) Graphics Technology. Get started today with the
Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
http://p.sf.net/sfu/intelisp-dev2dev_______________________________________________
Checkstyle-user mailing list
[hidden email]https://lists.sourceforge.net/lists/listinfo/checkstyle-user

Re: Custom Error Messages

Hello Marc,

the documentation says:

>The obvious question is how do you know which message keys a
Check uses, so that you can override them? Well, that is the tricky
part. To find out which keys a Check uses you currently need to look
into the Check's source code, in >conjunction with the Check's messages.properties
file. Tools/plugins might come to the rescue on this topic, so have
a look there.

This means you will probably need to download the Checkstyle source
distribution/check out the Checkstyle project from the source
repository (Mercurial I think).
Then look at the checkstyle configuration file you use to find out
which checks it is using.
For each check look for the matching check implementation class
(e.g. implementation class of the JavadocMethod check is
"com.puppycrawl...JavadocMethodCheck") in the Checkstyle sources.
When a check logs a message it usually uses a construct like:
log(aLineNo, "javadoc.return.expected");

The string argument is the message key you're looking for. Now
consult the messages.properties in the same package as the check in
question to cross-check you found the right message key you want to
override. This will also allow you to check whether the standard
message contains any parametrizable placeholders.

Dear all,
I just started using checkstyle and I desparately need it for
feedback reports for student assignments. So far, it has
already been very useful.
I know it's possible to have custom error messages, but it
is not quite clear to me how to get, say, the name of an
identifier which violates the LocalVariableName rule.
I've read the [Custom Messages] example on
http://checkstyle.sourceforge.net/config.html
but it is (completely) not clear to me where to find, say, the
messages.properties file for the sun rules. Also I didn't find
a Tools/plugins in the distribution.
Any pointers to examples/documentation will be extremely highly
valued:-)
Thanks in advance for your help.
Regards,
Marc van Dongen
------------------------------------------------------------------------------
Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
Tap into the largest installed PC base & get more eyes on your game by
optimizing for Intel(R) Graphics Technology. Get started today with the
Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
http://p.sf.net/sfu/intelisp-dev2dev
_______________________________________________
Checkstyle-user mailing list
[hidden email]https://lists.sourceforge.net/lists/listinfo/checkstyle-user

------------------------------------------------------------------------------
Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
Tap into the largest installed PC base & get more eyes on your game by
optimizing for Intel(R) Graphics Technology. Get started today with the
Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
http://p.sf.net/sfu/intelisp-dev2dev_______________________________________________
Checkstyle-user mailing list
[hidden email]https://lists.sourceforge.net/lists/listinfo/checkstyle-user