<commit_before>var gutil = require('gulp-util'),
    through = require('through2'),
    chalk = require('chalk');

/**
 * Returns "fail" reporter.
 *
 * The "fail" reporter rises an error on files stream if PHP Code Sniffer fails
 * for at least one file.
 *
 * @returns {Function}
 */
module.exports = function() {
    return through.obj(function(file, enc, callback) {
        var report = file.phpcsReport || {};

        if (report.error) {
            var errorMessage = 'PHP Code Sniffer failed' +
                ' on ' + chalk.magenta(file.path);

            this.emit('error', new gutil.PluginError('gulp-phpcs', errorMessage));
            callback();

            return;
        }

        this.push(file);
        callback();
    });
};<commit_msg>fix: fail reporter<commit_after>var gutil = require('gulp-util'),
    through = require('through2'),
    chalk = require('chalk');

/**
 * Returns "fail" reporter.
 *
 * The "fail" reporter rises an error on files stream if PHP Code Sniffer fails
 * for at least one file.
 *
 * @returns {Function}
 */
module.exports = function() {
    var phpcsError = false;

    return through.obj(
        // Watch for errors
        function(file, enc, callback) {
            var report = file.phpcsReport || {};

            if (report.error) {
                phpcsError = true;
            }

            this.push(file);
            callback();
        },

        // Abort if we had at leaste one error
        function(callback) {
            if (phpcsError) {
                this.emit('error', new gutil.PluginError('gulp-phpcs', 'PHP Code Sniffer failed at at leaste one file.'));
            }

            callback();
        });
};
{'fraction_non_alphanumeric': 0.13215339233038348, 'fraction_numerical': 0.0011799410029498525, 'mean_word_length': 2.0231729055258465, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4892613', 'n_tokens_mistral': 489, 'n_tokens_neox': 473, 'n_words': 137}