<commit_before>if !exists("g:go_metalinter_command")
  let g:go_metalinter_command = ""
endif

if !exists("g:go_metalinter_autosave_enabled")
  let g:go_metalinter_autosave_enabled = ['vet', 'golint']
endif

if !exists("g:go_metalinter_enabled")
  let g:go_metalinter_enabled = ['vet', 'golint', 'errcheck']
endif

if !exists("g:go_metalinter_deadline")
  let g:go_metalinter_deadline = "5s"
endif

if !exists("g:go_golint_bin")
  let g:go_golint_bin = "golint"
endif

if !exists("g:go_errcheck_bin")
  let g:go_errcheck_bin = "errcheck"
endif

function! go#lint#Gometa(autosave, ...) abort
  if a:0 == 0
    let goargs = shellescape(expand('%:p:h'))
  else
    let goargs = go#util#Shelljoin(a:000)
  endif

  let bin_path = go#path#CheckBinPath("gometalinter")
  if empty(bin_path)
    return
  endif

  let cmd = [bin_path]
  let cmd += ["--disable-all"]

  if a:autosave || empty(g:go_metalinter_command)
    " linters
    let linters = a:autosave ? g:go_metalinter_autosave_enabled : g:go_metalinter_enabled
    for linter in linters
      let cmd += ["--enable=".linter]
    endfor

    " path
    let cmd += [expand('%:p:h')]
  else
    " the user wants something else, let us use it.
    let cmd += [split(g:go_metalinter_command, " ")]
  endif

  if go#util#has_job() && has('lambda')
    call s:lint_job({'cmd': cmd})
    return
  endif

  " we add deadline only for sync mode
  let cmd += ["--deadline=" . g:go_metalinter_deadline]
  if a:autosave
    " include only messages for the active buffer
    let cmd += ["--include='^" . expand('%:p') . ".*$'"]
  endif


  let meta_command = join(cmd, " ")

  let out = go#tool#ExecuteInDir(meta_command)

  let l:listtype = "quickfix"
  if go#util#ShellError() == 0
    redraw | echo
    call go#list#Clean(l:listtype)
    call go#list#Window(l:listtype)
    echon "vim-go: " | echohl Function | echon "[metalinter] PASS" | echohl None<commit_msg>go_metalinter_deadline applies in async mode now<commit_after>if !exists("g:go_metalinter_command")
  let g:go_metalinter_command = ""
endif

if !exists("g:go_metalinter_autosave_enabled")
  let g:go_metalinter_autosave_enabled = ['vet', 'golint']
endif

if !exists("g:go_metalinter_enabled")
  let g:go_metalinter_enabled = ['vet', 'golint', 'errcheck']
endif

if !exists("g:go_golint_bin")
  let g:go_golint_bin = "golint"
endif

if !exists("g:go_errcheck_bin")
  let g:go_errcheck_bin = "errcheck"
endif

function! go#lint#Gometa(autosave, ...) abort
  if a:0 == 0
    let goargs = shellescape(expand('%:p:h'))
  else
    let goargs = go#util#Shelljoin(a:000)
  endif

  let bin_path = go#path#CheckBinPath("gometalinter")
  if empty(bin_path)
    return
  endif

  let cmd = [bin_path]
  let cmd += ["--disable-all"]

  if a:autosave || empty(g:go_metalinter_command)
    " linters
    let linters = a:autosave ? g:go_metalinter_autosave_enabled : g:go_metalinter_enabled
    for linter in linters
      let cmd += ["--enable=".linter]
    endfor

    " path
    let cmd += [expand('%:p:h')]
  else
    " the user wants something else, let us use it.
    let cmd += [split(g:go_metalinter_command, " ")]
  endif

  " gometalinter has a default deadline of 5 seconds.
  "
  " For async mode (s:lint_job), we want to override the default deadline only
  " if we have a deadline configured.
  "
  " For sync mode (go#tool#ExecuteInDir), always explicitly pass the 5 seconds
  " deadline if there is no other deadline configured. If a deadline is
  " configured, then use it.

  " Call gometalinter asynchronously.
  if go#util#has_job() && has('lambda')
    let deadline = get(g:, 'go_metalinter_deadline', 0)
    if deadline != 0
      let cmd += ["--deadline=" . deadline]
    endif

    call s:lint_job({'cmd': cmd})
    return
  endif

  " We're calling gometalinter synchronously.

  let cmd += ["--deadline=" . get(g:, 'go_metalinter_deadline', "5s")]

  if a:autosave
    " include only messages for the active buffer
    let cmd += ["--include='^" . expand('%:p') . ".*$'"]
  endif


  let meta_command = join(cmd, " ")

  let out = go#tool#ExecuteInDir(meta_command)

  let l:listtype = "quickfix"
  if go#util#ShellError() == 0
    redraw | echo
    call go#list#Clean(l:listtype)
    call go#list#Window(l:listtype)
    echon "vim-go: " | echohl Function | echon "[metalinter] PASS" | echohl None
{'fraction_non_alphanumeric': 0.1368591974019949, 'fraction_numerical': 0.0041753653444676405, 'mean_word_length': 3.916761687571266, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3472321', 'n_tokens_mistral': 1665, 'n_tokens_neox': 1563, 'n_words': 385}