|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| AbstractNameCheck | Line # 32 | 100% |
1.0
|
5 | 6 | 5 | 5 | 0.83 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ( 10 of 40) | |||
| Result | |||
|
0.9230769
|
com.puppycrawl.tools.checkstyle.checks.naming.MethodNameCheckTest.testDefault
com.puppycrawl.tools.checkstyle.checks.naming.MethodNameCheckTest.testDefault
|
1 PASS | |
|
0.84615386
|
com.puppycrawl.tools.checkstyle.checks.naming.MemberNameCheckTest.testInnerClass
com.puppycrawl.tools.checkstyle.checks.naming.MemberNameCheckTest.testInnerClass
|
1 PASS | |
|
0.84615386
|
com.puppycrawl.tools.checkstyle.checks.naming.MemberNameCheckTest.testPublicOnly
com.puppycrawl.tools.checkstyle.checks.naming.MemberNameCheckTest.testPublicOnly
|
1 PASS | |
|
0.84615386
|
com.puppycrawl.tools.checkstyle.checks.naming.LocalVariableNameCheckTest.testDefault
com.puppycrawl.tools.checkstyle.checks.naming.LocalVariableNameCheckTest.testDefault
|
1 PASS | |
|
0.84615386
|
com.puppycrawl.tools.checkstyle.checks.naming.MemberNameCheckTest.testProtectedOnly
com.puppycrawl.tools.checkstyle.checks.naming.MemberNameCheckTest.testProtectedOnly
|
1 PASS | |
|
0.84615386
|
com.puppycrawl.tools.checkstyle.checks.naming.MemberNameCheckTest.testNotPrivate
com.puppycrawl.tools.checkstyle.checks.naming.MemberNameCheckTest.testNotPrivate
|
1 PASS | |
|
0.84615386
|
com.puppycrawl.tools.checkstyle.checks.naming.MemberNameCheckTest.testSpecified
com.puppycrawl.tools.checkstyle.checks.naming.MemberNameCheckTest.testSpecified
|
1 PASS | |
|
0.84615386
|
com.puppycrawl.tools.checkstyle.checks.naming.MemberNameCheckTest.testPrivateOnly
com.puppycrawl.tools.checkstyle.checks.naming.MemberNameCheckTest.testPrivateOnly
|
1 PASS | |
|
0.84615386
|
com.puppycrawl.tools.checkstyle.checks.naming.LocalFinalVariableNameCheckTest.testSet
com.puppycrawl.tools.checkstyle.checks.naming.LocalFinalVariableNameCheckTest.testSet
|
1 PASS | |
|
0.84615386
|
com.puppycrawl.tools.checkstyle.checks.naming.ConstantNameCheckTest.testDefault
com.puppycrawl.tools.checkstyle.checks.naming.ConstantNameCheckTest.testDefault
|
1 PASS | |
| 30 tests are not displayed. This report was configured to show the top 10 tests that covered this file. | |||
| 1 | //////////////////////////////////////////////////////////////////////////////// | |
| 2 | // checkstyle: Checks Java source code for adherence to a set of rules. | |
| 3 | // Copyright (C) 2001-2005 Oliver Burn | |
| 4 | // | |
| 5 | // This library is free software; you can redistribute it and/or | |
| 6 | // modify it under the terms of the GNU Lesser General Public | |
| 7 | // License as published by the Free Software Foundation; either | |
| 8 | // version 2.1 of the License, or (at your option) any later version. | |
| 9 | // | |
| 10 | // This library is distributed in the hope that it will be useful, | |
| 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 13 | // Lesser General Public License for more details. | |
| 14 | // | |
| 15 | // You should have received a copy of the GNU Lesser General Public | |
| 16 | // License along with this library; if not, write to the Free Software | |
| 17 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 18 | //////////////////////////////////////////////////////////////////////////////// | |
| 19 | ||
| 20 | package com.puppycrawl.tools.checkstyle.checks.naming; | |
| 21 | ||
| 22 | import com.puppycrawl.tools.checkstyle.api.DetailAST; | |
| 23 | import com.puppycrawl.tools.checkstyle.api.TokenTypes; | |
| 24 | import com.puppycrawl.tools.checkstyle.checks.AbstractFormatCheck; | |
| 25 | ||
| 26 | /** | |
| 27 | * Abstract class for checking that names conform to a specified format. | |
| 28 | * | |
| 29 | * @author Rick Giles | |
| 30 | * @version 1.0 | |
| 31 | */ | |
| 32 | public abstract class AbstractNameCheck | |
| 33 | extends AbstractFormatCheck | |
| 34 | { | |
| 35 | /** | |
| 36 | * Creates a new <code>AbstractNameCheck</code> instance. | |
| 37 | * @param aFormat format to check with | |
| 38 | */ | |
| 39 | 48 |
public AbstractNameCheck(String aFormat) |
| 40 | { | |
| 41 | 48 | super(aFormat); |
| 42 | } | |
| 43 | ||
| 44 | /** | |
| 45 | * Decides whether the name of an AST should be checked against | |
| 46 | * the format regexp. | |
| 47 | * @param aAST the AST to check. | |
| 48 | * @return true if the IDENT subnode of aAST should be checked against | |
| 49 | * the format regexp. | |
| 50 | */ | |
| 51 | 10 |
protected boolean mustCheckName(DetailAST aAST) |
| 52 | { | |
| 53 | 10 | return true; |
| 54 | } | |
| 55 | ||
| 56 | /** {@inheritDoc} */ | |
| 57 | 578 |
public void visitToken(DetailAST aAST) |
| 58 | { | |
| 59 | 578 | if (mustCheckName(aAST)) { |
| 60 | 213 | final DetailAST nameAST = aAST.findFirstToken(TokenTypes.IDENT); |
| 61 | 213 | if (!getRegexp().matcher(nameAST.getText()).find()) { |
| 62 | 131 | log(nameAST.getLineNo(), |
| 63 | nameAST.getColumnNo(), | |
| 64 | "name.invalidPattern", | |
| 65 | nameAST.getText(), | |
| 66 | getFormat()); | |
| 67 | } | |
| 68 | } | |
| 69 | } | |
| 70 | } | |
|
|||||||||||||