<commit_before>const quotes = [ "\"", "'" ]

/**
 * Find the index of a character within a declaration value.
 *
 * @param {object} options
 * @param {string} options.value - The value to look through
 * @param {string|string[]} options.char - The target of the search. Can be
 *   a single character, a string with some length, or an array of single-character
 *   targets, all of which count as a match
 * @param {boolean} [options.insideFunction] - If `true`, only will report
 *   `char` found inside a function
 * @param {boolean} [options.outsideFunction] - If `true`, only will report
 *   `char` found outside functions
 * @param {boolean} [onlyOne] - Stop looking after the first match is found
 * @param {function} callback - Function that takes the index of `char` or
 *   `undefined` if `char` is not found
 * @return {undefined}
 */
export default function (options, callback) {
  const { value, char, insideFunction, outsideFunction } = options
  let isInsideString = false
  let isInsideFunction = false
  let openingQuote
  let openingParenCount = 0
  let count = 0

  const targetIsArray = Array.isArray(char)
  const targetLength = char.length

  function matchesTarget(toBeChecked) {
    if (targetIsArray) {
      return char.indexOf(toBeChecked) !== -1
    }
    return toBeChecked === char
  }

  for (let i = 0, l = value.length; i < l; i++) {
    const currentChar = value[i]
    if (!isInsideString && quotes.indexOf(currentChar) !== -1) {
      if (value[i - 1] === "\\") { continue }
      openingQuote = currentChar
      isInsideString = true

      // For string-quotes rule
      if (charMatchesCharToFind(currentChar)) {
        matchFound(i)
      }
      continue
    }
    if (isInsideString && currentChar === openingQuote) {
      if (value[i - 1] === "\\") { continue }
      isInsideString = false
      continue
    }
    if (insideFunction || outsideFunction) {
      if (!isInsideString && currentChar === "(") {
        openingParenCount++
        isInsideFunction = true
        continue
      }
      if (!isInsideString && currentChar === ")") {
        openingParenCount--
        if (openingParenCount === 0) {
          isInsideFunction = false
        }
        continue
      }
      if (!isInsideString && /^[a-zA-Z]*\(/.test(value.slice(i))) {
        continue
      }
    }

    const toBeChecked = (!targetIsArray && targetLength > 1)
      ? value.substr(i, targetLength)
      : currentChar<commit_msg>Fix linting error<commit_after>const quotes = [ "\"", "'" ]

/**
 * Find the index of a character within a declaration value.
 *
 * @param {object} options
 * @param {string} options.value - The value to look through
 * @param {string|string[]} options.char - The target of the search. Can be
 *   a single character, a string with some length, or an array of single-character
 *   targets, all of which count as a match
 * @param {boolean} [options.insideFunction] - If `true`, only will report
 *   `char` found inside a function
 * @param {boolean} [options.outsideFunction] - If `true`, only will report
 *   `char` found outside functions
 * @param {boolean} [onlyOne] - Stop looking after the first match is found
 * @param {function} callback - Function that takes the index of `char` or
 *   `undefined` if `char` is not found
 * @return {undefined}
 */
export default function (options, callback) {
  const { value, char, insideFunction, outsideFunction } = options
  let isInsideString = false
  let isInsideFunction = false
  let openingQuote
  let openingParenCount = 0
  let count = 0

  const targetIsArray = Array.isArray(char)
  const targetLength = char.length

  function matchesTarget(toBeChecked) {
    if (targetIsArray) {
      return char.indexOf(toBeChecked) !== -1
    }
    return toBeChecked === char
  }

  for (let i = 0, l = value.length; i < l; i++) {
    const currentChar = value[i]
    if (!isInsideString && quotes.indexOf(currentChar) !== -1) {
      if (value[i - 1] === "\\") { continue }
      openingQuote = currentChar
      isInsideString = true

      // For string-quotes rule
      if (matchesTarget(currentChar)) {
        matchFound(i)
      }
      continue
    }
    if (isInsideString && currentChar === openingQuote) {
      if (value[i - 1] === "\\") { continue }
      isInsideString = false
      continue
    }
    if (insideFunction || outsideFunction) {
      if (!isInsideString && currentChar === "(") {
        openingParenCount++
        isInsideFunction = true
        continue
      }
      if (!isInsideString && currentChar === ")") {
        openingParenCount--
        if (openingParenCount === 0) {
          isInsideFunction = false
        }
        continue
      }
      if (!isInsideString && /^[a-zA-Z]*\(/.test(value.slice(i))) {
        continue
      }
    }

    const toBeChecked = (!targetIsArray && targetLength > 1)
      ? value.substr(i, targetLength)
      : currentChar
{'fraction_non_alphanumeric': 0.12128612128612129, 'fraction_numerical': 0.003663003663003663, 'mean_word_length': 2.726307808946171, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '4594169', 'n_tokens_mistral': 1465, 'n_tokens_neox': 1396, 'n_words': 449}