Complain about stray echo lines in the codebase
This commit is contained in:
parent
38bc489604
commit
e12e5c912c
@ -18,7 +18,7 @@ function! s:EchoWithShortMess(setting, message) abort
|
|||||||
elseif a:setting is# 'off'
|
elseif a:setting is# 'off'
|
||||||
setlocal shortmess-=T
|
setlocal shortmess-=T
|
||||||
" Regular echo is needed for printing newline characters.
|
" Regular echo is needed for printing newline characters.
|
||||||
echo a:message
|
execute 'echo a:message'
|
||||||
else
|
else
|
||||||
throw 'Invalid setting: ' . string(a:setting)
|
throw 'Invalid setting: ' . string(a:setting)
|
||||||
endif
|
endif
|
||||||
@ -78,7 +78,7 @@ function! s:EchoImpl() abort
|
|||||||
elseif get(l:info, 'echoed')
|
elseif get(l:info, 'echoed')
|
||||||
" We'll only clear the echoed message when moving off errors once,
|
" We'll only clear the echoed message when moving off errors once,
|
||||||
" so we don't continually clear the echo line.
|
" so we don't continually clear the echo line.
|
||||||
echo
|
execute 'echo'
|
||||||
let l:info.echoed = 0
|
let l:info.echoed = 0
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
@ -126,6 +126,6 @@ function! ale#cursor#ShowCursorDetail() abort
|
|||||||
let l:message = get(l:loc, 'detail', l:loc.text)
|
let l:message = get(l:loc, 'detail', l:loc.text)
|
||||||
|
|
||||||
call ale#preview#Show(split(l:message, "\n"))
|
call ale#preview#Show(split(l:message, "\n"))
|
||||||
echo
|
execute 'echo'
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
@ -29,6 +29,10 @@ let s:global_variable_list = [
|
|||||||
\ 'ale_warn_about_trailing_whitespace',
|
\ 'ale_warn_about_trailing_whitespace',
|
||||||
\]
|
\]
|
||||||
|
|
||||||
|
function! s:Echo(message) abort
|
||||||
|
execute 'echo a:message'
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! s:GetLinterVariables(filetype, linter_names) abort
|
function! s:GetLinterVariables(filetype, linter_names) abort
|
||||||
let l:variable_list = []
|
let l:variable_list = []
|
||||||
let l:filetype_parts = split(a:filetype, '\.')
|
let l:filetype_parts = split(a:filetype, '\.')
|
||||||
@ -52,20 +56,20 @@ endfunction
|
|||||||
|
|
||||||
function! s:EchoLinterVariables(variable_list) abort
|
function! s:EchoLinterVariables(variable_list) abort
|
||||||
for l:key in a:variable_list
|
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)
|
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
|
endif
|
||||||
endfor
|
endfor
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:EchoGlobalVariables() abort
|
function! s:EchoGlobalVariables() abort
|
||||||
for l:key in s:global_variable_list
|
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)
|
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
|
endif
|
||||||
endfor
|
endfor
|
||||||
endfunction
|
endfunction
|
||||||
@ -79,34 +83,34 @@ function! s:EchoCommand(item) abort
|
|||||||
let l:status_message .= ' - exit code ' . a:item.exit_code
|
let l:status_message .= ' - exit code ' . a:item.exit_code
|
||||||
endif
|
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 g:ale_history_log_output && has_key(a:item, 'output')
|
||||||
if empty(a:item.output)
|
if empty(a:item.output)
|
||||||
echom ''
|
call s:Echo('')
|
||||||
echom '<<<NO OUTPUT RETURNED>>>'
|
call s:Echo('<<<NO OUTPUT RETURNED>>>')
|
||||||
echom ''
|
call s:Echo('')
|
||||||
else
|
else
|
||||||
echom ''
|
call s:Echo('')
|
||||||
echom '<<<OUTPUT STARTS>>>'
|
call s:Echo('<<<OUTPUT STARTS>>>')
|
||||||
|
|
||||||
for l:line in a:item.output
|
for l:line in a:item.output
|
||||||
echom l:line
|
call s:Echo(l:line)
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
echom '<<<OUTPUT ENDS>>>'
|
call s:Echo('<<<OUTPUT ENDS>>>')
|
||||||
echom ''
|
call s:Echo('')
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Echo the results of an executable check.
|
" Echo the results of an executable check.
|
||||||
function! s:EchoExecutable(item) abort
|
function! s:EchoExecutable(item) abort
|
||||||
echom printf(
|
call s:Echo(printf(
|
||||||
\ '(executable check - %s) %s',
|
\ '(executable check - %s) %s',
|
||||||
\ a:item.status ? 'success' : 'failure',
|
\ a:item.status ? 'success' : 'failure',
|
||||||
\ a:item.command,
|
\ a:item.command,
|
||||||
\)
|
\))
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:EchoCommandHistory() abort
|
function! s:EchoCommandHistory() abort
|
||||||
@ -127,12 +131,12 @@ function! s:EchoLinterAliases(all_linters) abort
|
|||||||
for l:linter in a:all_linters
|
for l:linter in a:all_linters
|
||||||
if !empty(l:linter.aliases)
|
if !empty(l:linter.aliases)
|
||||||
if l:first
|
if l:first
|
||||||
echom ' Linter Aliases:'
|
call s:Echo(' Linter Aliases:')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let l:first = 0
|
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
|
endif
|
||||||
endfor
|
endfor
|
||||||
endfunction
|
endfunction
|
||||||
@ -159,18 +163,18 @@ function! ale#debugging#Info() abort
|
|||||||
" This must be done after linters are loaded.
|
" This must be done after linters are loaded.
|
||||||
let l:variable_list = s:GetLinterVariables(l:filetype, l:enabled_names)
|
let l:variable_list = s:GetLinterVariables(l:filetype, l:enabled_names)
|
||||||
|
|
||||||
echom ' Current Filetype: ' . l:filetype
|
call s:Echo(' Current Filetype: ' . l:filetype)
|
||||||
echom 'Available Linters: ' . string(l:all_names)
|
call s:Echo('Available Linters: ' . string(l:all_names))
|
||||||
call s:EchoLinterAliases(l:all_linters)
|
call s:EchoLinterAliases(l:all_linters)
|
||||||
echom ' Enabled Linters: ' . string(l:enabled_names)
|
call s:Echo(' Enabled Linters: ' . string(l:enabled_names))
|
||||||
echom ' Linter Variables:'
|
call s:Echo(' Linter Variables:')
|
||||||
echom ''
|
call s:Echo('')
|
||||||
call s:EchoLinterVariables(l:variable_list)
|
call s:EchoLinterVariables(l:variable_list)
|
||||||
echom ' Global Variables:'
|
call s:Echo(' Global Variables:')
|
||||||
echom ''
|
call s:Echo('')
|
||||||
call s:EchoGlobalVariables()
|
call s:EchoGlobalVariables()
|
||||||
echom ' Command History:'
|
call s:Echo(' Command History:')
|
||||||
echom ''
|
call s:Echo('')
|
||||||
call s:EchoCommandHistory()
|
call s:EchoCommandHistory()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@ -179,5 +183,5 @@ function! ale#debugging#InfoToClipboard() abort
|
|||||||
silent call ale#debugging#Info()
|
silent call ale#debugging#Info()
|
||||||
redir END
|
redir END
|
||||||
|
|
||||||
echom 'ALEInfo copied to your clipboard'
|
call s:Echo('ALEInfo copied to your clipboard')
|
||||||
endfunction
|
endfunction
|
||||||
|
@ -251,10 +251,10 @@ function! s:HandleTSServerDiagnostics(response, error_type) abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:HandleLSPErrorMessage(error_message) abort
|
function! s:HandleLSPErrorMessage(error_message) abort
|
||||||
echoerr 'Error from LSP:'
|
execute 'echoerr ''Error from LSP:'''
|
||||||
|
|
||||||
for l:line in split(a:error_message, "\n")
|
for l:line in split(a:error_message, "\n")
|
||||||
echoerr l:line
|
execute 'echoerr l:line'
|
||||||
endfor
|
endfor
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ function! ale#fix#ApplyFixes(buffer, output) abort
|
|||||||
|
|
||||||
if l:data.lines_before != l:lines
|
if l:data.lines_before != l:lines
|
||||||
call remove(g:ale_fix_buffer_data, a:buffer)
|
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
|
return
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
@ -406,17 +406,18 @@ function! ale#fix#Fix(...) abort
|
|||||||
let l:callback_list = s:GetCallbacks()
|
let l:callback_list = s:GetCallbacks()
|
||||||
catch /E700/
|
catch /E700/
|
||||||
let l:function_name = join(split(split(v:exception, ':')[3]))
|
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',
|
\ 'There is no fixer named `%s`. Check :ALEFixSuggest',
|
||||||
\ l:function_name,
|
\ l:function_name,
|
||||||
\)
|
\)
|
||||||
|
execute 'echom l:echo_message'
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
endtry
|
endtry
|
||||||
|
|
||||||
if empty(l:callback_list)
|
if empty(l:callback_list)
|
||||||
if l:fixing_flag is# ''
|
if l:fixing_flag is# ''
|
||||||
echom 'No fixers have been defined. Try :ALEFixSuggest'
|
execute 'echom ''No fixers have been defined. Try :ALEFixSuggest'''
|
||||||
endif
|
endif
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
@ -158,7 +158,7 @@ function! ale#toggle#ToggleBuffer(buffer) abort
|
|||||||
" Disabling ALE globally removes autocmd events, so we cannot enable
|
" Disabling ALE globally removes autocmd events, so we cannot enable
|
||||||
" linting locally when linting is disabled globally
|
" linting locally when linting is disabled globally
|
||||||
if l:enabled && !g:ale_enabled
|
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
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -24,8 +24,8 @@ endif
|
|||||||
if !s:has_features
|
if !s:has_features
|
||||||
" Only output a warning if editing some special files.
|
" Only output a warning if editing some special files.
|
||||||
if index(['', 'gitcommit'], &filetype) == -1
|
if index(['', 'gitcommit'], &filetype) == -1
|
||||||
echoerr 'ALE requires NeoVim >= 0.1.5 or Vim 8 with +timers +job +channel'
|
execute 'echoerr ''ALE requires NeoVim >= 0.1.5 or Vim 8 with +timers +job +channel'''
|
||||||
echoerr 'Please update your editor appropriately.'
|
execute 'echoerr ''Please update your editor appropriately.'''
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" Stop here, as it won't work.
|
" Stop here, as it won't work.
|
||||||
|
@ -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 '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 '!=?' "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
|
exit $RETURN_CODE
|
||||||
|
Loading…
Reference in New Issue
Block a user