       @rubocopOutput({"stderr": "#{output}"})
 
     which command, (err) =>
-      if (err)
-        @rubocopNotFoundError()
-      else
-        new BufferedProcess({command, args, stdout, stderr})
+      return @rubocopNotFoundError() if (err)
+      new BufferedProcess({command, args, stdout, stderr})
 
   rubocopNotFoundError: ->
     atom.notifications.addError(

      .concat(@rubocopConfigPath(buffer.getPath()))

    which command, (err) =>
      if (err)
        @rubocopNotFoundError()
      else
        rubocop = spawnSync(command, args, { encoding: 'utf-8', timeout: 5000 })
        if (rubocop.stderr)
          @rubocopOutput({"stderr": "#{rubocop.stderr}"})
        else
          buffer.setTextViaDiff(fs.readFileSync(tempFilePath, 'utf-8'))
          @rubocopOutput(JSON.parse(rubocop.stdout))

  autoCorrectFile: (editor)  ->
    filePath = editor.getPath()

    atom.notifications.addSuccess(@toggleMessage("Debug Mode", !setting))

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

  rubocopConfigPath: (filePath) ->
    configFile = '/.rubocop.yml'
    [projectPath, relativePath] = atom.project.relativizePath(filePath)
    projectConfigPath = projectPath + configFile
    homeConfigPath = fs.getHomeDirectory() + configFile
    return ['--config', projectConfigPath] if (fs.existsSync(projectConfigPath))
    retrun ['--config', homeConfigPath] if (fs.existsSync(homeConfigPath))
    []

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