<commit_before>/*eslint no-console: ["error", {allow: ["log"]}] */

var validate  = require('./index.js');
var colors    = require('colors/safe');
var cliff     = require('cliff');
var pluralize = require('pluralize');
var bytes     = require('bytes');
var fs        = require('fs');

module.exports = function (dir, options) {
    if (fs.existsSync(dir)) {
        validate.BIDS(dir, options, function (issues, summary) {
            var errors = issues.errors;
            var warnings = issues.warnings;
            if (issues.errors.length === 1 && issues.errors[0].code === '61') {
                console.log(colors.red("(ERR)  The directory " + dir + " failed an initial Quick Test. This means the basic names and structure of the files and directories do not comply with BIDS specification. For more info go to http://bids.neuroimaging.io/"));
            } else if (issues.config && issues.config.length >= 1) {
                console.log(colors.red('(ERR)  Invalid Config File'));
                for (var i = 0; i < issues.config.length; i++) {
                    var issue = issues.config[i];
                    issue.file.file = {relativePath: issue.file.path};
                    issue.files = [issue.file];
                }
                logIssues(issues.config, 'red', options);
            } else if (errors.length >= 1 || warnings.length >= 1) {
                logIssues(errors, 'red', options);
                logIssues(warnings, 'yellow', options);
            }
            else {
                console.log(colors.green("This dataset appears to be BIDS compatible."));
            }
            logSummary(summary);
            if (issues === 'Invalid' || errors && errors.length >= 1 || issues.config && issues.config.length >= 1) {process.exit(1);}
        });
    } else {
        console.log(colors.red(dir + " does not exist"));
        process.exit(2);
    }
};

function logIssues (issues, color, options) {
    for (var i = 0; i < issues.length; i++) {
        var issue = issues[i];
        var type = (color==red ? 'ERR': 'WARN');
        console.log('\t' + colors[color]((i + 1) + ': (' + type + ') ' issue.reason + ' (code: ' + issue.code + ' - ' + issue.key + ')'));
        for (var j = 0; j < issue.files.length; j++) {
            var file = issues[i].files[j];
            if (!file || !file.file) {continue;}
            console.log('\t\t.' + file.file.relativePath);
            if (options.verbose) {console.log('\t\t\t' + file.reason);}<commit_msg>Add fix to the ERR and WARN distinguish<commit_after>/*eslint no-console: ["error", {allow: ["log"]}] */

var validate  = require('./index.js');
var colors    = require('colors/safe');
var cliff     = require('cliff');
var pluralize = require('pluralize');
var bytes     = require('bytes');
var fs        = require('fs');

module.exports = function (dir, options) {
    if (fs.existsSync(dir)) {
        validate.BIDS(dir, options, function (issues, summary) {
            var errors = issues.errors;
            var warnings = issues.warnings;
            if (issues.errors.length === 1 && issues.errors[0].code === '61') {
                console.log(colors.red("(ERR)  The directory " + dir + " failed an initial Quick Test. This means the basic names and structure of the files and directories do not comply with BIDS specification. For more info go to http://bids.neuroimaging.io/"));
            } else if (issues.config && issues.config.length >= 1) {
                console.log(colors.red('(ERR)  Invalid Config File'));
                for (var i = 0; i < issues.config.length; i++) {
                    var issue = issues.config[i];
                    issue.file.file = {relativePath: issue.file.path};
                    issue.files = [issue.file];
                }
                logIssues(issues.config, 'red', options);
            } else if (errors.length >= 1 || warnings.length >= 1) {
                logIssues(errors, 'red', options);
                logIssues(warnings, 'yellow', options);
            }
            else {
                console.log(colors.green("This dataset appears to be BIDS compatible."));
            }
            logSummary(summary);
            if (issues === 'Invalid' || errors && errors.length >= 1 || issues.config && issues.config.length >= 1) {process.exit(1);}
        });
    } else {
        console.log(colors.red(dir + " does not exist"));
        process.exit(2);
    }
};

function logIssues (issues, color, options) {
    for (var i = 0; i < issues.length; i++) {
        var issue = issues[i];
        var type = (color==red ? 'ERR': 'WARN');
        console.log('\t' + colors[color]((i + 1) + ': (' + type + ') ' + issue.reason + ' (code: ' + issue.code + ' - ' + issue.key + ')'));
        for (var j = 0; j < issue.files.length; j++) {
            var file = issues[i].files[j];
            if (!file || !file.file) {continue;}
            console.log('\t\t.' + file.file.relativePath);
            if (options.verbose) {console.log('\t\t\t' + file.reason);}
{'fraction_non_alphanumeric': 0.16481113320079524, 'fraction_numerical': 0.005964214711729622, 'mean_word_length': 2.077064220183486, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, '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': '4116208', 'n_tokens_mistral': 1484, 'n_tokens_neox': 1431, 'n_words': 386}