<commit_before>path = require 'path'
{XRegExp} = require 'xregexp'
helpers = require 'atom-linter'

class LinterPurescript
  lintProcess: null

  lint: (textEditor) ->
    mkResult = (match) ->
      lineEnd = match.lineEnd || match.lineStart
      colEnd = match.colEnd || match.colStart
      return {
        type: match.type || "Error",
        text: match.message,
        filePath: match.file,
        range: [[match.lineStart-1, match.colStart-1], [lineEnd-1, colEnd-1]]
      }

    return new Promise (resolve, reject) =>
      command = "/usr/local/bin/pulp"
      args = ["build"]

      filePath = textEditor.getPath()
      dirs = (dir for dir in atom.project.rootDirectories when dir.contains(filePath))
      projDir = if dirs.length == 1 then dirs[0].path else filePath.replace(/src\/.*/, "")

      options = { cwd: projDir, stream: "stderr" }

      console.log "linter-purescript: Running lint"
      helpers.execNode(command, args, options)
        .then (result) ->
          regex = '^[^\n]*(?<type>Error|Warning) at (?<file>[^\n]*) line (?<lineStart>[0-9]+), column (?<colStart>[0-9]+) - line (?<lineEnd>[0-9]+), column (?<colEnd>[0-9]+):(?<message>.*?)^[^\n]*See'

          matches = []
          XRegExp.forEach result, XRegExp(regex, "sm"), (match) ->
            matches.push(mkResult(match))

          parseRegex = 'Unable to parse module:\n[^"]*"(?<file>[^"]+)" \\(line (?<lineStart>[0-9]+), column (?<colStart>[0-9]+)\\):(?<message>.*?)^[^\n]*See'
          XRegExp.forEach result, XRegExp(parseRegex, "sm"), (match) ->
            matches.push(mkResult(match))

          console.log("Error count: " + matches.length)
          console.log(JSON.stringify(matches))

          resolve(matches)
        .then null, (err) ->
          reject(err)


module.exports = LinterPurescript<commit_msg>Make pull call more proper<commit_after>path = require 'path'
{XRegExp} = require 'xregexp'
helpers = require 'atom-linter'

class LinterPurescript
  lintProcess: null

  lint: (textEditor) ->
    mkResult = (match) ->
      lineEnd = match.lineEnd || match.lineStart
      colEnd = match.colEnd || match.colStart
      return {
        type: match.type || "Error",
        text: match.message,
        filePath: match.file,
        range: [[match.lineStart-1, match.colStart-1], [lineEnd-1, colEnd-1]]
      }

    return new Promise (resolve, reject) =>
      command = "pulp"
      args = ["build"]

      filePath = textEditor.getPath()
      dirs = (dir for dir in atom.project.rootDirectories when dir.contains(filePath))
      projDir = if dirs.length == 1 then dirs[0].path else filePath.replace(/src\/.*/, "")

      options = { cwd: projDir, stream: "stderr" }

      console.log "linter-purescript: Running lint"
      helpers.exec(command, args, options)
        .then (result) ->
          regex = '^[^\n]*(?<type>Error|Warning) at (?<file>[^\n]*) line (?<lineStart>[0-9]+), column (?<colStart>[0-9]+) - line (?<lineEnd>[0-9]+), column (?<colEnd>[0-9]+):(?<message>.*?)^[^\n]*See'

          matches = []
          XRegExp.forEach result, XRegExp(regex, "sm"), (match) ->
            matches.push(mkResult(match))

          parseRegex = 'Unable to parse module:\n[^"]*"(?<file>[^"]+)" \\(line (?<lineStart>[0-9]+), column (?<colStart>[0-9]+)\\):(?<message>.*?)^[^\n]*See'
          XRegExp.forEach result, XRegExp(parseRegex, "sm"), (match) ->
            matches.push(mkResult(match))

          console.log("Error count: " + matches.length)
          console.log(JSON.stringify(matches))

          resolve(matches)
        .then null, (err) ->
          reject(err)


module.exports = LinterPurescript
{'fraction_non_alphanumeric': 0.18671059857221306, 'fraction_numerical': 0.009884678747940691, 'mean_word_length': 2.767321613236815, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 39, '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': '788702', 'n_tokens_mistral': 1258, 'n_tokens_neox': 1205, 'n_words': 247}