+path = require 'path'
 {Range, Point} = require 'atom'
 CommandRunner = require '../command-runner'
 Violation = require '../violation'
-path = require 'path'
 
-DIAGNOSTIC_PATTERN = ///
+ERROR_PATTERN = ///
 ^(.+):(\d+):  # file / line
 \s*([^]+) # message
 ///

    for line in lines
      continue unless line

      matches = line.match(DIAGNOSTIC_PATTERN)
      continue unless matches
      [_, filePath, lineNumber, message] = matches

      severity = "error"

      if message.startsWith("Warning: ")
        severity = "warning"

      bufferPoint = new Point(parseInt(lineNumber) - 1, 0)
      bufferRange = new Range(bufferPoint, bufferPoint)

    # Our build command works in the same way as erlang-flymake.el
    # see: https://github.com/erlang/otp/blob/maint/lib/tools/emacs/erlang-flymake.el
    command = []

    userErlcPath = atom.config.get('atom-lint.erlc.path')

    if userErlcPath?
      command.push(userErlcPath)
    else
      command.push('erlc')

    directoryPath = path.dirname(@filePath)

    if directoryPath.endsWith('/src')
      projectRoot = path.dirname(projectRoot)
      command.push('-I', path.join(projectRoot, 'include'))
      command.push('-I', path.join(projectRoot, 'deps'))
      command.push('-pa', path.join(projectRoot, 'ebin'))

    command.push('-Wall')
    command.push('+warn_obsolete_guard')
