Issue #2451: removed excess hierarchy from AbstractNameCheck
This commit is contained in:
parent
2448576960
commit
541d6e2581
|
|
@ -42,7 +42,7 @@
|
|||
files="AbstractClassNameCheckTest.java|AbstractTypeAwareCheckTest.java|AbstractJavadocCheckTest.java|AbstractViolationReporterTest.java"/>
|
||||
|
||||
<!-- Tone down the checking for test code -->
|
||||
<suppress checks="CyclomaticComplexity" files="[\\/]XDocsPagesTest\.java" lines="328"/>
|
||||
<suppress checks="CyclomaticComplexity" files="[\\/]XDocsPagesTest\.java" lines="317"/>
|
||||
<suppress checks="EmptyBlock" files=".*[\\/]src[\\/]test[\\/]"/>
|
||||
<suppress checks="ImportControl" files=".*[\\/]src[\\/](test|it)[\\/]"/>
|
||||
<suppress checks="Javadoc" files=".*[\\/]src[\\/](test|it)[\\/]"/>
|
||||
|
|
|
|||
|
|
@ -19,9 +19,12 @@
|
|||
|
||||
package com.puppycrawl.tools.checkstyle.checks.naming;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.api.Check;
|
||||
import com.puppycrawl.tools.checkstyle.api.DetailAST;
|
||||
import com.puppycrawl.tools.checkstyle.api.TokenTypes;
|
||||
import com.puppycrawl.tools.checkstyle.checks.AbstractFormatCheck;
|
||||
import com.puppycrawl.tools.checkstyle.utils.CommonUtils;
|
||||
|
||||
/**
|
||||
* Abstract class for checking that names conform to a specified format.
|
||||
|
|
@ -29,30 +32,46 @@ import com.puppycrawl.tools.checkstyle.checks.AbstractFormatCheck;
|
|||
* @author Rick Giles
|
||||
*/
|
||||
public abstract class AbstractNameCheck
|
||||
extends AbstractFormatCheck {
|
||||
extends Check {
|
||||
/**
|
||||
* Message key for invalid pattern error.
|
||||
*/
|
||||
public static final String MSG_INVALID_PATTERN = "name.invalidPattern";
|
||||
|
||||
/** The format string of the regexp. */
|
||||
private String format;
|
||||
|
||||
/** The regexp to match against. */
|
||||
private Pattern regexp;
|
||||
|
||||
/**
|
||||
* Creates a new {@code AbstractNameCheck} instance.
|
||||
* @param format format to check with
|
||||
*/
|
||||
protected AbstractNameCheck(String format) {
|
||||
super(format);
|
||||
setFormat(format);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the format to the specified regular expression.
|
||||
* @param format a {@code String} value
|
||||
* @throws org.apache.commons.beanutils.ConversionException unable to parse format
|
||||
*/
|
||||
public final void setFormat(String format) {
|
||||
this.format = format;
|
||||
regexp = CommonUtils.createPattern(format);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitToken(DetailAST ast) {
|
||||
if (mustCheckName(ast)) {
|
||||
final DetailAST nameAST = ast.findFirstToken(TokenTypes.IDENT);
|
||||
if (!getRegexp().matcher(nameAST.getText()).find()) {
|
||||
if (!regexp.matcher(nameAST.getText()).find()) {
|
||||
log(nameAST.getLineNo(),
|
||||
nameAST.getColumnNo(),
|
||||
MSG_INVALID_PATTERN,
|
||||
nameAST.getText(),
|
||||
getFormat());
|
||||
format);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -110,17 +110,6 @@ public class XDocsPagesTest {
|
|||
|
||||
private static final List<String> UNDOCUMENTED_PROPERTIES = Arrays.asList(
|
||||
"SuppressWithNearbyCommentFilter.fileContents",
|
||||
"ClassTypeParameterNameCheck.compileFlags",
|
||||
"ConstantNameCheck.compileFlags",
|
||||
"InterfaceTypeParameterNameCheck.compileFlags",
|
||||
"LocalFinalVariableNameCheck.compileFlags",
|
||||
"LocalVariableNameCheck.compileFlags",
|
||||
"MemberNameCheck.compileFlags",
|
||||
"MethodNameCheck.compileFlags",
|
||||
"MethodTypeParameterNameCheck.compileFlags",
|
||||
"ParameterNameCheck.compileFlags",
|
||||
"StaticVariableNameCheck.compileFlags",
|
||||
"TypeNameCheck.compileFlags",
|
||||
"SuppressionCommentFilter.fileContents",
|
||||
"MethodNameCheck.applyToPackage",
|
||||
"MethodNameCheck.applyToPrivate",
|
||||
|
|
|
|||
Loading…
Reference in New Issue