<commit_before>exports = module.exports = plugin;

exports.default_word = "require";

exports.default_deps = function (opts) {
  opts = opts || {};

  var deps = {
    strings: [],
    expressions: [],
  };

  if (opts.nodes) deps.nodes = [];

  return deps;
};

function plugin () {
  var visitor = {
    CallExpression: function (path, state) {
      var
        node = path.node,
        opts = state.opts
      ;

      if (path.scope.hasBinding(opts.word, true)) {
        path.stop();
        return;
      }

      if (! opts.isRequire(node)) {
        return;
      }

      if (node.arguments.length) {
        if (node.arguments[0].type === "StringLiteral") {
          opts.dep("strings", node.arguments[0].value);
        }
        else {
          opts.dep("expressions", path.get("arguments.0").getSource())
        }
      }
      if (opts.nodes) opts.dep("nodes", node);
    },
    // CallExpression
  };

  return {
    pre: function () {
      opts = this.opts;

      if (! opts.word) opts.word = exports.default_word;

      if (! opts.isRequire) opts.isRequire = function (node) {
        return node.callee.type === "Identifier" && node.callee.name === opts.word;
      };
    },
    manipulateOptions: function (opts, parserOpts, file) {
      parserOpts.allowReturnOutsideFunction = true;
    },
    visitor: visitor,
  };
};
// plugin
<commit_msg>Refactor for compactness.<commit_after>exports = module.exports = plugin;

exports.default_word = "require";

exports.default_deps = function (opts) {
  opts = opts || {};

  var deps = {
    strings: [],
    expressions: [],
  };

  if (opts.nodes) deps.nodes = [];

  return deps;
};

function plugin () {
  var visitor = {
    CallExpression: function (path, state) {
      var
        node = path.node,
        opts = state.opts,
        args
      ;

      if (path.scope.hasBinding(opts.word, true)) {
        path.stop();
        return;
      }

      if (! opts.isRequire(node)) {
        return;
      }

      args = node.arguments;
      if (args.length) {
        if (args[0].type === "StringLiteral") {
          opts.dep("strings", args[0].value);
        }
        else {
          opts.dep("expressions", path.get("arguments.0").getSource())
        }
      }
      if (opts.nodes) opts.dep("nodes", node);
    },
    // CallExpression
  };

  return {
    pre: function () {
      opts = this.opts;

      if (! opts.word) opts.word = exports.default_word;

      if (! opts.isRequire) opts.isRequire = function (node) {
        return node.callee.type === "Identifier" && node.callee.name === opts.word;
      };
    },
    manipulateOptions: function (opts, parserOpts, file) {
      parserOpts.allowReturnOutsideFunction = true;
    },
    visitor: visitor,
  };
};
// plugin

{'fraction_non_alphanumeric': 0.1545684362585771, 'fraction_numerical': 0.0021668472372697724, 'mean_word_length': 2.091517857142857, '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': '3460190', 'n_tokens_mistral': 875, 'n_tokens_neox': 864, 'n_words': 173}