Ban use of ==# or ==? in the codebase, and prefer is# or is? instead

This commit is contained in:
w0rp 2017-08-08 08:39:13 +01:00
parent 5010ddc28f
commit a535d07f28
61 changed files with 158 additions and 154 deletions

View File

@ -21,8 +21,8 @@ function! ale_linters#ansible#ansible_lint#Handle(buffer, lines) abort
for l:match in ale#util#GetMatches(a:lines, l:pattern)
let l:code = l:match[4]
if (l:code ==# 'EANSIBLE002')
\ && !ale#Var(a:buffer, 'warn_about_trailing_whitespace')
if l:code is# 'EANSIBLE002'
\&& !ale#Var(a:buffer, 'warn_about_trailing_whitespace')
" Skip warnings for trailing whitespace if the option is off.
continue
endif
@ -32,7 +32,7 @@ function! ale_linters#ansible#ansible_lint#Handle(buffer, lines) abort
\ 'lnum': l:match[2] + 0,
\ 'col': l:match[3] + 0,
\ 'text': l:code . ': ' . l:match[5],
\ 'type': l:code[:0] ==# 'E' ? 'E' : 'W',
\ 'type': l:code[:0] is# 'E' ? 'E' : 'W',
\})
endif
endfor

View File

@ -27,7 +27,7 @@ function! ale_linters#coffee#coffeelint#Handle(buffer, lines) abort
for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:output, {
\ 'lnum': str2nr(l:match[1]),
\ 'type': l:match[3] ==# 'error' ? 'E' : 'W',
\ 'type': l:match[3] is# 'error' ? 'E' : 'W',
\ 'text': l:match[4],
\})
endfor

View File

@ -60,7 +60,7 @@ function! ale_linters#d#dmd#Handle(buffer, lines) abort
call add(l:output, {
\ 'lnum': l:match[1],
\ 'col': l:match[2],
\ 'type': l:match[3] ==# 'Warning' ? 'W' : 'E',
\ 'type': l:match[3] is# 'Warning' ? 'W' : 'E',
\ 'text': l:match[4],
\})
endfor

View File

@ -22,7 +22,7 @@ function! ale_linters#dart#dartanalyzer#Handle(buffer, lines) abort
for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:output, {
\ 'type': l:match[1] ==# 'error' ? 'E' : 'W',
\ 'type': l:match[1] is# 'error' ? 'E' : 'W',
\ 'text': l:match[6] . ': ' . l:match[2],
\ 'lnum': str2nr(l:match[4]),
\ 'col': str2nr(l:match[5]),

View File

@ -45,9 +45,9 @@ function! ale_linters#dockerfile#hadolint#GetExecutable(buffer) abort
let l:use_docker = ale#Var(a:buffer, 'dockerfile_hadolint_use_docker')
" check for mandatory directives
if l:use_docker ==# 'never'
if l:use_docker is# 'never'
return 'hadolint'
elseif l:use_docker ==# 'always'
elseif l:use_docker is# 'always'
return 'docker'
endif
@ -62,7 +62,7 @@ endfunction
function! ale_linters#dockerfile#hadolint#GetCommand(buffer) abort
let l:command = ale_linters#dockerfile#hadolint#GetExecutable(a:buffer)
if l:command ==# 'docker'
if l:command is# 'docker'
return 'docker run --rm -i ' . ale#Var(a:buffer, 'dockerfile_hadolint_docker_image')
endif
return 'hadolint -'

View File

@ -11,9 +11,9 @@ function! ale_linters#elixir#credo#Handle(buffer, lines) abort
let l:type = l:match[3]
let l:text = l:match[4]
if l:type ==# 'C'
if l:type is# 'C'
let l:type = 'E'
elseif l:type ==# 'R'
elseif l:type is# 'R'
let l:type = 'W'
endif

View File

@ -11,9 +11,9 @@ function! ale_linters#elixir#dogma#Handle(buffer, lines) abort
let l:type = l:match[3]
let l:text = l:match[4]
if l:type ==# 'C'
if l:type is# 'C'
let l:type = 'E'
elseif l:type ==# 'R'
elseif l:type is# 'R'
let l:type = 'W'
endif

View File

@ -7,16 +7,16 @@ function! ale_linters#elm#make#Handle(buffer, lines) abort
let l:temp_dir = l:is_windows ? $TMP : $TMPDIR
let l:unparsed_lines = []
for l:line in a:lines
if l:line[0] ==# '['
if l:line[0] is# '['
let l:errors = json_decode(l:line)
for l:error in l:errors
" Check if file is from the temp directory.
" Filters out any errors not related to the buffer.
if l:is_windows
let l:file_is_buffer = l:error.file[0:len(l:temp_dir) - 1] ==? l:temp_dir
let l:file_is_buffer = l:error.file[0:len(l:temp_dir) - 1] is? l:temp_dir
else
let l:file_is_buffer = l:error.file[0:len(l:temp_dir) - 1] ==# l:temp_dir
let l:file_is_buffer = l:error.file[0:len(l:temp_dir) - 1] is# l:temp_dir
endif
if l:file_is_buffer
@ -25,7 +25,7 @@ function! ale_linters#elm#make#Handle(buffer, lines) abort
\ 'col': l:error.region.start.column,
\ 'end_lnum': l:error.region.end.line,
\ 'end_col': l:error.region.end.column,
\ 'type': (l:error.type ==? 'error') ? 'E' : 'W',
\ 'type': (l:error.type is? 'error') ? 'E' : 'W',
\ 'text': l:error.overview,
\ 'detail': l:error.overview . "\n\n" . l:error.details
\})

View File

@ -27,7 +27,7 @@ function! ale_linters#erlang#erlc#Handle(buffer, lines) abort
let l:pattern_no_module_definition = '\v(no module definition)$'
let l:pattern_unused = '\v(.* is unused)$'
let l:is_hrl = fnamemodify(bufname(a:buffer), ':e') ==# 'hrl'
let l:is_hrl = fnamemodify(bufname(a:buffer), ':e') is# 'hrl'
for l:line in a:lines
let l:match = matchlist(l:line, l:pattern)

View File

@ -44,7 +44,7 @@ function! ale_linters#fortran#gcc#Handle(buffer, lines) abort
" Now we have the text, we can set it and add the error.
let l:last_loclist_obj.text = l:match[2]
let l:last_loclist_obj.type = l:match[1] ==# 'Warning' ? 'W' : 'E'
let l:last_loclist_obj.type = l:match[1] is# 'Warning' ? 'W' : 'E'
call add(l:output, l:last_loclist_obj)
else
let l:last_loclist_obj = {

View File

@ -32,7 +32,7 @@ function! ale_linters#go#gometalinter#Handler(buffer, lines) abort
call add(l:output, {
\ 'lnum': l:match[2] + 0,
\ 'col': l:match[3] + 0,
\ 'type': tolower(l:match[4]) ==# 'warning' ? 'W' : 'E',
\ 'type': tolower(l:match[4]) is# 'warning' ? 'W' : 'E',
\ 'text': l:match[5],
\})
endfor

View File

@ -5,9 +5,9 @@ function! ale_linters#haskell#hlint#Handle(buffer, lines) abort
let l:output = []
for l:error in ale#util#FuzzyJSONDecode(a:lines, [])
if l:error.severity ==# 'Error'
if l:error.severity is# 'Error'
let l:type = 'E'
elseif l:error.severity ==# 'Suggestion'
elseif l:error.severity is# 'Suggestion'
let l:type = 'I'
else
let l:type = 'W'

View File

@ -46,7 +46,7 @@ function! ale_linters#html#tidy#Handle(buffer, lines) abort
for l:match in ale#util#GetMatches(a:lines, l:pattern)
let l:line = l:match[1] + 0
let l:col = l:match[2] + 0
let l:type = l:match[3] ==# 'Error' ? 'E' : 'W'
let l:type = l:match[3] is# 'Error' ? 'E' : 'W'
let l:text = l:match[4]
call add(l:output, {

View File

@ -68,14 +68,14 @@ function! ale_linters#java#javac#Handle(buffer, lines) abort
let l:output[-1].col = len(l:match[1])
elseif empty(l:match[3])
" Add symbols to 'cannot find symbol' errors.
if l:output[-1].text ==# 'error: cannot find symbol'
if l:output[-1].text is# 'error: cannot find symbol'
let l:output[-1].text .= ': ' . l:match[2]
endif
else
call add(l:output, {
\ 'lnum': l:match[1] + 0,
\ 'text': l:match[2] . ':' . l:match[3],
\ 'type': l:match[2] ==# 'error' ? 'E' : 'W',
\ 'type': l:match[2] is# 'error' ? 'E' : 'W',
\})
endif
endfor

View File

@ -46,7 +46,7 @@ function! s:GetJSONLines(lines) abort
let l:start_index = 0
for l:line in a:lines
if l:line[:0] ==# '{'
if l:line[:0] is# '{'
break
endif
@ -77,13 +77,13 @@ function! ale_linters#javascript#flow#Handle(buffer, lines) abort
" In certain cases, `l:message.loc.source` points to a different path
" than the buffer one, thus we skip this loc information too.
if has_key(l:message, 'loc')
\&& l:line ==# 0
\&& l:line is# 0
\&& ale#path#IsBufferPath(a:buffer, l:message.loc.source)
let l:line = l:message.loc.start.line + 0
let l:col = l:message.loc.start.column + 0
endif
if l:text ==# ''
if l:text is# ''
let l:text = l:message.descr . ':'
else
let l:text = l:text . ' ' . l:message.descr
@ -98,7 +98,7 @@ function! ale_linters#javascript#flow#Handle(buffer, lines) abort
\ 'lnum': l:line,
\ 'col': l:col,
\ 'text': l:text,
\ 'type': l:error.level ==# 'error' ? 'E' : 'W',
\ 'type': l:error.level is# 'error' ? 'E' : 'W',
\})
endfor

View File

@ -124,7 +124,7 @@ function! ale_linters#kotlin#kotlinc#Handle(buffer, lines) abort
if l:buf_abspath !=# l:curbuf_abspath
continue
endif
let l:type_marker_str = l:type ==# 'warning' ? 'W' : 'E'
let l:type_marker_str = l:type is# 'warning' ? 'W' : 'E'
call add(l:output, {
\ 'lnum': l:line,
@ -145,7 +145,7 @@ function! ale_linters#kotlin#kotlinc#Handle(buffer, lines) abort
let l:type = l:match[1]
let l:text = l:match[2]
let l:type_marker_str = l:type ==# 'warning' || l:type ==# 'info' ? 'W' : 'E'
let l:type_marker_str = l:type is# 'warning' || l:type is# 'info' ? 'W' : 'E'
call add(l:output, {
\ 'lnum': 1,

View File

@ -30,7 +30,7 @@ function! ale_linters#matlab#mlint#Handle(buffer, lines) abort
" Suppress erroneous waring about filename
" TODO: Enable this error when copying filename is supported
if l:code ==# 'FNDEF'
if l:code is# 'FNDEF'
continue
endif

View File

@ -26,7 +26,7 @@ function! ale_linters#nim#nimcheck#Handle(buffer, lines) abort
if len(l:textmatch) > 0
let l:errortype = l:textmatch[1]
if l:errortype ==# 'Error'
if l:errortype is# 'Error'
let l:type = 'E'
endif
endif

View File

@ -21,7 +21,7 @@ function! ale_linters#perl#perlcritic#GetProfile(buffer) abort
" first see if we've been overridden
let l:profile = ale#Var(a:buffer, 'perl_perlcritic_profile')
if l:profile ==? ''
if l:profile is? ''
return ''
endif

View File

@ -40,7 +40,7 @@ function! ale_linters#php#phpcs#Handle(buffer, lines) abort
\ 'lnum': l:match[1] + 0,
\ 'col': l:match[2] + 0,
\ 'text': l:text,
\ 'type': l:type ==# 'error' ? 'E' : 'W',
\ 'type': l:type is# 'error' ? 'E' : 'W',
\})
endfor

View File

@ -115,7 +115,7 @@ function! ale_linters#python#flake8#Handle(buffer, lines) abort
for l:match in ale#util#GetMatches(a:lines, l:pattern)
let l:code = l:match[3]
if (l:code ==# 'W291' || l:code ==# 'W293')
if (l:code is# 'W291' || l:code is# 'W293')
\ && !ale#Var(a:buffer, 'warn_about_trailing_whitespace')
" Skip warnings for trailing whitespace if the option is off.
continue
@ -128,12 +128,12 @@ function! ale_linters#python#flake8#Handle(buffer, lines) abort
\ 'type': 'W',
\}
if l:code[:0] ==# 'F' || l:code ==# 'E999'
if l:code[:0] is# 'F' || l:code is# 'E999'
let l:item.type = 'E'
elseif l:code[:0] ==# 'E'
elseif l:code[:0] is# 'E'
let l:item.type = 'E'
let l:item.sub_type = 'style'
elseif l:code[:0] ==# 'W'
elseif l:code[:0] is# 'W'
let l:item.sub_type = 'style'
endif

View File

@ -31,13 +31,13 @@ function! ale_linters#python#pylint#Handle(buffer, lines) abort
"let l:failed = append(0, l:match)
let l:code = l:match[3]
if (l:code ==# 'C0303')
if (l:code is# 'C0303')
\ && !ale#Var(a:buffer, 'warn_about_trailing_whitespace')
" Skip warnings for trailing whitespace if the option is off.
continue
endif
if l:code ==# 'I0011'
if l:code is# 'I0011'
" Skip 'Locally disabling' message
continue
endif
@ -46,7 +46,7 @@ function! ale_linters#python#pylint#Handle(buffer, lines) abort
\ 'lnum': l:match[1] + 0,
\ 'col': l:match[2] + 1,
\ 'text': l:code . ': ' . l:match[5] . ' (' . l:match[4] . ')',
\ 'type': l:code[:0] ==# 'E' ? 'E' : 'W',
\ 'type': l:code[:0] is# 'E' ? 'E' : 'W',
\})
endfor

View File

@ -33,7 +33,7 @@ endfunction
function! ale_linters#ruby#brakeman#GetCommand(buffer) abort
let l:rails_root = ale#ruby#FindRailsRoot(a:buffer)
if l:rails_root ==? ''
if l:rails_root is? ''
return ''
endif

View File

@ -30,7 +30,7 @@ function! ale_linters#ruby#rails_best_practices#GetCommand(buffer) abort
let l:rails_root = ale#ruby#FindRailsRoot(a:buffer)
if l:rails_root ==? ''
if l:rails_root is? ''
return ''
endif

View File

@ -43,9 +43,9 @@ function! ale_linters#ruby#rubocop#Handle(buffer, lines) abort
endfunction
function! ale_linters#ruby#rubocop#GetType(severity) abort
if a:severity ==? 'convention'
\|| a:severity ==? 'warning'
\|| a:severity ==? 'refactor'
if a:severity is? 'convention'
\|| a:severity is? 'warning'
\|| a:severity is? 'refactor'
return 'W'
endif

View File

@ -38,7 +38,7 @@ function! ale_linters#scala#scalac#Handle(buffer, lines) abort
endif
let l:text = l:match[3]
let l:type = l:match[2] ==# 'error' ? 'E' : 'W'
let l:type = l:match[2] is# 'error' ? 'E' : 'W'
let l:col = 0
if l:ln + 1 < len(a:lines)

View File

@ -19,7 +19,7 @@ function! ale_linters#scss#scsslint#Handle(buffer, lines) abort
\ 'lnum': l:match[1] + 0,
\ 'col': l:match[2] + 0,
\ 'text': l:match[4],
\ 'type': l:match[3] ==# 'E' ? 'E' : 'W',
\ 'type': l:match[3] is# 'E' ? 'E' : 'W',
\})
endfor

View File

@ -11,7 +11,7 @@ endif
if !exists('g:ale_sh_shell_default_shell')
let g:ale_sh_shell_default_shell = fnamemodify($SHELL, ':t')
if g:ale_sh_shell_default_shell ==# '' || g:ale_sh_shell_default_shell ==# 'fish'
if g:ale_sh_shell_default_shell is# '' || g:ale_sh_shell_default_shell is# 'fish'
let g:ale_sh_shell_default_shell = 'bash'
endif
endif

View File

@ -29,7 +29,7 @@ function! ale_linters#sml#smlnj#Handle(buffer, lines) abort
\ 'bufnr': a:buffer,
\ 'lnum': l:match[1] + 0,
\ 'text': l:match[2] . ': ' . l:match[3],
\ 'type': l:match[2] ==# 'error' ? 'E' : 'W',
\ 'type': l:match[2] is# 'error' ? 'E' : 'W',
\})
continue
endif

View File

@ -28,7 +28,7 @@ function! ale_linters#tcl#nagelfar#Handle(buffer, lines) abort
for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:output, {
\ 'lnum': l:match[1] + 0,
\ 'type': l:match[2] ==# 'N' ? 'W' : l:match[2],
\ 'type': l:match[2] is# 'N' ? 'W' : l:match[2],
\ 'text': l:match[3],
\})
endfor

View File

@ -17,7 +17,7 @@ function! ale_linters#typescript#tslint#Handle(buffer, lines) abort
for l:error in ale#util#FuzzyJSONDecode(a:lines, [])
if ale#path#IsBufferPath(a:buffer, l:error.name)
call add(l:output, {
\ 'type': (get(l:error, 'ruleSeverity', '') ==# 'WARNING' ? 'W' : 'E'),
\ 'type': (get(l:error, 'ruleSeverity', '') is# 'WARNING' ? 'W' : 'E'),
\ 'text': l:error.failure,
\ 'lnum': l:error.startPosition.line + 1,
\ 'col': l:error.startPosition.character + 1,

View File

@ -14,7 +14,7 @@ function! ale_linters#verilog#iverilog#Handle(buffer, lines) abort
for l:match in ale#util#GetMatches(a:lines, l:pattern)
let l:line = l:match[1] + 0
let l:type = l:match[2] =~# 'error' ? 'E' : 'W'
let l:text = l:match[2] ==# 'syntax error' ? 'syntax error' : l:match[4]
let l:text = l:match[2] is# 'syntax error' ? 'syntax error' : l:match[4]
call add(l:output, {
\ 'lnum': l:line,

View File

@ -33,7 +33,7 @@ function! ale_linters#verilog#verilator#Handle(buffer, lines) abort
for l:match in ale#util#GetMatches(a:lines, l:pattern)
let l:line = l:match[3] + 0
let l:type = l:match[1] ==# 'Error' ? 'E' : 'W'
let l:type = l:match[1] is# 'Error' ? 'E' : 'W'
let l:text = l:match[4]
let l:file = l:match[2]

View File

@ -21,7 +21,7 @@ function! ale_linters#yaml#swaglint#Handle(buffer, lines) abort
for l:match in ale#util#GetMatches(a:lines, l:pattern)
let l:obj = {
\ 'type': l:match[1] ==# 'error' ? 'E' : 'W',
\ 'type': l:match[1] is# 'error' ? 'E' : 'W',
\ 'lnum': l:match[2] + 0,
\ 'col': l:match[3] + 0,
\ 'text': l:match[4],

View File

@ -33,7 +33,7 @@ function! ale_linters#yaml#yamllint#Handle(buffer, lines) abort
\ 'lnum': l:line,
\ 'col': l:col,
\ 'text': l:text,
\ 'type': l:type ==# 'error' ? 'E' : 'W',
\ 'type': l:type is# 'error' ? 'E' : 'W',
\})
endfor

View File

@ -50,7 +50,7 @@ function! ale#Queue(delay, ...) abort
" Remember that we want to check files for this buffer.
" We will remember this until we finally run the linters, via any event.
if l:linting_flag ==# 'lint_file'
if l:linting_flag is# 'lint_file'
let s:should_lint_file_for_buffer[bufnr('%')] = 1
endif
@ -157,7 +157,7 @@ endfunction
" Escape a string suitably for each platform.
" shellescape does not work on Windows.
function! ale#Escape(str) abort
if fnamemodify(&shell, ':t') ==? 'cmd.exe'
if fnamemodify(&shell, ':t') is? 'cmd.exe'
" If the string contains spaces, it will be surrounded by quotes.
" Otherwise, special characters will be escaped with carets (^).
return substitute(

View File

@ -9,7 +9,7 @@ function! ale#c#FindProjectRoot(buffer) abort
let l:path = fnamemodify(l:full_path, ':h')
" Correct .git path detection.
if fnamemodify(l:path, ':t') ==# '.git'
if fnamemodify(l:path, ':t') is# '.git'
let l:path = fnamemodify(l:path, ':h')
endif

View File

@ -44,7 +44,7 @@ function! ale#completion#FilterSuggestionsByPrefix(suggestions, prefix) abort
" foo.
" ^
" We need to include all of the given suggestions.
if a:prefix ==# '.'
if a:prefix is# '.'
return a:suggestions
endif
@ -59,7 +59,7 @@ function! ale#completion#FilterSuggestionsByPrefix(suggestions, prefix) abort
for l:suggestion in a:suggestions
" Add suggestions if the suggestion starts with a case-insensitive
" match for the prefix.
if l:suggestion.word[: len(a:prefix) - 1] ==? a:prefix
if l:suggestion.word[: len(a:prefix) - 1] is? a:prefix
call add(l:filtered_suggestions, l:suggestion)
endif
endfor
@ -150,9 +150,9 @@ function! ale#completion#ParseTSServerCompletionEntryDetails(response) abort
call add(l:documentationParts, l:part.text)
endfor
if l:suggestion.kind ==# 'clasName'
if l:suggestion.kind is# 'clasName'
let l:kind = 'f'
elseif l:suggestion.kind ==# 'parameterName'
elseif l:suggestion.kind is# 'parameterName'
let l:kind = 'f'
else
let l:kind = 'v'
@ -182,7 +182,7 @@ function! s:HandleTSServerLSPResponse(conn_id, response) abort
let l:command = get(a:response, 'command', '')
if l:command ==# 'completions'
if l:command is# 'completions'
let l:names = ale#completion#ParseTSServerCompletions(a:response)
if !empty(l:names)
@ -196,7 +196,7 @@ function! s:HandleTSServerLSPResponse(conn_id, response) abort
\ ),
\)
endif
elseif l:command ==# 'completionEntryDetails'
elseif l:command is# 'completionEntryDetails'
call ale#completion#Show(
\ a:response,
\ 'ale#completion#ParseTSServerCompletionEntryDetails',
@ -256,7 +256,7 @@ function! ale#completion#GetCompletions() abort
\}
for l:linter in ale#linter#Get(&filetype)
if l:linter.lsp ==# 'tsserver'
if l:linter.lsp is# 'tsserver'
call s:GetLSPCompletions(l:linter)
endif
endfor

View File

@ -4,7 +4,7 @@
" Return a formatted message according to g:ale_echo_msg_format variable
function! s:GetMessage(linter, type, text) abort
let l:msg = g:ale_echo_msg_format
let l:type = a:type ==# 'E'
let l:type = a:type is# 'E'
\ ? g:ale_echo_msg_error_str
\ : g:ale_echo_msg_warning_str
@ -22,12 +22,12 @@ function! s:EchoWithShortMess(setting, message) abort
try
" Turn shortmess on or off.
if a:setting ==# 'on'
if a:setting is# 'on'
setlocal shortmess+=T
" echomsg is needed for the message to get truncated and appear in
" the message history.
exec "norm! :echomsg a:message\n"
elseif a:setting ==# 'off'
elseif a:setting is# 'off'
setlocal shortmess-=T
" Regular echo is needed for printing newline characters.
echo a:message

View File

@ -81,7 +81,7 @@ function! s:EchoCommandHistory() abort
let l:status_message = l:item.status
" Include the exit code in output if we have it.
if l:item.status ==# 'finished'
if l:item.status is# 'finished'
let l:status_message .= ' - exit code ' . l:item.exit_code
endif

View File

@ -224,7 +224,7 @@ function! s:HandleTSServerDiagnostics(response, error_type) abort
" tsserver sends syntax and semantic errors in separate messages, so we
" have to collect the messages separately for each buffer and join them
" back together again.
if a:error_type ==# 'syntax'
if a:error_type is# 'syntax'
let l:info.syntax_loclist = l:thislist
else
let l:info.semantic_loclist = l:thislist
@ -247,16 +247,16 @@ endfunction
function! ale#engine#HandleLSPResponse(conn_id, response) abort
let l:method = get(a:response, 'method', '')
if get(a:response, 'jsonrpc', '') ==# '2.0' && has_key(a:response, 'error')
if get(a:response, 'jsonrpc', '') is# '2.0' && has_key(a:response, 'error')
" Uncomment this line to print LSP error messages.
" call s:HandleLSPErrorMessage(a:response.error.message)
elseif l:method ==# 'textDocument/publishDiagnostics'
elseif l:method is# 'textDocument/publishDiagnostics'
call s:HandleLSPDiagnostics(a:conn_id, a:response)
elseif get(a:response, 'type', '') ==# 'event'
\&& get(a:response, 'event', '') ==# 'semanticDiag'
elseif get(a:response, 'type', '') is# 'event'
\&& get(a:response, 'event', '') is# 'semanticDiag'
call s:HandleTSServerDiagnostics(a:response, 'semantic')
elseif get(a:response, 'type', '') ==# 'event'
\&& get(a:response, 'event', '') ==# 'syntaxDiag'
elseif get(a:response, 'type', '') is# 'event'
\&& get(a:response, 'event', '') is# 'syntaxDiag'
call s:HandleTSServerDiagnostics(a:response, 'syntax')
endif
endfunction
@ -313,17 +313,17 @@ endfunction
function! s:RemapItemTypes(type_map, loclist) abort
for l:item in a:loclist
let l:key = l:item.type
\ . (get(l:item, 'sub_type', '') ==# 'style' ? 'S' : '')
\ . (get(l:item, 'sub_type', '') is# 'style' ? 'S' : '')
let l:new_key = get(a:type_map, l:key, '')
if l:new_key ==# 'E'
\|| l:new_key ==# 'ES'
\|| l:new_key ==# 'W'
\|| l:new_key ==# 'WS'
\|| l:new_key ==# 'I'
if l:new_key is# 'E'
\|| l:new_key is# 'ES'
\|| l:new_key is# 'W'
\|| l:new_key is# 'WS'
\|| l:new_key is# 'I'
let l:item.type = l:new_key[0]
if l:new_key ==# 'ES' || l:new_key ==# 'WS'
if l:new_key is# 'ES' || l:new_key is# 'WS'
let l:item.sub_type = 'style'
elseif has_key(l:item, 'sub_type')
call remove(l:item, 'sub_type')
@ -465,9 +465,9 @@ function! s:RunJob(options) abort
\ 'exit_cb': function('s:HandleExit'),
\}
if l:output_stream ==# 'stderr'
if l:output_stream is# 'stderr'
let l:job_options.err_cb = function('s:GatherOutput')
elseif l:output_stream ==# 'both'
elseif l:output_stream is# 'both'
let l:job_options.out_cb = function('s:GatherOutput')
let l:job_options.err_cb = function('s:GatherOutput')
else
@ -635,7 +635,7 @@ function! s:CheckWithLSP(buffer, linter) abort
" Remember the linter this connection is for.
let s:lsp_linter_map[l:id] = a:linter.name
let l:change_message = a:linter.lsp ==# 'tsserver'
let l:change_message = a:linter.lsp is# 'tsserver'
\ ? ale#lsp#tsserver_message#Geterr(a:buffer)
\ : ale#lsp#message#DidChange(a:buffer)
let l:request_id = ale#lsp#Send(l:id, l:change_message, l:root)

View File

@ -186,9 +186,9 @@ function! s:RunJob(options) abort
if l:read_temporary_file
" TODO: Check that a temporary file is set here.
let l:job_info.file_to_read = l:temporary_file
elseif l:output_stream ==# 'stderr'
elseif l:output_stream is# 'stderr'
let l:job_options.err_cb = function('s:GatherOutput')
elseif l:output_stream ==# 'both'
elseif l:output_stream is# 'both'
let l:job_options.out_cb = function('s:GatherOutput')
let l:job_options.err_cb = function('s:GatherOutput')
else
@ -320,7 +320,7 @@ function! ale#fix#InitBufferData(buffer, fixing_flag) abort
\ 'lines_before': getbufline(a:buffer, 1, '$'),
\ 'filename': expand('#' . a:buffer . ':p'),
\ 'done': 0,
\ 'should_save': a:fixing_flag ==# 'save_file',
\ 'should_save': a:fixing_flag is# 'save_file',
\ 'temporary_directory_list': [],
\}
endfunction
@ -342,7 +342,7 @@ function! ale#fix#Fix(...) abort
let l:callback_list = s:GetCallbacks()
if empty(l:callback_list)
if l:fixing_flag ==# ''
if l:fixing_flag is# ''
echoerr 'No fixers have been defined. Try :ALEFixSuggest'
endif

View File

@ -11,7 +11,7 @@ function! ale#handlers#cppcheck#HandleCppCheckFormat(buffer, lines) abort
if ale#path#IsBufferPath(a:buffer, l:match[1])
call add(l:output, {
\ 'lnum': str2nr(l:match[2]),
\ 'type': l:match[3] ==# 'error' ? 'E' : 'W',
\ 'type': l:match[3] is# 'error' ? 'E' : 'W',
\ 'text': l:match[4],
\})
endif

View File

@ -29,7 +29,7 @@ function! ale#handlers#css#HandleCSSLintFormat(buffer, lines) abort
\ 'lnum': l:match[1] + 0,
\ 'col': l:match[2] + 0,
\ 'text': l:text,
\ 'type': l:type ==# 'Warning' ? 'W' : 'E',
\ 'type': l:type is# 'Warning' ? 'W' : 'E',
\})
endfor
@ -61,7 +61,7 @@ function! ale#handlers#css#HandleStyleLintFormat(buffer, lines) abort
call add(l:output, {
\ 'lnum': l:match[1] + 0,
\ 'col': l:match[2] + 0,
\ 'type': l:match[3] ==# '✖' ? 'E' : 'W',
\ 'type': l:match[3] is# '✖' ? 'E' : 'W',
\ 'text': l:match[4] . ' [' . l:match[5] . ']',
\})
endfor

View File

@ -92,7 +92,7 @@ function! ale#handlers#eslint#Handle(buffer, lines) abort
\ 'lnum': l:match[1] + 0,
\ 'col': l:match[2] + 0,
\ 'text': l:text,
\ 'type': l:type ==# 'Warning' ? 'W' : 'E',
\ 'type': l:type is# 'Warning' ? 'W' : 'E',
\}
for l:col_match in ale#util#GetMatches(l:text, s:col_end_patterns)

View File

@ -81,7 +81,7 @@ function! ale#handlers#gcc#HandleGCCFormat(buffer, lines) abort
let l:included_filename = ''
endif
elseif l:include_lnum > 0
\&& (empty(l:included_filename) || l:included_filename ==# l:match[1])
\&& (empty(l:included_filename) || l:included_filename is# l:match[1])
" If we hit the first error after an include header, or the
" errors below have the same name as the first filename we see,
" then include these lines, and remember what that filename was.
@ -96,7 +96,7 @@ function! ale#handlers#gcc#HandleGCCFormat(buffer, lines) abort
let l:included_filename = ''
if s:IsHeaderFile(bufname(bufnr('')))
\&& l:match[5][:len(s:pragma_error) - 1] ==# s:pragma_error
\&& l:match[5][:len(s:pragma_error) - 1] is# s:pragma_error
continue
endif

View File

@ -14,7 +14,7 @@ function! ale#handlers#haskell#HandleGHCFormat(buffer, lines) abort
for l:line in a:lines
if len(matchlist(l:line, l:pattern)) > 0
call add(l:corrected_lines, l:line)
elseif l:line ==# ''
elseif l:line is# ''
call add(l:corrected_lines, l:line)
else
if len(l:corrected_lines) > 0
@ -42,10 +42,10 @@ function! ale#handlers#haskell#HandleGHCFormat(buffer, lines) abort
let l:text = l:errors[2]
else
let l:ghc_type = ''
let l:text = l:match[4][:0] ==# ' ' ? l:match[4][1:] : l:match[4]
let l:text = l:match[4][:0] is# ' ' ? l:match[4][1:] : l:match[4]
endif
if l:ghc_type ==? 'Warning'
if l:ghc_type is? 'Warning'
let l:type = 'W'
else
let l:type = 'E'

View File

@ -47,7 +47,7 @@ function! ale#handlers#rust#HandleRustErrorsForFile(buffer, full_filename, lines
for l:span in l:error.spans
if (
\ l:span.is_primary
\ && (ale#path#IsBufferPath(a:buffer, l:span.file_name) || l:span.file_name ==# '<anon>')
\ && (ale#path#IsBufferPath(a:buffer, l:span.file_name) || l:span.file_name is# '<anon>')
\)
call add(l:output, {
\ 'lnum': l:span.line_start,

View File

@ -65,15 +65,15 @@ function! ale#highlight#UpdateHighlights() abort
call ale#highlight#RemoveHighlights()
for l:item in l:item_list
if l:item.type ==# 'W'
if get(l:item, 'sub_type', '') ==# 'style'
if l:item.type is# 'W'
if get(l:item, 'sub_type', '') is# 'style'
let l:group = 'ALEStyleWarning'
else
let l:group = 'ALEWarning'
endif
elseif l:item.type ==# 'I'
elseif l:item.type is# 'I'
let l:group = 'ALEInfo'
elseif get(l:item, 'sub_type', '') ==# 'style'
elseif get(l:item, 'sub_type', '') is# 'style'
let l:group = 'ALEStyleError'
else
let l:group = 'ALEError'

View File

@ -34,7 +34,7 @@ function! ale#job#JoinNeovimOutput(job, last_line, data, mode, callback) abort
let l:new_last_line = a:last_line . a:data[0]
endif
if a:mode ==# 'raw'
if a:mode is# 'raw'
if !empty(l:lines)
call a:callback(a:job, join(l:lines, "\n") . "\n")
endif
@ -50,7 +50,7 @@ endfunction
function! s:NeoVimCallback(job, data, event) abort
let l:info = s:job_map[a:job]
if a:event ==# 'stdout'
if a:event is# 'stdout'
let l:info.out_cb_line = ale#job#JoinNeovimOutput(
\ a:job,
\ l:info.out_cb_line,
@ -58,7 +58,7 @@ function! s:NeoVimCallback(job, data, event) abort
\ l:info.mode,
\ ale#util#GetFunction(l:info.out_cb),
\)
elseif a:event ==# 'stderr'
elseif a:event is# 'stderr'
let l:info.err_cb_line = ale#job#JoinNeovimOutput(
\ a:job,
\ l:info.err_cb_line,
@ -117,7 +117,7 @@ function! s:VimCloseCallback(channel) abort
" job_status() can trigger the exit handler.
" The channel can close before the job has exited.
if job_status(l:job) ==# 'dead'
if job_status(l:job) is# 'dead'
try
if !empty(l:info) && has_key(l:info, 'exit_cb')
call ale#util#GetFunction(l:info.exit_cb)(l:job_id, l:info.exit_code)
@ -142,7 +142,7 @@ function! s:VimExitCallback(job, exit_code) abort
let l:info.exit_code = a:exit_code
" The program can exit before the data has finished being read.
if ch_status(job_getchannel(a:job)) ==# 'closed'
if ch_status(job_getchannel(a:job)) is# 'closed'
try
if !empty(l:info) && has_key(l:info, 'exit_cb')
call ale#util#GetFunction(l:info.exit_cb)(l:job_id, a:exit_code)
@ -273,7 +273,7 @@ function! ale#job#IsRunning(job_id) abort
endtry
elseif has_key(s:job_map, a:job_id)
let l:job = s:job_map[a:job_id].job
return job_status(l:job) ==# 'run'
return job_status(l:job) is# 'run'
endif
return 0
@ -296,7 +296,7 @@ function! ale#job#Stop(job_id) abort
" We must close the channel for reading the buffer if it is open
" when stopping a job. Otherwise, we will get errors in the status line.
if ch_status(job_getchannel(l:job)) ==# 'open'
if ch_status(job_getchannel(l:job)) is# 'open'
call ch_close_in(job_getchannel(l:job))
endif

View File

@ -59,7 +59,7 @@ function! ale#linter#PreProcess(linter) abort
throw '`name` must be defined to name the linter'
endif
let l:needs_address = l:obj.lsp ==# 'socket'
let l:needs_address = l:obj.lsp is# 'socket'
let l:needs_executable = l:obj.lsp !=# 'socket'
let l:needs_command = l:obj.lsp !=# 'socket'
let l:needs_lsp_details = !empty(l:obj.lsp)
@ -311,7 +311,7 @@ function! ale#linter#Get(original_filetypes) abort
let l:all_linters = ale#linter#GetAll(l:filetype)
let l:filetype_linters = []
if type(l:linter_names) == type('') && l:linter_names ==# 'all'
if type(l:linter_names) == type('') && l:linter_names is# 'all'
let l:filetype_linters = l:all_linters
elseif type(l:linter_names) == type([])
" Select only the linters we or the user has specified.
@ -383,7 +383,7 @@ function! ale#linter#StartLSP(buffer, linter, callback) abort
return {}
endif
if a:linter.lsp ==# 'socket'
if a:linter.lsp is# 'socket'
let l:address = ale#linter#GetAddress(a:buffer, a:linter)
let l:conn_id = ale#lsp#ConnectToAddress(
\ l:address,
@ -425,7 +425,7 @@ function! ale#linter#StartLSP(buffer, linter, callback) abort
endif
" The change message needs to be sent for tsserver before doing anything.
if a:linter.lsp ==# 'tsserver'
if a:linter.lsp is# 'tsserver'
call ale#lsp#Send(l:conn_id, ale#lsp#tsserver_message#Change(a:buffer))
endif

View File

@ -4,7 +4,7 @@
" Return 1 if there is a buffer with buftype == 'quickfix' in bufffer list
function! ale#list#IsQuickfixOpen() abort
for l:buf in range(1, bufnr('$'))
if getbufvar(l:buf, '&buftype') ==# 'quickfix'
if getbufvar(l:buf, '&buftype') is# 'quickfix'
return 1
endif
endfor
@ -18,7 +18,7 @@ function! s:ShouldOpen(buffer) abort
let l:saved = getbufvar(a:buffer, 'ale_save_event_fired', 0)
return (type(l:val) == type(1) && l:val == 1)
\ || (type(l:val) == type('') && l:val ==# 'on_save' && l:saved)
\ || (type(l:val) == type('') && l:val is# 'on_save' && l:saved)
endfunction
function! ale#list#SetLists(buffer, loclist) abort
@ -51,8 +51,8 @@ function! ale#list#SetLists(buffer, loclist) abort
if s:ShouldOpen(a:buffer) && (l:keep_open || !empty(a:loclist))
let l:winnr = winnr()
let l:mode = mode()
let l:reset_visual_selection = l:mode ==? 'v' || l:mode ==# "\<c-v>"
let l:reset_character_selection = l:mode ==? 's' || l:mode ==# "\<c-s>"
let l:reset_visual_selection = l:mode is? 'v' || l:mode is# "\<c-v>"
let l:reset_character_selection = l:mode is? 's' || l:mode is# "\<c-s>"
if g:ale_set_quickfix
if !ale#list#IsQuickfixOpen()

View File

@ -17,7 +17,7 @@ function! ale#loclist_jumping#FindNearest(direction, wrap) abort
let l:search_item = {'lnum': l:pos[1], 'col': l:pos[2]}
" When searching backwards, so we can find the next smallest match.
if a:direction ==# 'before'
if a:direction is# 'before'
let l:loclist = reverse(copy(l:loclist))
endif
@ -36,11 +36,11 @@ function! ale#loclist_jumping#FindNearest(direction, wrap) abort
\ l:search_item
\)
if a:direction ==# 'before' && l:cmp_value < 0
if a:direction is# 'before' && l:cmp_value < 0
return [l:item.lnum, l:item.col]
endif
if a:direction ==# 'after' && l:cmp_value > 0
if a:direction is# 'after' && l:cmp_value > 0
return [l:item.lnum, l:item.col]
endif
endfor

View File

@ -190,17 +190,17 @@ function! ale#lsp#HandleOtherInitializeResponses(conn, response) abort
return
endif
if get(a:response, 'method', '') ==# ''
if get(a:response, 'method', '') is# ''
if has_key(get(a:response, 'result', {}), 'capabilities')
for [l:dir, l:project] in l:uninitialized_projects
call s:MarkProjectAsInitialized(a:conn, l:project)
endfor
endif
elseif get(a:response, 'method', '') ==# 'textDocument/publishDiagnostics'
elseif get(a:response, 'method', '') is# 'textDocument/publishDiagnostics'
let l:filename = ale#path#FromURI(a:response.params.uri)
for [l:dir, l:project] in l:uninitialized_projects
if l:filename[:len(l:dir) - 1] ==# l:dir
if l:filename[:len(l:dir) - 1] is# l:dir
call s:MarkProjectAsInitialized(a:conn, l:project)
endif
endfor
@ -215,7 +215,7 @@ function! ale#lsp#HandleMessage(conn, message) abort
" Call our callbacks.
for l:response in l:response_list
if get(l:response, 'method', '') ==# 'initialize'
if get(l:response, 'method', '') is# 'initialize'
call s:HandleInitializeResponse(a:conn, l:response)
else
call ale#lsp#HandleOtherInitializeResponses(a:conn, l:response)
@ -304,7 +304,7 @@ function! ale#lsp#ConnectToAddress(address, project_root, callback) abort
\})
endif
if ch_status(l:conn.channnel) ==# 'fail'
if ch_status(l:conn.channnel) is# 'fail'
return 0
endif
@ -319,7 +319,7 @@ endfunction
function! s:SendMessageData(conn, data) abort
if has_key(a:conn, 'executable')
call ale#job#SendRaw(a:conn.id, a:data)
elseif has_key(a:conn, 'channel') && ch_status(a:conn.channnel) ==# 'open'
elseif has_key(a:conn, 'channel') && ch_status(a:conn.channnel) is# 'open'
" Send the message to the server
call ch_sendraw(a:conn.channel, a:data)
else

View File

@ -65,7 +65,7 @@ endfunction
" Return 1 if a path is an absolute path.
function! ale#path#IsAbsolute(filename) abort
" Check for /foo and C:\foo, etc.
return a:filename[:0] ==# '/' || a:filename[1:2] ==# ':\'
return a:filename[:0] is# '/' || a:filename[1:2] is# ':\'
endfunction
" Given a filename, return 1 if the file represents some temporary file
@ -78,7 +78,7 @@ function! ale#path#IsTempName(filename) abort
\]
for l:prefix in l:prefix_list
if a:filename[:len(l:prefix) - 1] ==# l:prefix
if a:filename[:len(l:prefix) - 1] is# l:prefix
return 1
endif
endfor
@ -90,19 +90,19 @@ endfunction
" two paths represent the same file on disk.
function! ale#path#IsBufferPath(buffer, complex_filename) abort
" If the path is one of many different names for stdin, we have a match.
if a:complex_filename ==# '-'
\|| a:complex_filename ==# 'stdin'
\|| a:complex_filename[:0] ==# '<'
if a:complex_filename is# '-'
\|| a:complex_filename is# 'stdin'
\|| a:complex_filename[:0] is# '<'
return 1
endif
let l:test_filename = ale#path#Simplify(a:complex_filename)
if l:test_filename[:1] ==# './'
if l:test_filename[:1] is# './'
let l:test_filename = l:test_filename[2:]
endif
if l:test_filename[:1] ==# '..'
if l:test_filename[:1] is# '..'
" Remove ../../ etc. from the front of the path.
let l:test_filename = substitute(l:test_filename, '\v^(\.\.[/\\])+', '/', '')
endif
@ -114,8 +114,8 @@ function! ale#path#IsBufferPath(buffer, complex_filename) abort
let l:buffer_filename = expand('#' . a:buffer . ':p')
return l:buffer_filename ==# l:test_filename
\ || l:buffer_filename[-len(l:test_filename):] ==# l:test_filename
return l:buffer_filename is# l:test_filename
\ || l:buffer_filename[-len(l:test_filename):] is# l:test_filename
endfunction
" Given a path, return every component of the path, moving upwards.
@ -133,7 +133,7 @@ function! ale#path#Upwards(path) abort
if ale#Has('win32') && a:path =~# '^[a-zA-z]:\'
" Add \ to C: for C:\, etc.
let l:path_list[-1] .= '\'
elseif a:path[0] ==# '/'
elseif a:path[0] is# '/'
" If the path starts with /, even on Windows, add / and / to all paths.
call map(l:path_list, '''/'' . v:val')
call add(l:path_list, '/')
@ -146,10 +146,10 @@ endfunction
" relatives paths will not be prefixed with the protocol.
" For Windows paths, the `:` in C:\ etc. will not be percent-encoded.
function! ale#path#ToURI(path) abort
let l:has_drive_letter = a:path[1:2] ==# ':\'
let l:has_drive_letter = a:path[1:2] is# ':\'
return substitute(
\ ((l:has_drive_letter || a:path[:0] ==# '/') ? 'file://' : '')
\ ((l:has_drive_letter || a:path[:0] is# '/') ? 'file://' : '')
\ . (l:has_drive_letter ? '/' . a:path[:2] : '')
\ . ale#uri#Encode(l:has_drive_letter ? a:path[3:] : a:path),
\ '\\',
@ -160,7 +160,7 @@ endfunction
function! ale#path#FromURI(uri) abort
let l:i = len('file://')
let l:encoded_path = a:uri[: l:i - 1] ==# 'file://' ? a:uri[l:i :] : a:uri
let l:encoded_path = a:uri[: l:i - 1] is# 'file://' ? a:uri[l:i :] : a:uri
return ale#uri#Decode(l:encoded_path)
endfunction

View File

@ -13,7 +13,7 @@ function! ale#pattern_options#SetOptions() abort
endfor
for l:key in keys(l:options)
if l:key[:0] ==# '&'
if l:key[:0] is# '&'
call setbufvar(bufnr(''), l:key, l:options[l:key])
else
let b:[l:key] = l:options[l:key]

View File

@ -168,9 +168,9 @@ function! ale#sign#GetSignType(sublist) abort
let l:highest_level = 100
for l:item in a:sublist
let l:level = (l:item.type ==# 'I' ? 2 : l:item.type ==# 'W')
let l:level = (l:item.type is# 'I' ? 2 : l:item.type is# 'W')
if get(l:item, 'sub_type', '') ==# 'style'
if get(l:item, 'sub_type', '') is# 'style'
let l:level += 10
endif

View File

@ -26,15 +26,15 @@ function! ale#statusline#Update(buffer, loclist) abort
let l:count.total = len(a:loclist)
for l:entry in a:loclist
if l:entry.type ==# 'W'
if get(l:entry, 'sub_type', '') ==# 'style'
if l:entry.type is# 'W'
if get(l:entry, 'sub_type', '') is# 'style'
let l:count.style_warning += 1
else
let l:count.warning += 1
endif
elseif l:entry.type ==# 'I'
elseif l:entry.type is# 'I'
let l:count.info += 1
elseif get(l:entry, 'sub_type', '') ==# 'style'
elseif get(l:entry, 'sub_type', '') is# 'style'
let l:count.style_error += 1
else
let l:count.error += 1

View File

@ -193,7 +193,7 @@ endfunction
" The buffer number is required for determining the fileformat setting for
" the buffer.
function! ale#util#Writefile(buffer, lines, filename) abort
let l:corrected_lines = getbufvar(a:buffer, '&fileformat') ==# 'dos'
let l:corrected_lines = getbufvar(a:buffer, '&fileformat') is# 'dos'
\ ? map(copy(a:lines), 'v:val . "\r"')
\ : a:lines

View File

@ -65,6 +65,8 @@ if (( FIX_ERRORS )); then
for directory in "${directories[@]}"; do
sed -i "s/^\(function.*)\) *$/\1 abort/" "$directory"/**/*.vim
sed -i "s/shellescape(/ale#Escape(/" "$directory"/**/*.vim
sed -i 's/==#/is#/g' "$directory"/**/*.vim
sed -i 's/==?/is?/g' "$directory"/**/*.vim
done
fi
@ -80,5 +82,7 @@ check_errors 'let g:ale_\w\+_\w\+_args =' 'Name your option g:ale_<filetype>_<li
check_errors 'shellescape(' 'Use ale#Escape instead of shellescape'
check_errors 'simplify(' 'Use ale#path#Simplify instead of simplify'
check_errors "expand(['\"]%" "Use expand('#' . a:buffer . '...') instead. You might get a filename for the wrong buffer."
check_errors '==#' "Use 'is#' instead of '==#'. 0 ==# 'foobar' is true"
check_errors '==?' "Use 'is?' instead of '==?'. 0 ==? 'foobar' is true"
exit $RETURN_CODE

View File

@ -206,11 +206,11 @@ function! ALEInitAuGroups() abort
augroup ALERunOnTextChangedGroup
autocmd!
if g:ale_enabled
if l:text_changed ==? 'always' || l:text_changed ==# '1'
if l:text_changed is? 'always' || l:text_changed is# '1'
autocmd TextChanged,TextChangedI * call ale#Queue(g:ale_lint_delay)
elseif l:text_changed ==? 'normal'
elseif l:text_changed is? 'normal'
autocmd TextChanged * call ale#Queue(g:ale_lint_delay)
elseif l:text_changed ==? 'insert'
elseif l:text_changed is? 'insert'
autocmd TextChangedI * call ale#Queue(g:ale_lint_delay)
endif
endif