[ checkstyle-Bugs-2019882 ] SuppressionCommentFilter ignores messageFormat

View: New views
1 Messages — Rating Filter:   Alert me  

[ checkstyle-Bugs-2019882 ] SuppressionCommentFilter ignores messageFormat

by SourceForge.net :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Bugs item #2019882, was opened at 2008-07-16 12:24
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=397078&aid=2019882&group_id=29721

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Core Framework
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Chris Brigham (cbrigham)
Assigned to: Oliver Burn (oburn)
Summary: SuppressionCommentFilter ignores messageFormat

Initial Comment:
SuppressionCommentFilters ignore their messageFormats if their checkFormat regex patterns match the check that triggered the event.  This is a problem because by default, all checks match the triggered event, causing messageFormat to be skipped.

As a local workaround, I must enter a garbage checkFormat string that I know will not match anything if I want my messageFormat to matter.

This bug also breaks the example present on http://checkstyle.sourceforge.net/config.html :

<module name="SuppressionCommentFilter">
    <property name="offCommentFormat" value="UNUSED OFF\: (\w+)"/>
    <property name="onCommentFormat" value="UNUSED ON\: (\w+)"/>
    <property name="checkFormat" value="Unused"/>
    <property name="messageFormat" value="^Unused \w+ '$1'.$"/>
</module>

The bug lies in the method SuppressionCommentFilter.Tag.isMatch(AuditEvent) at SuppressionCommentFilter:207-220:

        /**
         * Determines whether the source of an audit event
         * matches the text of this tag.
         * @param aEvent the <code>AuditEvent</code> to check.
         * @return true if the source of aEvent matches the text of this tag.
         */
        public boolean isMatch(AuditEvent aEvent)
        {
            final Matcher tagMatcher =
                mTagCheckRegexp.matcher(aEvent.getSourceName());
            if (tagMatcher.find()) {
                return true;
            }
            if (mTagMessageRegexp != null) {
                final Matcher messageMatcher =
                    mTagMessageRegexp.matcher(aEvent.getMessage());
                return messageMatcher.find();
            }
            return false;
        }

This code should be changed to:

        public boolean isMatch(AuditEvent aEvent)
        {
            final Matcher tagMatcher =
                mTagCheckRegexp.matcher(aEvent.getSourceName());
            if (tagMatcher.find()) {
                if (mTagMessageRegexp != null) {
                    final Matcher messageMatcher =
                            mTagMessageRegexp.matcher(aEvent.getMessage());
                    return messageMatcher.find();
                }
                return true;
            }
            return false;
        }

I apologize for any inappropriate formatting caused by pasting into this text input box.  Cheers,

- Chris

----------------------------------------------------------------------

You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=397078&aid=2019882&group_id=29721

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Checkstyle-devel mailing list
Checkstyle-devel@...
https://lists.sourceforge.net/lists/listinfo/checkstyle-devel