Skip to content

SuppressionCommentFilter ignores messageFormat #76

Closed
romani opened this Issue Dec 8, 2013 · 2 comments

2 participants

@romani
Checkstyle member
romani commented Dec 8, 2013

SF issue: 520
Created: 2008-07-16
Creator: Chris Brigham

SuppressionCommentFilters ignore their messageFormats if their checkFormat regex patterns match the check that triggered the event.

Expected: messageFormats should apply as "AND" after match for checkFormat.
This bug also breaks the example present on http://checkstyle.sourceforge.net/config.html so it have to resolved.

SyncError.java, without changing config, change in file "2" to "3". in case of "3" violation have to be present.

import java.util.concurrent.ExecutionException;
import java.util.zip.DataFormatException;

public class SyncError {

    // ThrowsCount OFF: 2
    protected void beginTransaction1() throws ExecutionException, DataFormatException {
        // ...
    }
    // ThrowsCount OFF: 2


}

my_checks.xml:

<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
          "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
          "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">

<module name="Checker">
    <module name="TreeWalker">
        <module name="FileContentsHolder"/>
        <module name="ThrowsCount"/>
    </module>
        <module name="SuppressionCommentFilter">
            <property name="offCommentFormat" value="ThrowsCount OFF\: (\w+)"/>
            <property name="onCommentFormat" value="ThrowsCount ON\: (\w+)"/>
            <property name="checkFormat" value="ThrowsCount"/>
            <property name="messageFormat" value="^Throws count \w+ $1 .*$"/>
        </module>
</module>

Command:

java -cp file:///home/rivanov/java/git-others/checkstyle/target/checkstyle-5.7-SNAPSHOT-all.jar com.puppycrawl.tools.checkstyle.Main -c my_checks.xml SyncError.java 
@romani romani closed this Dec 9, 2013
@Splaktar
Splaktar commented Jun 7, 2014

Is this fix in 5.7?

@romani
Checkstyle member
romani commented Jun 8, 2014

Yes, it should work in 5.7.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.