Complain about stray echo lines in the codebase

This commit is contained in:
w0rp 2017-11-15 12:00:08 +00:00
parent 38bc489604
commit e12e5c912c
7 changed files with 44 additions and 38 deletions

View File

@ -18,7 +18,7 @@ function! s:EchoWithShortMess(setting, message) abort
elseif a:setting is# 'off'
setlocal shortmess-=T
" Regular echo is needed for printing newline characters.
echo a:message
execute 'echo a:message'
else
throw 'Invalid setting: ' . string(a:setting)
endif
@ -78,7 +78,7 @@ function! s:EchoImpl() abort
elseif get(l:info, 'echoed')
" We'll only clear the echoed message when moving off errors once,
" so we don't continually clear the echo line.
echo
execute 'echo'
let l:info.echoed = 0
endif
endfunction
@ -126,6 +126,6 @@ function! ale#cursor#ShowCursorDetail() abort
let l:message = get(l:loc, 'detail', l:loc.text)
call ale#preview#Show(split(l:message, "\n"))
echo
execute 'echo'
endif
endfunction

View File

@ -29,6 +29,10 @@ let s:global_variable_list = [
\ 'ale_warn_about_trailing_whitespace',
\]
function! s:Echo(message) abort
execute 'echo a:message'
endfunction
function! s:GetLinterVariables(filetype, linter_names) abort
let l:variable_list = []
let l:filetype_parts = split(a:filetype, '\.')
@ -52,20 +56,20 @@ endfunction
function! s:EchoLinterVariables(variable_list) abort
for l:key in a:variable_list
echom 'let g:' . l:key . ' = ' . string(g:[l:key])
call s:Echo('let g:' . l:key . ' = ' . string(g:[l:key]))
if has_key(b:, l:key)
echom 'let b:' . l:key . ' = ' . string(b:[l:key])
call s:Echo('let b:' . l:key . ' = ' . string(b:[l:key]))
endif
endfor
endfunction
function! s:EchoGlobalVariables() abort
for l:key in s:global_variable_list
echom 'let g:' . l:key . ' = ' . string(get(g:, l:key, v:null))
call s:Echo('let g:' . l:key . ' = ' . string(get(g:, l:key, v:null)))
if has_key(b:, l:key)
echom 'let b:' . l:key . ' = ' . string(b:[l:key])
call s:Echo('let b:' . l:key . ' = ' . string(b:[l:key]))
endif
endfor
endfunction
@ -79,34 +83,34 @@ function! s:EchoCommand(item) abort
let l:status_message .= ' - exit code ' . a:item.exit_code
endif
echom '(' . l:status_message . ') ' . string(a:item.command)
call s:Echo('(' . l:status_message . ') ' . string(a:item.command))
if g:ale_history_log_output && has_key(a:item, 'output')
if empty(a:item.output)
echom ''
echom '<<<NO OUTPUT RETURNED>>>'
echom ''
call s:Echo('')
call s:Echo('<<<NO OUTPUT RETURNED>>>')
call s:Echo('')
else
echom ''
echom '<<<OUTPUT STARTS>>>'
call s:Echo('')
call s:Echo('<<<OUTPUT STARTS>>>')
for l:line in a:item.output
echom l:line
call s:Echo(l:line)
endfor
echom '<<<OUTPUT ENDS>>>'
echom ''
call s:Echo('<<<OUTPUT ENDS>>>')
call s:Echo('')
endif
endif
endfunction
" Echo the results of an executable check.
function! s:EchoExecutable(item) abort
echom printf(
call s:Echo(printf(
\ '(executable check - %s) %s',
\ a:item.status ? 'success' : 'failure',
\ a:item.command,
\)
\))
endfunction
function! s:EchoCommandHistory() abort
@ -127,12 +131,12 @@ function! s:EchoLinterAliases(all_linters) abort
for l:linter in a:all_linters
if !empty(l:linter.aliases)
if l:first
echom ' Linter Aliases:'
call s:Echo(' Linter Aliases:')
endif
let l:first = 0
echom string(l:linter.name) . ' -> ' . string(l:linter.aliases)
call s:Echo(string(l:linter.name) . ' -> ' . string(l:linter.aliases))
endif
endfor
endfunction
@ -159,18 +163,18 @@ function! ale#debugging#Info() abort
" This must be done after linters are loaded.
let l:variable_list = s:GetLinterVariables(l:filetype, l:enabled_names)
echom ' Current Filetype: ' . l:filetype
echom 'Available Linters: ' . string(l:all_names)
call s:Echo(' Current Filetype: ' . l:filetype)
call s:Echo('Available Linters: ' . string(l:all_names))
call s:EchoLinterAliases(l:all_linters)
echom ' Enabled Linters: ' . string(l:enabled_names)
echom ' Linter Variables:'
echom ''
call s:Echo(' Enabled Linters: ' . string(l:enabled_names))
call s:Echo(' Linter Variables:')
call s:Echo('')
call s:EchoLinterVariables(l:variable_list)
echom ' Global Variables:'
echom ''
call s:Echo(' Global Variables:')
call s:Echo('')
call s:EchoGlobalVariables()
echom ' Command History:'
echom ''
call s:Echo(' Command History:')
call s:Echo('')
call s:EchoCommandHistory()
endfunction
@ -179,5 +183,5 @@ function! ale#debugging#InfoToClipboard() abort
silent call ale#debugging#Info()
redir END
echom 'ALEInfo copied to your clipboard'
call s:Echo('ALEInfo copied to your clipboard')
endfunction

View File

@ -251,10 +251,10 @@ function! s:HandleTSServerDiagnostics(response, error_type) abort
endfunction
function! s:HandleLSPErrorMessage(error_message) abort
echoerr 'Error from LSP:'
execute 'echoerr ''Error from LSP:'''
for l:line in split(a:error_message, "\n")
echoerr l:line
execute 'echoerr l:line'
endfor
endfunction

View File

@ -75,7 +75,7 @@ function! ale#fix#ApplyFixes(buffer, output) abort
if l:data.lines_before != l:lines
call remove(g:ale_fix_buffer_data, a:buffer)
echoerr 'The file was changed before fixing finished'
execute 'echoerr ''The file was changed before fixing finished'''
return
endif
endif
@ -406,17 +406,18 @@ function! ale#fix#Fix(...) abort
let l:callback_list = s:GetCallbacks()
catch /E700/
let l:function_name = join(split(split(v:exception, ':')[3]))
echom printf(
let l:echo_message = printf(
\ 'There is no fixer named `%s`. Check :ALEFixSuggest',
\ l:function_name,
\)
execute 'echom l:echo_message'
return 0
endtry
if empty(l:callback_list)
if l:fixing_flag is# ''
echom 'No fixers have been defined. Try :ALEFixSuggest'
execute 'echom ''No fixers have been defined. Try :ALEFixSuggest'''
endif
return 0

View File

@ -158,7 +158,7 @@ function! ale#toggle#ToggleBuffer(buffer) abort
" Disabling ALE globally removes autocmd events, so we cannot enable
" linting locally when linting is disabled globally
if l:enabled && !g:ale_enabled
echom 'ALE cannot be enabled locally when disabled globally'
execute 'echom ''ALE cannot be enabled locally when disabled globally'''
return
endif

View File

@ -24,8 +24,8 @@ endif
if !s:has_features
" Only output a warning if editing some special files.
if index(['', 'gitcommit'], &filetype) == -1
echoerr 'ALE requires NeoVim >= 0.1.5 or Vim 8 with +timers +job +channel'
echoerr 'Please update your editor appropriately.'
execute 'echoerr ''ALE requires NeoVim >= 0.1.5 or Vim 8 with +timers +job +channel'''
execute 'echoerr ''Please update your editor appropriately.'''
endif
" Stop here, as it won't work.

View File

@ -90,5 +90,6 @@ check_errors '==#' "Use 'is#' instead of '==#'. 0 ==# 'foobar' is true"
check_errors '==?' "Use 'is?' instead of '==?'. 0 ==? 'foobar' is true"
check_errors '!=#' "Use 'isnot#' instead of '!=#'. 0 !=# 'foobar' is false"
check_errors '!=?' "Use 'isnot?' instead of '!=?'. 0 !=? 'foobar' is false"
check_errors '^ *:\?echo' "Stray echo line. Use \`execute echo\` if you want to echo something"
exit $RETURN_CODE