<commit_before>var _ = require('lodash');
var getObject = require('getobject');

var sub = require('string-sub');

var re = function(rules) {
	var rulesets = {};

	_.assign(rulesets, rules);

	this.rules = rulesets;
};

re.prototype = {
	getValue: getObject.get,

	getMessage: function(lineNum, item, result, rule, context) {
		var warning;

		var message = rule.message || this.message;

		if (rule.message === false) {
			message = false;
		}

		if (_.isString(message)) {
			warning = this.message(message, lineNum, item, result, rule, context);
		}
		else if (_.isFunction(message)) {
			warning = message.call(this, lineNum, item, result, rule, context);
		}

		return warning;
	},

	isValidRule: function(ruleName, rule, context) {
		return (ruleName !== 'IGNORE' && ruleName.indexOf('_') !== 0) &&
				(rule.ignore !== 'node' || !context.hasSheBang);
	},

	isValidRuleSet: function(rules, fullItem, context) {
		var validRuleSet = false;

		if (_.isObject(rules)) {
			var ignore = rules.IGNORE;
			var customIgnore = context.customIgnore;

			validRuleSet = (!ignore || (ignore && !ignore.test(fullItem))) &&
					(!customIgnore || (customIgnore && !customIgnore.test(fullItem)));
		}

		return validRuleSet;
	},

	iterateRules: function(rules, context) {
		var instance = this;

		if (_.isString(rules)) {
			rules = instance.getValue(instance.rules, rules);
		}

		var fullItem = context.fullItem;
		var item = context.item;
		var lineNum = context.lineNum;
		var logger = context.logger;

		if (instance.isValidRuleSet(rules, fullItem, context)) {
			_.forEach(
				rules,
				function(rule, ruleName) {
					if (instance.isValidRule(ruleName, rule, context)) {
						var result = instance.testLine(rule, context);

						if (result) {
							var warning = instance.getMessage(lineNum, item, result, rule, context);
<commit_msg>Removing fullItem from isValidRuleSet arguments since it's already inside of the context<commit_after>var _ = require('lodash');
var getObject = require('getobject');

var sub = require('string-sub');

var re = function(rules) {
	var rulesets = {};

	_.assign(rulesets, rules);

	this.rules = rulesets;
};

re.prototype = {
	getValue: getObject.get,

	getMessage: function(lineNum, item, result, rule, context) {
		var warning;

		var message = rule.message || this.message;

		if (rule.message === false) {
			message = false;
		}

		if (_.isString(message)) {
			warning = this.message(message, lineNum, item, result, rule, context);
		}
		else if (_.isFunction(message)) {
			warning = message.call(this, lineNum, item, result, rule, context);
		}

		return warning;
	},

	isValidRule: function(ruleName, rule, context) {
		return (ruleName !== 'IGNORE' && ruleName.indexOf('_') !== 0) &&
				(rule.ignore !== 'node' || !context.hasSheBang);
	},

	isValidRuleSet: function(rules, context) {
		var validRuleSet = false;

		if (_.isObject(rules)) {
			var ignore = rules.IGNORE;
			var customIgnore = context.customIgnore;
			var fullItem = context.fullItem;

			validRuleSet = (!ignore || (ignore && !ignore.test(fullItem))) &&
					(!customIgnore || (customIgnore && !customIgnore.test(fullItem)));
		}

		return validRuleSet;
	},

	iterateRules: function(rules, context) {
		var instance = this;

		if (_.isString(rules)) {
			rules = instance.getValue(instance.rules, rules);
		}

		var fullItem = context.fullItem;
		var item = context.item;
		var lineNum = context.lineNum;
		var logger = context.logger;

		if (instance.isValidRuleSet(rules, context)) {
			_.forEach(
				rules,
				function(rule, ruleName) {
					if (instance.isValidRule(ruleName, rule, context)) {
						var result = instance.testLine(rule, context);

						if (result) {
							var warning = instance.getMessage(lineNum, item, result, rule, context);

{'fraction_non_alphanumeric': 0.14698859113823295, 'fraction_numerical': 0.0005306447333510214, 'mean_word_length': 3.896103896103896, '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': '7269569', 'n_tokens_mistral': 1370, 'n_tokens_neox': 1194, 'n_words': 296}