|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| AbstractBeanCheck | Line # 38 | 92.9% |
0.9285714
|
9.03 | 15 | 9 | 9 | 0.6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ( 10 of 13) | |||
| Result | |||
|
0.85714287
|
com.puppycrawl.tools.checkstyle.checks.j2ee.SessionBeanCheckTest.testDefault
com.puppycrawl.tools.checkstyle.checks.j2ee.SessionBeanCheckTest.testDefault
|
1 PASS | |
|
0.78571427
|
com.puppycrawl.tools.checkstyle.checks.j2ee.MessageBeanCheckTest.testDefault
com.puppycrawl.tools.checkstyle.checks.j2ee.MessageBeanCheckTest.testDefault
|
1 PASS | |
|
0.60714287
|
com.puppycrawl.tools.checkstyle.checks.j2ee.EntityBeanCheckTest.testMissingConstructor
com.puppycrawl.tools.checkstyle.checks.j2ee.EntityBeanCheckTest.testMissingConstructor
|
1 PASS | |
|
0.5714286
|
com.puppycrawl.tools.checkstyle.checks.j2ee.EntityBeanCheckTest.testAbstractBeanBean
com.puppycrawl.tools.checkstyle.checks.j2ee.EntityBeanCheckTest.testAbstractBeanBean
|
1 PASS | |
|
0.5714286
|
com.puppycrawl.tools.checkstyle.checks.j2ee.EntityBeanCheckTest.testPostCreate
com.puppycrawl.tools.checkstyle.checks.j2ee.EntityBeanCheckTest.testPostCreate
|
1 PASS | |
|
0.5714286
|
com.puppycrawl.tools.checkstyle.checks.j2ee.EntityBeanCheckTest.testContainerBean
com.puppycrawl.tools.checkstyle.checks.j2ee.EntityBeanCheckTest.testContainerBean
|
1 PASS | |
|
0.5714286
|
com.puppycrawl.tools.checkstyle.checks.j2ee.EntityBeanCheckTest.testAbstractBean
com.puppycrawl.tools.checkstyle.checks.j2ee.EntityBeanCheckTest.testAbstractBean
|
1 PASS | |
|
0.5714286
|
com.puppycrawl.tools.checkstyle.checks.j2ee.EntityBeanCheckTest.testFind
com.puppycrawl.tools.checkstyle.checks.j2ee.EntityBeanCheckTest.testFind
|
1 PASS | |
|
0.5714286
|
com.puppycrawl.tools.checkstyle.checks.j2ee.EntityBeanCheckTest.testBeanBean
com.puppycrawl.tools.checkstyle.checks.j2ee.EntityBeanCheckTest.testBeanBean
|
1 PASS | |
|
0.5714286
|
com.puppycrawl.tools.checkstyle.checks.j2ee.EntityBeanCheckTest.testDefaultBean
com.puppycrawl.tools.checkstyle.checks.j2ee.EntityBeanCheckTest.testDefaultBean
|
1 PASS | |
| 3 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 | package com.puppycrawl.tools.checkstyle.checks.j2ee; | |
| 20 | ||
| 21 | import com.puppycrawl.tools.checkstyle.api.DetailAST; | |
| 22 | import com.puppycrawl.tools.checkstyle.api.TokenTypes; | |
| 23 | ||
| 24 | /** | |
| 25 | * Abstract class for checks that verify Bean implementation. | |
| 26 | * | |
| 27 | * Checks that a Bean implementation satisfies Bean | |
| 28 | * requirements: | |
| 29 | * <ul> | |
| 30 | * <li>The class is defined as <code>public</code>.</li> | |
| 31 | * <li>The class cannot be defined as <code>abstract</code> or | |
| 32 | * <code>final</code>.</li> | |
| 33 | * <li>It contains a <code>public</code> constructor with no parameters.</li> | |
| 34 | * <li>It must not define the <code>finalize</code> method.</li> | |
| 35 | </ul> | |
| 36 | * @author Rick Giles | |
| 37 | */ | |
| 38 | public abstract class AbstractBeanCheck | |
| 39 | extends AbstractJ2eeCheck | |
| 40 | { | |
| 41 | /** | |
| 42 | * {@inheritDoc} | |
| 43 | */ | |
| 44 | 17 |
public int[] getDefaultTokens() |
| 45 | { | |
| 46 | 17 | return new int[] {TokenTypes.CLASS_DEF}; |
| 47 | } | |
| 48 | ||
| 49 | /** | |
| 50 | * {@inheritDoc} | |
| 51 | */ | |
| 52 | 0 |
public int[] getRequiredTokens() |
| 53 | { | |
| 54 | 0 | return getDefaultTokens(); |
| 55 | } | |
| 56 | ||
| 57 | /** | |
| 58 | * Checks a bean class requirements. | |
| 59 | * <ul> | |
| 60 | * <li>The class is defined as <code>public</code>.</li> | |
| 61 | * <li>It contains a <code>public</code> constructor with no parameters.</li> | |
| 62 | * <li>It must not define the <code>finalize</code> method.</li> | |
| 63 | * </ul> | |
| 64 | * @param aAST CLASS_DEF node for class definition to check. | |
| 65 | * @param aBeanType bean type for error messages. | |
| 66 | * @param aAllowAbstract if false, the class cannot be abstract. | |
| 67 | */ | |
| 68 | 21 |
protected void checkBean( |
| 69 | DetailAST aAST, | |
| 70 | String aBeanType, | |
| 71 | boolean aAllowAbstract) | |
| 72 | { | |
| 73 | 21 | final DetailAST nameAST = aAST.findFirstToken(TokenTypes.IDENT); |
| 74 | 21 | final String name = nameAST.getText(); |
| 75 | 21 | final String arg = aBeanType + " '" + name + "'"; |
| 76 | ||
| 77 | 21 | if (!Utils.isPublic(aAST)) { |
| 78 | 4 | log(nameAST.getLineNo(), nameAST.getColumnNo(), |
| 79 | "nonpublic.bean", arg); | |
| 80 | } | |
| 81 | 21 | if (Utils.isFinal(aAST)) { |
| 82 | 2 | log(nameAST.getLineNo(), nameAST.getColumnNo(), |
| 83 | "illegalmodifier.bean", | |
| 84 | new Object[] {arg, "final"}); | |
| 85 | } | |
| 86 | 21 | if (!aAllowAbstract && Utils.isAbstract(aAST)) { |
| 87 | 2 | log(nameAST.getLineNo(), nameAST.getColumnNo(), |
| 88 | "illegalmodifier.bean", | |
| 89 | new Object[] {arg, "abstract"}); | |
| 90 | } | |
| 91 | 21 | if (!Utils.hasPublicConstructor(aAST, 0)) { |
| 92 | 1 | log(nameAST.getLineNo(), nameAST.getColumnNo(), |
| 93 | "nonpublicconstructor.bean", arg); | |
| 94 | } | |
| 95 | 21 | if (Utils.hasPublicMethod(aAST, "finalize", true, 0)) { |
| 96 | 1 | log( |
| 97 | nameAST.getLineNo(), | |
| 98 | nameAST.getColumnNo(), | |
| 99 | "hasfinalize.bean", | |
| 100 | arg); | |
| 101 | } | |
| 102 | } | |
| 103 | } | |
|
|||||||||||||