<commit_before>/*
 * grunt-diff-json
 * https://github.com/openknowl/grunt-diff-json
 *
 * Copyright (c) 2015 openknowl
 * Licensed under the MIT license.
 */

'use strict';

module.exports = function (grunt) {

	// Please see the Grunt documentation for more information regarding task
	// creation: http://gruntjs.com/creating-tasks

	grunt.registerMultiTask('diff_json', 'Grunt task that compares two json files.', function () {
		// Merge task-specific and/or target-specific options with these defaults.
		var options = this.options({
			punctuation: '.',
			separator: ', '
		});

		// Iterate over all specified file groups.
		this.files.forEach(function (f) {
			// Concat specified files.
			var src = f.src.filter(function (filepath) {
				// Warn on and remove invalid source files (if nonull was set).
				if (!grunt.file.exists(filepath)) {
					grunt.log.warn('Source file "' + filepath + '" not found.');
					return false;
				} else {
					return true;
				}
			}).map(function (filepath) {
				// Read file source.<commit_msg>paste good-old configTest<commit_after>/*
 * grunt-diff-json
 * https://github.com/openknowl/grunt-diff-json
 *
 * Copyright (c) 2015 openknowl
 * Licensed under the MIT license.
 */

'use strict';

var deepDiff = require('deep-diff');

var diffJson = function (dest, src) {
	var diff = deepDiff(src, dest);

	if (typeof diff !== 'undefined') {
		for (var i = 0; i < diff.length; i++) {
			var path = diff[i].path.join('.');
			switch (diff[i].kind) {
				case 'E':
					if (typeof diff[i].rhs !== typeof diff[i].lhs) {
						grunt.log.error('Wrong Type [' + path + ']');
						grunt.fail.warn('config test failed.');
					}

					else {
						grunt.log.writeln('[' + path + '] "' + diff[i].lhs + '" -> "' + diff[i].rhs + '"');
					}

					break;

				case 'N':
					grunt.log.error('Obsolete [' + path + ']');
					warn++;
					break;

				case 'D':
					grunt.log.error('Missing [' + path + '] (example value : "' + diff[i].lhs + '") Aborting.');
					grunt.fail.warn('config test failed.');
					break;
			}
		}
	}

	grunt.log.writeln('Config test succeeded with ' + warn + ' warning(s).');
	return true;
};

module.exports = function (grunt) {

	// Please see the Grunt documentation for more information regarding task
	// creation: http://gruntjs.com/creating-tasks

	grunt.registerMultiTask('diff_json', 'Grunt task that compares two json files.', function () {
		// Merge task-specific and/or target-specific options with these defaults.
		var options = this.options({
			punctuation: '.',
			separator: ', '
		});

		// Iterate over all specified file groups.
		this.files.forEach(function (f) {
			// Concat specified files.
			var src = f.src.filter(function (filepath) {
				// Warn on and remove invalid source files (if nonull was set).
				if (!grunt.file.exists(filepath)) {
					grunt.log.warn('Source file "' + filepath + '" not found.');
					return false;
				} else {
					return true;
				}
			}).map(function (filepath) {
				// Read file source.
{'fraction_non_alphanumeric': 0.15992037159920372, 'fraction_numerical': 0.0029860650298606504, 'mean_word_length': 2.860435339308579, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 2, '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': '722983', 'n_tokens_mistral': 1151, 'n_tokens_neox': 971, 'n_words': 262}