diff --git a/src/checkstyle/com/puppycrawl/tools/checkstyle/filters/IntMatchFilter.java b/src/checkstyle/com/puppycrawl/tools/checkstyle/filters/IntMatchFilter.java index 17dcfa9d0..e7ef82761 100644 --- a/src/checkstyle/com/puppycrawl/tools/checkstyle/filters/IntMatchFilter.java +++ b/src/checkstyle/com/puppycrawl/tools/checkstyle/filters/IntMatchFilter.java @@ -21,8 +21,7 @@ package com.puppycrawl.tools.checkstyle.filters; import com.puppycrawl.tools.checkstyle.api.Filter; /** - * This filter accepts a matching Integer and is neutral - * on other Objects. + * This filter accepts a matching Integer. * @author Rick Giles */ public class IntMatchFilter diff --git a/src/checkstyle/com/puppycrawl/tools/checkstyle/filters/IntRangeFilter.java b/src/checkstyle/com/puppycrawl/tools/checkstyle/filters/IntRangeFilter.java index deeb33c2d..4d585b6f6 100644 --- a/src/checkstyle/com/puppycrawl/tools/checkstyle/filters/IntRangeFilter.java +++ b/src/checkstyle/com/puppycrawl/tools/checkstyle/filters/IntRangeFilter.java @@ -21,8 +21,7 @@ package com.puppycrawl.tools.checkstyle.filters; import com.puppycrawl.tools.checkstyle.api.Filter; /** - * This filter accepts an Integer in a range and is neutral - * on other Objects. + * This filter accepts an Integer in a range. * @author Rick Giles */ public class IntRangeFilter diff --git a/src/checkstyle/com/puppycrawl/tools/checkstyle/filters/SuppressElement.java b/src/checkstyle/com/puppycrawl/tools/checkstyle/filters/SuppressElement.java index 3b0241a0a..6ed6f443e 100644 --- a/src/checkstyle/com/puppycrawl/tools/checkstyle/filters/SuppressElement.java +++ b/src/checkstyle/com/puppycrawl/tools/checkstyle/filters/SuppressElement.java @@ -27,8 +27,12 @@ import com.puppycrawl.tools.checkstyle.api.Utils; /** *

- * This filter denies AuditEvents according to file, check, line, and - * column. It is neutral on Objects that are not AuditEvents. + * This filter accepts AuditEvents according to file, check, line, and + * column conditions. It rejects an AuditEvent if the event's file + * name and check name match the filter's file name and check name + * patterns, and the event's line is in the filter's line CSV or the + * check's columns is in the filter's column CSV. + * It rejects Objects that are not AuditEvents. *

* @author Rick Giles */ @@ -114,7 +118,7 @@ public class SuppressElement public boolean accept(Object aObject) { if (!(aObject instanceof AuditEvent)) { - return true; + return false; } final AuditEvent event = (AuditEvent) aObject; @@ -133,7 +137,7 @@ public class SuppressElement return false; } - // reject line if it is accepted by the line CSV filter + // reject if line matches a line CSV value. if (mLineFilter != null) { final Integer line = new Integer(event.getLine()); if (mLineFilter.accept(line)) { @@ -141,7 +145,7 @@ public class SuppressElement } } - // reject if column accepted by the column CSV filter + // reject if column matches a column CSV value. if (mColumnFilter != null) { final Integer column = new Integer(event.getColumn()); if (mColumnFilter.accept(column)) { diff --git a/src/checkstyle/com/puppycrawl/tools/checkstyle/filters/SuppressionFilter.java b/src/checkstyle/com/puppycrawl/tools/checkstyle/filters/SuppressionFilter.java index e195ed17a..172ba1898 100644 --- a/src/checkstyle/com/puppycrawl/tools/checkstyle/filters/SuppressionFilter.java +++ b/src/checkstyle/com/puppycrawl/tools/checkstyle/filters/SuppressionFilter.java @@ -19,6 +19,7 @@ package com.puppycrawl.tools.checkstyle.filters; import com.puppycrawl.tools.checkstyle.SuppressionsLoader; +import com.puppycrawl.tools.checkstyle.api.AuditEvent; import com.puppycrawl.tools.checkstyle.api.AutomaticBean; import com.puppycrawl.tools.checkstyle.api.CheckstyleException; import com.puppycrawl.tools.checkstyle.api.Filter; @@ -26,9 +27,9 @@ import com.puppycrawl.tools.checkstyle.api.FilterSet; /** *

- * This filter suppresses AuditEvents according to file, check, line, and + * This filter accepts AuditEvents according to file, check, line, and * column, as specified in a suppression file. - * It is neutral on Objects that are not AuditEvents. + * It rejects Objects that are not AuditEvents. *

* @author Rick Giles */ @@ -36,8 +37,8 @@ public class SuppressionFilter extends AutomaticBean implements Filter { - /** chain of individual suppresses */ - private FilterSet mFilterChain = new FilterSet(); + /** set of individual suppresses */ + private FilterSet mFilters = new FilterSet(); /** * Loads the suppressions for a file. @@ -47,25 +48,30 @@ public class SuppressionFilter public void setFile(String aFileName) throws CheckstyleException { - mFilterChain = SuppressionsLoader.loadSuppressions(aFileName); + mFilters = SuppressionsLoader.loadSuppressions(aFileName); } /** @see com.puppycrawl.tools.checkstyle.api.Filter */ public boolean accept(Object aObject) { - return mFilterChain.accept(aObject); + if (!(aObject instanceof AuditEvent)) { + return false; + } + else { + return mFilters.accept(aObject); + } } /** @see java.lang.Object#toString() */ public String toString() { - return mFilterChain.toString(); + return mFilters.toString(); } /** @see java.lang.Object#hashCode() */ public int hashCode() { - return mFilterChain.hashCode(); + return mFilters.hashCode(); } /** @see java.lang.Object#equals(java.lang.Object) */ @@ -73,7 +79,7 @@ public class SuppressionFilter { if (aObject instanceof SuppressionFilter) { final SuppressionFilter other = (SuppressionFilter) aObject; - return this.mFilterChain.equals(other.mFilterChain); + return this.mFilters.equals(other.mFilters); } else { return false;