|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| AbstractHeaderCheck | Line # 32 | 100% |
1.0
|
7 | 7 | 7 | 7 | 1 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ( 10 of 14) | |||
| Result | |||
|
0.6
|
com.puppycrawl.tools.checkstyle.checks.header.HeaderCheckTest.testRegexpHeader
com.puppycrawl.tools.checkstyle.checks.header.HeaderCheckTest.testRegexpHeader
|
1 PASS | |
|
0.6
|
com.puppycrawl.tools.checkstyle.checks.header.HeaderCheckTest.testRegexpHeaderMulti3
com.puppycrawl.tools.checkstyle.checks.header.HeaderCheckTest.testRegexpHeaderMulti3
|
1 PASS | |
|
0.6
|
com.puppycrawl.tools.checkstyle.checks.header.HeaderCheckTest.testInlineRegexpHeader
com.puppycrawl.tools.checkstyle.checks.header.HeaderCheckTest.testInlineRegexpHeader
|
1 PASS | |
|
0.6
|
com.puppycrawl.tools.checkstyle.checks.header.HeaderCheckTest.testRegexpHeaderMulti2
com.puppycrawl.tools.checkstyle.checks.header.HeaderCheckTest.testRegexpHeaderMulti2
|
1 PASS | |
|
0.6
|
com.puppycrawl.tools.checkstyle.checks.header.HeaderCheckTest.testRegexpHeaderIgnore
com.puppycrawl.tools.checkstyle.checks.header.HeaderCheckTest.testRegexpHeaderIgnore
|
1 PASS | |
|
0.6
|
com.puppycrawl.tools.checkstyle.checks.header.HeaderCheckTest.testRegexpHeaderMulti4
com.puppycrawl.tools.checkstyle.checks.header.HeaderCheckTest.testRegexpHeaderMulti4
|
1 PASS | |
|
0.6
|
com.puppycrawl.tools.checkstyle.checks.header.HeaderCheckTest.testRegexpHeaderSmallHeader
com.puppycrawl.tools.checkstyle.checks.header.HeaderCheckTest.testRegexpHeaderSmallHeader
|
1 PASS | |
|
0.6
|
com.puppycrawl.tools.checkstyle.checks.header.HeaderCheckTest.testStaticHeader
com.puppycrawl.tools.checkstyle.checks.header.HeaderCheckTest.testStaticHeader
|
1 PASS | |
|
0.6
|
com.puppycrawl.tools.checkstyle.checks.header.HeaderCheckTest.testRegexpHeaderMulti5
com.puppycrawl.tools.checkstyle.checks.header.HeaderCheckTest.testRegexpHeaderMulti5
|
1 PASS | |
|
0.6
|
com.puppycrawl.tools.checkstyle.checks.header.HeaderCheckTest.testRegexpHeaderMulti1
com.puppycrawl.tools.checkstyle.checks.header.HeaderCheckTest.testRegexpHeaderMulti1
|
1 PASS | |
| 4 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.header; | |
| 21 | ||
| 22 | import org.apache.commons.beanutils.ConversionException; | |
| 23 | ||
| 24 | import com.puppycrawl.tools.checkstyle.api.Check; | |
| 25 | import com.puppycrawl.tools.checkstyle.api.CheckstyleException; | |
| 26 | ||
| 27 | /** | |
| 28 | * Abstract super class for header checks. | |
| 29 | * Provides support for headerFile property. | |
| 30 | * @author o_sukhosolsky | |
| 31 | */ | |
| 32 | public abstract class AbstractHeaderCheck extends Check | |
| 33 | { | |
| 34 | /** information about the expected header file. */ | |
| 35 | private HeaderInfo mHeaderInfo = createHeaderInfo(); | |
| 36 | ||
| 37 | /** | |
| 38 | * Return the header lines to check against. | |
| 39 | * @return the header lines to check against. | |
| 40 | */ | |
| 41 | 1 |
protected String[] getHeaderLines() |
| 42 | { | |
| 43 | 1 | return mHeaderInfo.getHeaderLines(); |
| 44 | } | |
| 45 | ||
| 46 | /** | |
| 47 | * Abstract factory method to create an unconfigured | |
| 48 | * header info bean. Note that the actual type of the | |
| 49 | * return value can be subclass specific. | |
| 50 | * | |
| 51 | * @return a header info bean for this check. | |
| 52 | */ | |
| 53 | protected abstract HeaderInfo createHeaderInfo(); | |
| 54 | ||
| 55 | /** | |
| 56 | * Return the header info to check against. | |
| 57 | * @return the header info to check against. | |
| 58 | */ | |
| 59 | 15 |
protected HeaderInfo getHeaderInfo() |
| 60 | { | |
| 61 | 15 | return mHeaderInfo; |
| 62 | } | |
| 63 | ||
| 64 | /** | |
| 65 | * Set the header file to check against. | |
| 66 | * @param aFileName the file that contains the header to check against. | |
| 67 | * @throws ConversionException if the file cannot be loaded | |
| 68 | */ | |
| 69 | 11 |
public void setHeaderFile(String aFileName) |
| 70 | throws ConversionException | |
| 71 | { | |
| 72 | 11 | mHeaderInfo.setHeaderFile(aFileName); |
| 73 | } | |
| 74 | ||
| 75 | /** | |
| 76 | * Set the header to check against. Individual lines in the header | |
| 77 | * must be separated by '\n' characters. | |
| 78 | * @param aHeader header content to check against. | |
| 79 | * @throws ConversionException if the header cannot be interpreted | |
| 80 | */ | |
| 81 | 2 |
public void setHeader(String aHeader) |
| 82 | { | |
| 83 | 2 | mHeaderInfo.setHeader(aHeader); |
| 84 | } | |
| 85 | ||
| 86 | /** | |
| 87 | * Checks that required args were specified. | |
| 88 | * @throws CheckstyleException {@inheritDoc} | |
| 89 | * @see com.puppycrawl.tools.checkstyle.api.AutomaticBean#finishLocalSetup | |
| 90 | */ | |
| 91 | 12 |
protected final void finishLocalSetup() throws CheckstyleException |
| 92 | { | |
| 93 | 12 | if (mHeaderInfo.getHeaderLines() == null) { |
| 94 | 2 | throw new CheckstyleException( |
| 95 | "property 'headerFile' is missing or invalid in module " | |
| 96 | + getConfiguration().getName()); | |
| 97 | } | |
| 98 | } | |
| 99 | ||
| 100 | /** {@inheritDoc} */ | |
| 101 | 10 |
public final int[] getDefaultTokens() |
| 102 | { | |
| 103 | 10 | return new int[0]; |
| 104 | } | |
| 105 | ||
| 106 | } | |
|
|||||||||||||