<commit_before>////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001  <NAME>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program 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 General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
////////////////////////////////////////////////////////////////////////////////
package com.puppycrawl.tools.checkstyle;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import org.apache.regexp.RESyntaxException;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.taskdefs.LogOutputStream;
import org.apache.tools.ant.types.EnumeratedAttribute;
import org.apache.tools.ant.types.FileSet;

/**
 * An implementation of a ANT task for calling checkstyle. See the documentation
 * of the task for usage.
 * @author <a href="mailto:<EMAIL>"><NAME></a>
 **/
public class CheckStyleTask
    extends Task
{
    /** poor man's enum for an xml formatter **/
    private static final String E_XML = "xml";
    /** poor man's enum for an plain formatter **/
    private static final String E_PLAIN = "plain";

    /** name of file to check **/
    private String mFileName;

    /** whether to fail build on violations **/
    private boolean mFailOnViolation = true;

    /** contains the filesets to process **/
    private final List mFileSets = new ArrayList();

    /** contains the formatters to log to **/
    private final List mFormatters = new ArrayList();

    /** the configuration to pass to the checker **/
    private final Configuration mConfig = new Configuration();

    ////////////////////////////////////////////////////////////////////////////
    // Setters for attributes
    ////////////////////////////////////////////////////////////////////////////

    /**
     * Adds a set of files (nested fileset attribute).
     * @param aFS the file set to add
     */
    public void addFileset(FileSet aFS)
    {
        mFileSets.add(aFS);
    }

    /**
     * Add a formatter
     * @param aFormatter the formatter to add for logging.
     */
    public void addFormatter(Formatter aFormatter)
    {
        mFormatters.add(aFormatter);
    }


    /** @param aFile the file to be checked **/
    public void setFile(File aFile)
    {
        mFileName = aFile.getAbsolutePath();
    }

    /** @param aAllowed whether tabs are allowed **/
    public void setAllowTabs(boolean aAllowed)
    {
        mConfig.setAllowTabs(aAllowed);
    }

    /** @param aAllowed whether protected data is allowed **/
    public void setAllowProtected(boolean aAllowed)
    {
        mConfig.setAllowProtected(aAllowed);
    }

    /** @param aAllowed whether allow having no author **/
    public void setAllowNoAuthor(boolean aAllowed)
    {
        mConfig.setAllowNoAuthor(aAllowed);
    }

    /** @param aLen max allowed line length **/
    public void setMaxLineLen(int aLen)
    {
        mConfig.setMaxLineLength(aLen);
    }

    /** @param aLen max allowed method length **/
    public void setMaxMethodLen(int aLen)
    {
        mConfig.setMaxMethodLength(aLen);
    }

    /** @param aLen max allowed constructor length **/
    public void setMaxConstructorLen(int aLen)
    {
        mConfig.setMaxConstructorLength(aLen);
    }

    /** @param aLen max allowed file length **/
    public void setMaxFileLen(int aLen)
    {
        mConfig.setMaxFileLength(aLen);
    }

    /** @param aIgnore whether max line length should be ignored for
     *                 import statements
     */
    public void setIgnoreImportLength(boolean aIgnore)
    {
        mConfig.setIgnoreImportLength(aIgnore);
    }

    /** @param aPat pattern for member variables **/
    public void setMemberPattern(String aPat)
    {
        try {
            mConfig.setMemberPat(aPat);
        }
        catch (RESyntaxException ex) {
            throw new BuildException("Unable to parse memberPattern - ", ex);
        }
    }

    /** @param aPat pattern for public member variables **/
    public void setPublicMemberPattern(String aPat)
    {
        try {
            mConfig.setPublicMemberPat(aPat);
        }
        catch (RESyntaxException ex) {
            throw new BuildException(
                "Unable to parse publicMemberPattern - ", ex);
        }<commit_msg>fix bug #508010, documentation and code are inconsistent<commit_after>////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001  <NAME>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program 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 General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
////////////////////////////////////////////////////////////////////////////////
package com.puppycrawl.tools.checkstyle;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import org.apache.regexp.RESyntaxException;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.taskdefs.LogOutputStream;
import org.apache.tools.ant.types.EnumeratedAttribute;
import org.apache.tools.ant.types.FileSet;

/**
 * An implementation of a ANT task for calling checkstyle. See the documentation
 * of the task for usage.
 * @author <a href="mailto:<EMAIL>"><NAME></a>
 **/
public class CheckStyleTask
    extends Task
{
    /** poor man's enum for an xml formatter **/
    private static final String E_XML = "xml";
    /** poor man's enum for an plain formatter **/
    private static final String E_PLAIN = "plain";

    /** name of file to check **/
    private String mFileName;

    /** whether to fail build on violations **/
    private boolean mFailOnViolation = true;

    /** contains the filesets to process **/
    private final List mFileSets = new ArrayList();

    /** contains the formatters to log to **/
    private final List mFormatters = new ArrayList();

    /** the configuration to pass to the checker **/
    private final Configuration mConfig = new Configuration();

    ////////////////////////////////////////////////////////////////////////////
    // Setters for attributes
    ////////////////////////////////////////////////////////////////////////////

    /**
     * Adds a set of files (nested fileset attribute).
     * @param aFS the file set to add
     */
    public void addFileset(FileSet aFS)
    {
        mFileSets.add(aFS);
    }

    /**
     * Add a formatter
     * @param aFormatter the formatter to add for logging.
     */
    public void addFormatter(Formatter aFormatter)
    {
        mFormatters.add(aFormatter);
    }


    /** @param aFile the file to be checked **/
    public void setFile(File aFile)
    {
        mFileName = aFile.getAbsolutePath();
    }

    /** @param aAllowed whether tabs are allowed **/
    public void setAllowTabs(boolean aAllowed)
    {
        mConfig.setAllowTabs(aAllowed);
    }

    /** @param aAllowed whether protected data is allowed **/
    public void setAllowProtected(boolean aAllowed)
    {
        mConfig.setAllowProtected(aAllowed);
    }

    /** @param aAllowed whether allow having no author **/
    public void setAllowNoAuthor(boolean aAllowed)
    {
        mConfig.setAllowNoAuthor(aAllowed);
    }

    /** @param aLen max allowed line length **/
    public void setMaxLineLen(int aLen)
    {
        mConfig.setMaxLineLength(aLen);
    }

    /** @param aLen max allowed method length **/
    public void setMaxMethodLen(int aLen)
    {
        mConfig.setMaxMethodLength(aLen);
    }

    /** @param aLen max allowed constructor length **/
    public void setMaxConstructorLen(int aLen)
    {
        mConfig.setMaxConstructorLength(aLen);
    }

    /** @param aLen max allowed file length **/
    public void setMaxFileLen(int aLen)
    {
        mConfig.setMaxFileLength(aLen);
    }

    /** @param aIgnore whether max line length should be ignored for
     *                 import statements
     */
    public void setIgnoreImportLen(boolean aIgnore)
    {
        mConfig.setIgnoreImportLength(aIgnore);
    }

    /** @param aPat pattern for member variables **/
    public void setMemberPattern(String aPat)
    {
        try {
            mConfig.setMemberPat(aPat);
        }
        catch (RESyntaxException ex) {
            throw new BuildException("Unable to parse memberPattern - ", ex);
        }
    }

    /** @param aPat pattern for public member variables **/
    public void setPublicMemberPattern(String aPat)
    {
        try {
            mConfig.setPublicMemberPat(aPat);
        }
        catch (RESyntaxException ex) {
            throw new BuildException(
                "Unable to parse publicMemberPattern - ", ex);
        }
{'fraction_non_alphanumeric': 0.14776032577079698, 'fraction_numerical': 0.0042660461508629045, 'mean_word_length': 2.1816779765576806, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, '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': '4940217', 'n_tokens_mistral': 2752, 'n_tokens_neox': 2683, 'n_words': 925}