<commit_before>/**
 * @fileoverview Counts `it`-body complexity
 * Rule based on "default" `complexity`-rule implementation
 * @author onechiporenko
 * @copyright 2015 onechiporenko. All rights reserved.
 */

"use strict";

var n = require("../utils/node.js");

//------------------------------------------------------------------------------
// Rule Definition
//------------------------------------------------------------------------------

module.exports = function (context) {

  var insideIt = false;
  var currentComplexityCount = 0;
  var maxAllowedComplexity = context.options.length ? context.options[0] : 20;
  var skipSkipped = context.options.length > 1 ? context.options[1] : false;
  var nodeSkipped;

  function increaseComplexity() {
    if (!insideIt) {
      return;
    }
    if (nodeSkipped) {
      return;
    }
    currentComplexityCount++;
  }

  return {
    "FunctionExpression": function (node) {
      if (n.isItBody(node)) {
        if (skipSkipped) {
          nodeSkipped = n.tryDetectSkipInParent(node);
        }
        insideIt = true;
      }
    },
    "FunctionExpression:exit": function (node) {
      if (n.isItBody(node)) {
        if (currentComplexityCount > maxAllowedComplexity) {
          context.report(node, "`it` has a complexity of {{num}}. Maximum allowed is {{max}}.", {
            max: maxAllowedComplexity,
            num: currentComplexityCount<commit_msg>Increase default maximum complexity to 40<commit_after>/**
 * @fileoverview Counts `it`-body complexity
 * Rule based on "default" `complexity`-rule implementation
 * @author onechiporenko
 * @copyright 2015 onechiporenko. All rights reserved.
 */

"use strict";

var n = require("../utils/node.js");

//------------------------------------------------------------------------------
// Rule Definition
//------------------------------------------------------------------------------

module.exports = function (context) {

  var insideIt = false;
  var currentComplexityCount = 0;
  var maxAllowedComplexity = context.options.length ? context.options[0] : 40;
  var skipSkipped = context.options.length > 1 ? context.options[1] : false;
  var nodeSkipped;

  function increaseComplexity() {
    if (!insideIt) {
      return;
    }
    if (nodeSkipped) {
      return;
    }
    currentComplexityCount++;
  }

  return {
    "FunctionExpression": function (node) {
      if (n.isItBody(node)) {
        if (skipSkipped) {
          nodeSkipped = n.tryDetectSkipInParent(node);
        }
        insideIt = true;
      }
    },
    "FunctionExpression:exit": function (node) {
      if (n.isItBody(node)) {
        if (currentComplexityCount > maxAllowedComplexity) {
          context.report(node, "`it` has a complexity of {{num}}. Maximum allowed is {{max}}.", {
            max: maxAllowedComplexity,
            num: currentComplexityCount
{'fraction_non_alphanumeric': 0.21973407977606718, 'fraction_numerical': 0.007697690692792162, 'mean_word_length': 1.941358024691358, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 7, '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': '6508898', 'n_tokens_mistral': 798, 'n_tokens_neox': 774, 'n_words': 188}