<commit_before>////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2015 the original author or authors.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
////////////////////////////////////////////////////////////////////////////////

package com.puppycrawl.tools.checkstyle.checks.metrics;

import java.math.BigInteger;
import java.util.ArrayDeque;
import java.util.Deque;

import com.puppycrawl.tools.checkstyle.api.Check;
import com.puppycrawl.tools.checkstyle.api.DetailAST;
import com.puppycrawl.tools.checkstyle.api.TokenTypes;

/**
 * Base class for checks the calculate complexity based around methods.
 *
 * @author <a href="mailto:<EMAIL>"><NAME></a>
 * @author <NAME>
 */
public abstract class AbstractComplexityCheck
    extends Check {
    /** the initial current value */
    private static final BigInteger INITIAL_VALUE = BigInteger.ONE;

    /** stack of values - all but the current value */
    private final Deque<BigInteger> valueStack = new ArrayDeque<>();

    /** the current value */
    private BigInteger currentValue = BigInteger.ZERO;

    /** threshold to report error for */
    private int max;

    /**
     * Creates an instance.
     * @param max the threshold of when to report an error
     */
    public AbstractComplexityCheck(int max) {
        this.max = max;
    }

    /**
     * @return the message ID to log violations with
     */
    protected abstract String getMessageID();

    @Override
    public final int[] getRequiredTokens() {
        return new int[] {
            TokenTypes.CTOR_DEF,
            TokenTypes.METHOD_DEF,
            TokenTypes.INSTANCE_INIT,
            TokenTypes.STATIC_INIT,
        };
    }

    /** @return the maximum threshold allowed */
    public final int getMax() {
        return max;
    }

    /**
     * Set the maximum threshold allowed.
     *
     * @param max the maximum threshold
     */
    public final void setMax(int max) {
        this.max = max;<commit_msg>Decrease visibility of constructor in abstract class. #1555<commit_after>////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2015 the original author or authors.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
////////////////////////////////////////////////////////////////////////////////

package com.puppycrawl.tools.checkstyle.checks.metrics;

import java.math.BigInteger;
import java.util.ArrayDeque;
import java.util.Deque;

import com.puppycrawl.tools.checkstyle.api.Check;
import com.puppycrawl.tools.checkstyle.api.DetailAST;
import com.puppycrawl.tools.checkstyle.api.TokenTypes;

/**
 * Base class for checks the calculate complexity based around methods.
 *
 * @author <a href="mailto:<EMAIL>@<EMAIL>"><NAME></a>
 * @author <NAME>
 */
public abstract class AbstractComplexityCheck
    extends Check {
    /** the initial current value */
    private static final BigInteger INITIAL_VALUE = BigInteger.ONE;

    /** stack of values - all but the current value */
    private final Deque<BigInteger> valueStack = new ArrayDeque<>();

    /** the current value */
    private BigInteger currentValue = BigInteger.ZERO;

    /** threshold to report error for */
    private int max;

    /**
     * Creates an instance.
     * @param max the threshold of when to report an error
     */
    protected AbstractComplexityCheck(int max) {
        this.max = max;
    }

    /**
     * @return the message ID to log violations with
     */
    protected abstract String getMessageID();

    @Override
    public final int[] getRequiredTokens() {
        return new int[] {
            TokenTypes.CTOR_DEF,
            TokenTypes.METHOD_DEF,
            TokenTypes.INSTANCE_INIT,
            TokenTypes.STATIC_INIT,
        };
    }

    /** @return the maximum threshold allowed */
    public final int getMax() {
        return max;
    }

    /**
     * Set the maximum threshold allowed.
     *
     * @param max the maximum threshold
     */
    public final void setMax(int max) {
        this.max = max;
{'fraction_non_alphanumeric': 0.140918021075192, 'fraction_numerical': 0.00928737274513306, 'mean_word_length': 2.3116499112950915, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '684264', 'n_tokens_mistral': 1471, 'n_tokens_neox': 1398, 'n_words': 568}