Class SuppressElement
- java.lang.Object
-
- com.puppycrawl.tools.checkstyle.filters.SuppressElement
-
- All Implemented Interfaces:
Filter
public class SuppressElement extends java.lang.Object implements Filter
This filter processesAuditEventobjects based on the criteria of file, check, module id, line, and column. It rejects an AuditEvent if the following match:- the event's file name; and
- the check name or the module identifier; and
- (optionally) the event's line is in the filter's line CSV; and
- (optionally) the check's columns is in the filter's column CSV.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringcheckPatternThe pattern for check class names.private java.util.regex.PatterncheckRegexpThe regexp to match check names against.private CsvFiltercolumnFilterColumn number filter.private java.lang.StringcolumnsCsvCSV for column number filter.private java.lang.StringfilePatternThe pattern for file names.private java.util.regex.PatternfileRegexpThe regexp to match file names against.private CsvFilterlineFilterLine number filter.private java.lang.StringlinesCsvCSV for line number filter.private java.lang.StringmoduleIdModule id filter.
-
Constructor Summary
Constructors Constructor Description SuppressElement(java.lang.String files)Constructs aSuppressElementfor a file name pattern.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaccept(AuditEvent event)Determines whether or not a filtered AuditEvent is accepted.booleanequals(java.lang.Object other)inthashCode()private booleanisFileNameAndModuleNotMatching(AuditEvent event)Is matching by file name and Check name.private booleanisLineAndColumnMatch(AuditEvent event)Whether line and column match.voidsetChecks(java.lang.String checks)Set the check class pattern.voidsetColumns(java.lang.String columns)Sets the CSV values and ranges for column number filtering.voidsetLines(java.lang.String lines)Sets the CSV values and ranges for line number filtering.voidsetModuleId(java.lang.String moduleId)Set the module id for filtering.
-
-
-
Field Detail
-
fileRegexp
private final java.util.regex.Pattern fileRegexp
The regexp to match file names against.
-
filePattern
private final java.lang.String filePattern
The pattern for file names.
-
checkRegexp
private java.util.regex.Pattern checkRegexp
The regexp to match check names against.
-
checkPattern
private java.lang.String checkPattern
The pattern for check class names.
-
moduleId
private java.lang.String moduleId
Module id filter.
-
lineFilter
private CsvFilter lineFilter
Line number filter.
-
linesCsv
private java.lang.String linesCsv
CSV for line number filter.
-
columnFilter
private CsvFilter columnFilter
Column number filter.
-
columnsCsv
private java.lang.String columnsCsv
CSV for column number filter.
-
-
Constructor Detail
-
SuppressElement
public SuppressElement(java.lang.String files)
Constructs aSuppressElementfor a file name pattern. Must either callsetColumns(String)orsetModuleId(String)before using this object.- Parameters:
files- regular expression for names of filtered files.
-
-
Method Detail
-
setChecks
public void setChecks(java.lang.String checks)
Set the check class pattern.- Parameters:
checks- regular expression for filtered check classes.
-
setModuleId
public void setModuleId(java.lang.String moduleId)
Set the module id for filtering. Cannot be null.- Parameters:
moduleId- the id
-
setLines
public void setLines(java.lang.String lines)
Sets the CSV values and ranges for line number filtering. E.g. "1,7-15,18".- Parameters:
lines- CSV values and ranges for line number filtering.
-
setColumns
public void setColumns(java.lang.String columns)
Sets the CSV values and ranges for column number filtering. E.g. "1,7-15,18".- Parameters:
columns- CSV values and ranges for column number filtering.
-
accept
public boolean accept(AuditEvent event)
Description copied from interface:FilterDetermines whether or not a filtered AuditEvent is accepted.
-
isFileNameAndModuleNotMatching
private boolean isFileNameAndModuleNotMatching(AuditEvent event)
Is matching by file name and Check name.- Parameters:
event- event- Returns:
- true is matching
-
isLineAndColumnMatch
private boolean isLineAndColumnMatch(AuditEvent event)
Whether line and column match.- Parameters:
event- event to process.- Returns:
- true if line and column match.
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equalsin classjava.lang.Object
-
-