<commit_before>package com.cflint.main;

import java.awt.Desktop;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

import javax.swing.JFileChooser;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.xml.bind.JAXBException;
import javax.xml.transform.TransformerException;

import com.cflint.*;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.GnuParser;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Options;

import com.cflint.config.CFLintChainedConfig;
import com.cflint.config.CFLintConfig;
import com.cflint.config.CFLintConfiguration;
import com.cflint.config.CFLintPluginInfo;
import com.cflint.config.CFLintPluginInfo.PluginInfoRule;
import com.cflint.config.CFLintPluginInfo.PluginInfoRule.PluginMessage;
import com.cflint.config.CFLintPluginInfo.RuleGroup;
import com.cflint.config.ConfigUtils;
import com.cflint.tools.CFLintFilter;
import com.cflint.xml.MarshallerException;
import com.cflint.xml.stax.DefaultCFlintResultMarshaller;

public class CFLintMain {
    private static final String CFLINT = "cflint";
    private static final String FINDBUGS = "findbugs";
    private static final String DISPLAY_THIS_HELP = "display this help";

    private List<String> folder = new ArrayList<String>();
    private String filterFile = null;
    private boolean verbose = false;
    private boolean logerror = false;
    private boolean quiet = false;
    private boolean xmlOutput = false;
    private boolean jsonOutput = false;
    private boolean htmlOutput = true;
    private boolean textOutput = false;
    private String xmlOutFile = "cflint-result.xml";
    private String xmlstyle = CFLINT;
    private String htmlOutFile = "cflint-result.html";
    private  String htmlStyle = "plain.xsl";
    private String jsonOutFile = "cflint-result.json";
    private String textOutFile = null;
    private CFLintConfig cmdLineConfig = null;
    private CFLintConfig configFileConfig = null;
    private CFLintConfig defaultConfig = null;
    private String extensions;
    private boolean showprogress = false;
    private boolean progressUsesThread = true;
    private Boolean stdIn = false;
    private String stdInFile = "source.cfc";
    private Boolean stdOut = false;
    // private String configfile = null;
    private boolean strictInclude;

    public static void main(final String[] args) throws Exception {
        final Options options = new Options();
        options.addOption(Settings.RULES, false, "list of all supported rules");
        options.addOption(Settings.CONFIG, false, "list of rules in config file");
        options.addOption(Settings.INCLUDE_RULE, true, "specify rules to include");
        options.addOption(Settings.EXCLUDE_RULE, true, "specify rules to exclude");
        options.addOption(Settings.FOLDER, true, "folder(s) to scan");
        options.addOption(Settings.FILE, true, "file(s) to scan");
        options.addOption(Settings.FILTER_FILE, true, "filter file");
        options.addOption(Settings.V, false, "verbose output");
        options.addOption(Settings.VERSION, false, "show the version number");
        options.addOption(Settings.UI, false, "show UI");
        options.addOption(Settings.VERBOSE, false, "verbose output");
        options.addOption(Settings.STRICT_INCLUDE, false, "Check every include and try to parse it");
        options.addOption(Settings.SHOWPROGRESS, false, "show progress bar");
        options.addOption(Settings.SINGLETHREAD, false, "show progress bar");

        options.addOption(Settings.LOGERROR, false, "log parsing errors as bugs");
        options.addOption(Settings.E, false, "log parsing errors as bugs");
        options.addOption(Settings.QUIET, false,"less output");
        options.addOption(Settings.Q, false, "less output");
        options.addOption(Settings.HELP, false, DISPLAY_THIS_HELP);
        options.addOption(Settings.QUESTION_MARK, false, DISPLAY_THIS_HELP);
        options.addOption(Settings.H, false, DISPLAY_THIS_HELP);
        options.addOption(Settings.XML, false, "output in xml format");
        options.addOption(Settings.XMLFILE, true, "specify the output xml file (default: cflint-results.xml)");
        options.addOption(Settings.XMLSTYLE, true, "cflint,findbugs");
        options.addOption(Settings.HTML, false, "output in html format (default)");
        options.addOption(Settings.HTMLFILE, true, "specify the output html file (default: cflint-results.html)");
        options.addOption(Settings.HTMLSTYLE, true, "default,plain");// fancy,fancy-hist,summary
        options.addOption(Settings.JSON, false, "output in json format");
        options.addOption(Settings.JSONFILE, true, "specify the output json file (default: cflint-results.json)");
        options.addOption(Settings.TEXT, false, "output in plain text");
        options.addOption(Settings.TEXTFILE, true, "specify the output text file (default: cflint-results.txt)");
        options.addOption(Settings.EXTENSIONS, true, "specify the extensions of the CF source files (default: .cfm,.cfc)");
        options.addOption(Settings.CONFIGFILE, true, "specify the location of the config file");
        options.addOption(Settings.STDIN, true, "use stdin for file input (default: source.cfc)");
        options.addOption(Settings.STDOUT, false, "output to stdout only");
        options.addOption(Settings.LIST_RULE_GROUPS, false, "list rule groups");
        options.addOption(Settings.RULE_GROUPS, true, "rule groups");

        final CommandLineParser parser = new GnuParser();
        final CommandLine cmd = parser.parse(options, args);
        final CFLintMain main = new CFLintMain();

        if (cmd.hasOption(Settings.H) || cmd.hasOption(Settings.HELP) || cmd.hasOption(Settings.QUESTION_MARK)) {
            final HelpFormatter formatter = new HelpFormatter();
            formatter.printHelp(CFLINT, options);
            return;
        }
        if (cmd.hasOption(Settings.VERSION)) {
            System.out.println("CFLint " + Version.getVersion());
            System.out.println("CFParser " + cfml.parsing.Version.getVersion());
            return;
        }
        main.strictInclude = cmd.hasOption(Settings.STRICT_INCLUDE);
        if (cmd.hasOption(Settings.RULES) || cmd.hasOption(Settings.CONFIG)) {
            final CFLintPluginInfo pluginInfo = cmd.hasOption(Settings.RULES) ? ConfigUtils.loadDefaultPluginInfo()
                    : new CFLintPluginInfo();<commit_msg>fix single thread message and add a couple of spaces<commit_after>package com.cflint.main;

import java.awt.Desktop;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

import javax.swing.JFileChooser;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.xml.bind.JAXBException;
import javax.xml.transform.TransformerException;

import com.cflint.*;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.GnuParser;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Options;

import com.cflint.config.CFLintChainedConfig;
import com.cflint.config.CFLintConfig;
import com.cflint.config.CFLintConfiguration;
import com.cflint.config.CFLintPluginInfo;
import com.cflint.config.CFLintPluginInfo.PluginInfoRule;
import com.cflint.config.CFLintPluginInfo.PluginInfoRule.PluginMessage;
import com.cflint.config.CFLintPluginInfo.RuleGroup;
import com.cflint.config.ConfigUtils;
import com.cflint.tools.CFLintFilter;
import com.cflint.xml.MarshallerException;
import com.cflint.xml.stax.DefaultCFlintResultMarshaller;

public class CFLintMain {
    private static final String CFLINT = "cflint";
    private static final String FINDBUGS = "findbugs";
    private static final String DISPLAY_THIS_HELP = "display this help";

    private List<String> folder = new ArrayList<String>();
    private String filterFile = null;
    private boolean verbose = false;
    private boolean logerror = false;
    private boolean quiet = false;
    private boolean xmlOutput = false;
    private boolean jsonOutput = false;
    private boolean htmlOutput = true;
    private boolean textOutput = false;
    private String xmlOutFile = "cflint-result.xml";
    private String xmlstyle = CFLINT;
    private String htmlOutFile = "cflint-result.html";
    private  String htmlStyle = "plain.xsl";
    private String jsonOutFile = "cflint-result.json";
    private String textOutFile = null;
    private CFLintConfig cmdLineConfig = null;
    private CFLintConfig configFileConfig = null;
    private CFLintConfig defaultConfig = null;
    private String extensions;
    private boolean showprogress = false;
    private boolean progressUsesThread = true;
    private Boolean stdIn = false;
    private String stdInFile = "source.cfc";
    private Boolean stdOut = false;
    // private String configfile = null;
    private boolean strictInclude;

    public static void main(final String[] args) throws Exception {
        final Options options = new Options();
        options.addOption(Settings.RULES, false, "list of all supported rules");
        options.addOption(Settings.CONFIG, false, "list of rules in config file");
        options.addOption(Settings.INCLUDE_RULE, true, "specify rules to include");
        options.addOption(Settings.EXCLUDE_RULE, true, "specify rules to exclude");
        options.addOption(Settings.FOLDER, true, "folder(s) to scan");
        options.addOption(Settings.FILE, true, "file(s) to scan");
        options.addOption(Settings.FILTER_FILE, true, "filter file");
        options.addOption(Settings.V, false, "verbose output");
        options.addOption(Settings.VERSION, false, "show the version number");
        options.addOption(Settings.UI, false, "show UI");
        options.addOption(Settings.VERBOSE, false, "verbose output");
        options.addOption(Settings.STRICT_INCLUDE, false, "Check every include and try to parse it");
        options.addOption(Settings.SHOWPROGRESS, false, "show progress bar");
        options.addOption(Settings.SINGLETHREAD, false, "run single threaded");

        options.addOption(Settings.LOGERROR, false, "log parsing errors as bugs");
        options.addOption(Settings.E, false, "log parsing errors as bugs");
        options.addOption(Settings.QUIET, false, "less output");
        options.addOption(Settings.Q, false, "less output");
        options.addOption(Settings.HELP, false, DISPLAY_THIS_HELP);
        options.addOption(Settings.QUESTION_MARK, false, DISPLAY_THIS_HELP);
        options.addOption(Settings.H, false, DISPLAY_THIS_HELP);
        options.addOption(Settings.XML, false, "output in xml format");
        options.addOption(Settings.XMLFILE, true, "specify the output xml file (default: cflint-results.xml)");
        options.addOption(Settings.XMLSTYLE, true, "cflint,findbugs");
        options.addOption(Settings.HTML, false, "output in html format (default)");
        options.addOption(Settings.HTMLFILE, true, "specify the output html file (default: cflint-results.html)");
        options.addOption(Settings.HTMLSTYLE, true, "default,plain"); // fancy,fancy-hist,summary
        options.addOption(Settings.JSON, false, "output in json format");
        options.addOption(Settings.JSONFILE, true, "specify the output json file (default: cflint-results.json)");
        options.addOption(Settings.TEXT, false, "output in plain text");
        options.addOption(Settings.TEXTFILE, true, "specify the output text file (default: cflint-results.txt)");
        options.addOption(Settings.EXTENSIONS, true, "specify the extensions of the CF source files (default: .cfm,.cfc)");
        options.addOption(Settings.CONFIGFILE, true, "specify the location of the config file");
        options.addOption(Settings.STDIN, true, "use stdin for file input (default: source.cfc)");
        options.addOption(Settings.STDOUT, false, "output to stdout only");
        options.addOption(Settings.LIST_RULE_GROUPS, false, "list rule groups");
        options.addOption(Settings.RULE_GROUPS, true, "rule groups");

        final CommandLineParser parser = new GnuParser();
        final CommandLine cmd = parser.parse(options, args);
        final CFLintMain main = new CFLintMain();

        if (cmd.hasOption(Settings.H) || cmd.hasOption(Settings.HELP) || cmd.hasOption(Settings.QUESTION_MARK)) {
            final HelpFormatter formatter = new HelpFormatter();
            formatter.printHelp(CFLINT, options);
            return;
        }
        if (cmd.hasOption(Settings.VERSION)) {
            System.out.println("CFLint " + Version.getVersion());
            System.out.println("CFParser " + cfml.parsing.Version.getVersion());
            return;
        }
        main.strictInclude = cmd.hasOption(Settings.STRICT_INCLUDE);
        if (cmd.hasOption(Settings.RULES) || cmd.hasOption(Settings.CONFIG)) {
            final CFLintPluginInfo pluginInfo = cmd.hasOption(Settings.RULES) ? ConfigUtils.loadDefaultPluginInfo()
                    : new CFLintPluginInfo();
{'fraction_non_alphanumeric': 0.1053687907676869, 'fraction_numerical': 0.0, 'mean_word_length': 4.004304160688665, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 22}, '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': '2881339', 'n_tokens_mistral': 4020, 'n_tokens_neox': 3980, 'n_words': 987}