001////////////////////////////////////////////////////////////////////////////////
002// checkstyle: Checks Java source code for adherence to a set of rules.
003// Copyright (C) 2001-2014  Oliver Burn
004//
005// This library is free software; you can redistribute it and/or
006// modify it under the terms of the GNU Lesser General Public
007// License as published by the Free Software Foundation; either
008// version 2.1 of the License, or (at your option) any later version.
009//
010// This library is distributed in the hope that it will be useful,
011// but WITHOUT ANY WARRANTY; without even the implied warranty of
012// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013// Lesser General Public License for more details.
014//
015// You should have received a copy of the GNU Lesser General Public
016// License along with this library; if not, write to the Free Software
017// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
018////////////////////////////////////////////////////////////////////////////////
019package com.puppycrawl.tools.checkstyle.checks.metrics;
020
021import com.puppycrawl.tools.checkstyle.api.TokenTypes;
022
023/**
024 * The number of other classes a given class relies on. Also the square
025 * of this has been shown to indicate the amount of maintenance required
026 * in functional programs (on a file basis) at least.
027 *
028 * @author <a href="mailto:simon@redhillconsulting.com.au">Simon Harris</a>
029 * @author o_sukhodolsky
030 */
031public final class ClassFanOutComplexityCheck extends AbstractClassCouplingCheck
032{
033    /** default value of max value. */
034    private static final int DEFAULT_MAX = 20;
035
036    /** Creates new instance of this check. */
037    public ClassFanOutComplexityCheck()
038    {
039        super(DEFAULT_MAX);
040    }
041
042    @Override
043    public int[] getRequiredTokens()
044    {
045        return new int[] {
046            TokenTypes.PACKAGE_DEF,
047            TokenTypes.CLASS_DEF,
048            TokenTypes.INTERFACE_DEF,
049            TokenTypes.ENUM_DEF,
050            TokenTypes.TYPE,
051            TokenTypes.LITERAL_NEW,
052            TokenTypes.LITERAL_THROWS,
053            TokenTypes.ANNOTATION_DEF,
054        };
055    }
056
057    @Override
058    protected String getLogMessageId()
059    {
060        return "classFanOutComplexity";
061    }
062}