 fs = require 'fs'
 {$, $$, SelectListView} = require 'atom'
 
+# Basic flake8 parsing tool with callback functionality
 flake = (filePath, callback) ->
   line_expr = /:(\d+):(\d+): ([CEFW]\d{3}) (.*)/
   errors = []
   currentIndex = -1
-  skipLine = false
+  skip_line = false
 
   params = ["--show-source", filePath]
   ignoreErrors = atom.config.get "flake8.ignoreErrors"

        else
          message = error.message
        # console.log(message)
        error_list.push({message, error})

      @setItems(error_list)

    if @previouslyFocusedElement[0] and @previouslyFocusedElement[0] isnt document.body
      @eventElement = @previouslyFocusedElement
    else
      @eventElement = atom.workspaceView

  viewForItem: ({message, error}) ->
    console.log('Processing: ' + message)
    # data = '<li class="event"><div class="pull-right"></div><span title="error">' + message + '</span></li>'
    # console.log('Returning html: ' + data)
    # return data
    base_msg = error.type + ' - ' + error.message
    $$ ->
      @li class: 'event', 'data-event-name': error.type, =>
        @div class: 'pull-right', =>
            # Use the keybinding class to display line numbers
            @kbd "Line: " + error.line, class: 'key-binding'
        @span base_msg[0..65], title: message

  confirmed: ({eventName}) ->
    @cancel()
    @eventElement.trigger(eventName)

        "line": parseInt(line)
      }
      currentIndex += 1
      skip_line = false
    else
      if not skip_line
        errors[currentIndex].evidence = line.toString().trim()
        skip_line = true

  # Watch for the exit code
  proc.on 'exit', (exit_code, signal) ->
    if exit_code == 1 and errors.length == 0
      console.log('Flake8 may have crashed. Check flake8 bin path.')
    callback errors


module.exports =

class SimpleFlake8View extends SelectListView

