           ''' }
         )
 
-      rubocop = new BufferedProcess({command, args, stdout, stderr})
+    stdout = (output) =>
+      @rubocopOutput(filePath.replace(/.+\//, ""), output)
+    stderr = (output) =>
+      @rubocopOutput(filePath.replace(/.+\//, ""), output)
 
+    rubocop = new BufferedProcess({command, args, stdout, stderr})
+
+  rubocopOutput: (fileName, output) ->
+    debug = atom.config.get('rubocop-auto-correct.debugMode')
+    notification = atom.config.get('rubocop-auto-correct.notification')
+    console.log(output) if debug
+
+    if output.match("corrected")
+      re = /^.+?(:[0-9]+:[0-9]+:.*$)/mg
+      offenses = output.match(re)
+      offenses.map (offense) ->
+        message = offense.replace(re, fileName + "$1")
+        console.log(message) if debug
+        atom.notifications.addSuccess(message) if notification
+    else
+      atom.notifications.addError(output) if notification
 
   makeTempFile: (filename) ->
     directory = temp.mkdirSync()

    @subscriptions.add(bufferSavedSubscription)
    @subscriptions.add(editorDestroyedSubscription)

  toggleAutoRun: ->
    if atom.config.get('rubocop-auto-correct.autoRun')
      atom.config.set('rubocop-auto-correct.autoRun', false)
      atom.notifications.addSuccess("Turn OFF, Auto Run")
    else
      atom.config.set('rubocop-auto-correct.autoRun', true)
      atom.notifications.addSuccess("Turn ON, Auto Run")

  toggleNotification: ->
    if atom.config.get('rubocop-auto-correct.notification')
      atom.config.set('rubocop-auto-correct.notification', false)
      atom.notifications.addSuccess("Turn OFF, Notification")
    else
      atom.config.set('rubocop-auto-correct.notification', true)
      atom.notifications.addSuccess("Turn ON, Notification")

  toggleCorrectFile: ->
    if atom.config.get('rubocop-auto-correct.correctFile')
      atom.config.set('rubocop-auto-correct.correctFile', false)
      atom.notifications.addSuccess("Correct the buffer")
    else
      atom.config.set('rubocop-auto-correct.correctFile', true)
      atom.notifications.addSuccess("Correct the file")

  toggleDebugMode: ->
    if atom.config.get('rubocop-auto-correct.debugMode')
      atom.config.set('rubocop-auto-correct.debugMode', false)
      atom.notifications.addSuccess("Turn OFF, Debug Mode")
    else
      atom.config.set('rubocop-auto-correct.debugMode', true)
      atom.notifications.addSuccess("Turn ON, Debug Mode")

  run: (editor) ->
    unless editor.getGrammar().scopeName.match("ruby")
      return atom.notifications.addError("Only use source.ruby")
    if atom.config.get('rubocop-auto-correct.correctFile')
      if editor.isModified()
        editor.save()
      @autoCorrectFile(editor.getPath())
    else
      @autoCorrectBuffer(editor.getBuffer())

  projectRootRubocopConfig: (filePath) ->
    [projectPath, relativePath] = atom.project.relativizePath(filePath)
    rubocopConfigPath = projectPath+'/.rubocop.yml'
    if (fs.existsSync(rubocopConfigPath))
      ['--config', rubocopConfigPath]
    else
      []


          ''' }
        )

    rubocop = spawnSync(command, args, { encoding: 'utf-8', timeout: 5000 })

    if (rubocop.status != 0)
      @rubocopOutput(buffer.getBaseName(), rubocop.stderr)
    else
      buffer.setTextViaDiff(fs.readFileSync(tempFilePath, 'utf-8'))
      @rubocopOutput(buffer.getBaseName(), rubocop.stdout)

  autoCorrectFile: (filePath)  ->
    commandWithArgs = atom.config.get('rubocop-auto-correct.rubocopCommandPath')
