- As of Checkstyle 5 all checks can be configured to report custom,
- configuration specific messages instead of the Checkstyle default messages.
- This can be useful in cases where the check message should reference
- corresponding sections in a coding style document or the default is
- too generic for junior developers to understand.
+ As of Checkstyle 5 all checks can be configured to report
+ custom, configuration specific messages instead of the
+ Checkstyle default messages. This can be useful in cases where
+ the check message should reference corresponding sections in a
+ coding style document or the default is too generic for
+ developers to understand.
An example usage is:
+
- Each check configuration element can host 0-n message elements.
- Every check uses one or more distinct message keys to log violations. If you want to customize
- a certain message you need to specify the message key in the key attribute
- of the message element.
- The value attribute specifies the custom message pattern, as shown in the
- example.
- Placeholders used in the default message can also be used in the custom message.
- Note that the message pattern must be a valid java.text.MessageFormat style
- pattern, so be careful about curly braces outside a placeholder definition.
+ Each check configuration element can zero or more message elements. Every check uses one or
+ more distinct message keys to log violations. If you want to
+ customize a certain message you need to specify the message key
+ in the key attribute of the message element.
- How do you know, which message keys a check uses, so that you can override them?
- Well, thats the trick part. To find out which keys a check uses you currently need to look into
- the checks source code, in conjunction with the checks messages.properties file.
- Tools/plugins might come to the rescue on this topic, so have a look there.
+ The value attribute specifies the
+ custom message pattern, as shown in the example above.
+ Placeholders used in the default message can also be used in the
+ custom message. Note that the message pattern must be a valid
+ java.text.MessageFormat style pattern,
+ so be careful about curly braces outside a placeholder
+ definition.
+
+ 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.
@@ -650,7 +667,7 @@ document in a file. If there is no configured suppressions file, the Filter accepts all audit events.
- +