Ban !=# and !=? from the codebase

This commit is contained in:
w0rp 2017-08-11 00:31:42 +01:00
parent b1462ac66c
commit d5ae3201a4
24 changed files with 37 additions and 33 deletions

View File

@ -14,7 +14,7 @@ function! ale_linters#dockerfile#hadolint#Handle(buffer, lines) abort
for l:match in ale#util#GetMatches(a:lines, l:pattern) for l:match in ale#util#GetMatches(a:lines, l:pattern)
let l:lnum = 0 let l:lnum = 0
if l:match[1] !=# '' if l:match[1] isnot# ''
let l:lnum = l:match[1] + 0 let l:lnum = l:match[1] + 0
endif endif

View File

@ -31,7 +31,7 @@ function! ale_linters#elm#make#Handle(buffer, lines) abort
\}) \})
endif endif
endfor endfor
elseif l:line !=# 'Successfully generated /dev/null' elseif l:line isnot# 'Successfully generated /dev/null'
call add(l:unparsed_lines, l:line) call add(l:unparsed_lines, l:line)
endif endif
endfor endfor

View File

@ -13,7 +13,7 @@ let s:classpath_sep = has('unix') ? ':' : ';'
function! ale_linters#kotlin#kotlinc#GetImportPaths(buffer) abort function! ale_linters#kotlin#kotlinc#GetImportPaths(buffer) abort
" exec maven/gradle only if classpath is not set " exec maven/gradle only if classpath is not set
if ale#Var(a:buffer, 'kotlin_kotlinc_classpath') !=# '' if ale#Var(a:buffer, 'kotlin_kotlinc_classpath') isnot# ''
return '' return ''
else else
let l:pom_path = ale#path#FindNearestFile(a:buffer, 'pom.xml') let l:pom_path = ale#path#FindNearestFile(a:buffer, 'pom.xml')
@ -70,7 +70,7 @@ function! ale_linters#kotlin#kotlinc#GetCommand(buffer, import_paths) abort
endif endif
" We only get here if not using module or the module file not readable " We only get here if not using module or the module file not readable
if ale#Var(a:buffer, 'kotlin_kotlinc_classpath') !=# '' if ale#Var(a:buffer, 'kotlin_kotlinc_classpath') isnot# ''
let l:kotlinc_opts .= ' -cp ' . ale#Var(a:buffer, 'kotlin_kotlinc_classpath') let l:kotlinc_opts .= ' -cp ' . ale#Var(a:buffer, 'kotlin_kotlinc_classpath')
else else
" get classpath from maven/gradle " get classpath from maven/gradle
@ -78,7 +78,7 @@ function! ale_linters#kotlin#kotlinc#GetCommand(buffer, import_paths) abort
endif endif
let l:fname = '' let l:fname = ''
if ale#Var(a:buffer, 'kotlin_kotlinc_sourcepath') !=# '' if ale#Var(a:buffer, 'kotlin_kotlinc_sourcepath') isnot# ''
let l:fname .= expand(ale#Var(a:buffer, 'kotlin_kotlinc_sourcepath'), 1) . ' ' let l:fname .= expand(ale#Var(a:buffer, 'kotlin_kotlinc_sourcepath'), 1) . ' '
else else
" Find the src directory for files in this project. " Find the src directory for files in this project.
@ -121,7 +121,7 @@ function! ale_linters#kotlin#kotlinc#Handle(buffer, lines) abort
let l:curbuf_abspath = expand('#' . a:buffer . ':p') let l:curbuf_abspath = expand('#' . a:buffer . ':p')
" Skip if file is not loaded " Skip if file is not loaded
if l:buf_abspath !=# l:curbuf_abspath if l:buf_abspath isnot# l:curbuf_abspath
continue continue
endif endif
let l:type_marker_str = l:type is# 'warning' ? 'W' : 'E' let l:type_marker_str = l:type is# 'warning' ? 'W' : 'E'

View File

@ -12,7 +12,7 @@ function! ale_linters#nim#nimcheck#Handle(buffer, lines) abort
" module names. " module names.
let l:temp_buffer_filename = fnamemodify(l:match[1], ':p:t') let l:temp_buffer_filename = fnamemodify(l:match[1], ':p:t')
if l:buffer_filename !=# '' && l:temp_buffer_filename !=# l:buffer_filename if l:buffer_filename isnot# '' && l:temp_buffer_filename isnot# l:buffer_filename
continue continue
endif endif

View File

@ -34,7 +34,7 @@ function! ale_linters#perl#perl#Handle(buffer, lines) abort
if ale#path#IsBufferPath(a:buffer, l:match[2]) if ale#path#IsBufferPath(a:buffer, l:match[2])
\ && ( \ && (
\ l:text !=# 'BEGIN failed--compilation aborted' \ l:text isnot# 'BEGIN failed--compilation aborted'
\ || empty(l:output) \ || empty(l:output)
\ || match(l:output[-1].text, s:begin_failed_skip_pattern) < 0 \ || match(l:output[-1].text, s:begin_failed_skip_pattern) < 0
\ ) \ )

View File

@ -41,10 +41,10 @@ function! ale_linters#perl#perlcritic#GetCommand(buffer) abort
let l:command = ale#Escape(ale_linters#perl#perlcritic#GetExecutable(a:buffer)) let l:command = ale#Escape(ale_linters#perl#perlcritic#GetExecutable(a:buffer))
\ . " --verbose '". l:critic_verbosity . "' --nocolor" \ . " --verbose '". l:critic_verbosity . "' --nocolor"
if l:profile !=? '' if l:profile isnot? ''
let l:command .= ' --profile ' . ale#Escape(l:profile) let l:command .= ' --profile ' . ale#Escape(l:profile)
endif endif
if l:options !=? '' if l:options isnot? ''
let l:command .= ' ' . l:options let l:command .= ' ' . l:options
endif endif

View File

@ -37,7 +37,7 @@ function! ale_linters#python#mypy#Handle(buffer, lines) abort
let l:buffer_filename = expand('#' . a:buffer . ':p') let l:buffer_filename = expand('#' . a:buffer . ':p')
for l:match in ale#util#GetMatches(a:lines, l:pattern) for l:match in ale#util#GetMatches(a:lines, l:pattern)
if l:buffer_filename[-len(l:match[1]):] !=# l:match[1] if l:buffer_filename[-len(l:match[1]):] isnot# l:match[1]
continue continue
endif endif

View File

@ -4,7 +4,7 @@
let g:ale_rust_cargo_use_check = get(g:, 'ale_rust_cargo_use_check', 0) let g:ale_rust_cargo_use_check = get(g:, 'ale_rust_cargo_use_check', 0)
function! ale_linters#rust#cargo#GetCargoExecutable(bufnr) abort function! ale_linters#rust#cargo#GetCargoExecutable(bufnr) abort
if ale#path#FindNearestFile(a:bufnr, 'Cargo.toml') !=# '' if ale#path#FindNearestFile(a:bufnr, 'Cargo.toml') isnot# ''
return 'cargo' return 'cargo'
else else
" if there is no Cargo.toml file, we don't use cargo even if it exists, " if there is no Cargo.toml file, we don't use cargo even if it exists,

View File

@ -7,7 +7,7 @@ function! ale_linters#rust#rustc#RustcCommand(buffer_number) abort
" <project root>/target/release/deps/ " <project root>/target/release/deps/
let l:cargo_file = ale#path#FindNearestFile(a:buffer_number, 'Cargo.toml') let l:cargo_file = ale#path#FindNearestFile(a:buffer_number, 'Cargo.toml')
if l:cargo_file !=# '' if l:cargo_file isnot# ''
let l:project_root = fnamemodify(l:cargo_file, ':h') let l:project_root = fnamemodify(l:cargo_file, ':h')
let l:dependencies = '-L ' . l:project_root . '/target/debug/deps -L ' . let l:dependencies = '-L ' . l:project_root . '/target/debug/deps -L ' .
\ l:project_root . '/target/release/deps' \ l:project_root . '/target/release/deps'

View File

@ -58,7 +58,7 @@ function! ale#Queue(delay, ...) abort
endfunction endfunction
function! s:ALEQueueImpl(delay, linting_flag, buffer) abort function! s:ALEQueueImpl(delay, linting_flag, buffer) abort
if a:linting_flag !=# '' && a:linting_flag !=# 'lint_file' if a:linting_flag isnot# '' && a:linting_flag isnot# 'lint_file'
throw "linting_flag must be either '' or 'lint_file'" throw "linting_flag must be either '' or 'lint_file'"
endif endif

View File

@ -72,7 +72,7 @@ function! ale#cursor#EchoCursorWarning(...) abort
endif endif
" Only echo the warnings in normal mode, otherwise we will get problems. " Only echo the warnings in normal mode, otherwise we will get problems.
if mode() !=# 'n' if mode() isnot# 'n'
return return
endif endif
@ -118,7 +118,7 @@ function! ale#cursor#ShowCursorDetail() abort
endif endif
" Only echo the warnings in normal mode, otherwise we will get problems. " Only echo the warnings in normal mode, otherwise we will get problems.
if mode() !=# 'n' if mode() isnot# 'n'
return return
endif endif

View File

@ -128,14 +128,14 @@ function! s:HandleLoclist(linter_name, buffer, loclist) abort
" Remove this linter from the list of active linters. " Remove this linter from the list of active linters.
" This may have already been done when the job exits. " This may have already been done when the job exits.
call filter(l:buffer_info.active_linter_list, 'v:val !=# a:linter_name') call filter(l:buffer_info.active_linter_list, 'v:val isnot# a:linter_name')
" Make some adjustments to the loclists to fix common problems, and also " Make some adjustments to the loclists to fix common problems, and also
" to set default values for loclist items. " to set default values for loclist items.
let l:linter_loclist = ale#engine#FixLocList(a:buffer, a:linter_name, a:loclist) let l:linter_loclist = ale#engine#FixLocList(a:buffer, a:linter_name, a:loclist)
" Remove previous items for this linter. " Remove previous items for this linter.
call filter(g:ale_buffer_info[a:buffer].loclist, 'v:val.linter_name !=# a:linter_name') call filter(g:ale_buffer_info[a:buffer].loclist, 'v:val.linter_name isnot# a:linter_name')
" Add the new items. " Add the new items.
call extend(g:ale_buffer_info[a:buffer].loclist, l:linter_loclist) call extend(g:ale_buffer_info[a:buffer].loclist, l:linter_loclist)
@ -169,8 +169,8 @@ function! s:HandleExit(job_id, exit_code) abort
" Remove this job from the list. " Remove this job from the list.
call ale#job#Stop(a:job_id) call ale#job#Stop(a:job_id)
call remove(s:job_info_map, a:job_id) call remove(s:job_info_map, a:job_id)
call filter(g:ale_buffer_info[l:buffer].job_list, 'v:val !=# a:job_id') call filter(g:ale_buffer_info[l:buffer].job_list, 'v:val isnot# a:job_id')
call filter(g:ale_buffer_info[l:buffer].active_linter_list, 'v:val !=# l:linter.name') call filter(g:ale_buffer_info[l:buffer].active_linter_list, 'v:val isnot# l:linter.name')
" Stop here if we land in the handle for a job completing if we're in " Stop here if we land in the handle for a job completing if we're in
" a sandbox. " a sandbox.

View File

@ -335,7 +335,7 @@ function! ale#fix#Fix(...) abort
let l:fixing_flag = get(a:000, 0, '') let l:fixing_flag = get(a:000, 0, '')
if l:fixing_flag !=# '' && l:fixing_flag !=# 'save_file' if l:fixing_flag isnot# '' && l:fixing_flag isnot# 'save_file'
throw "fixing_flag must be either '' or 'save_file'" throw "fixing_flag must be either '' or 'save_file'"
endif endif

View File

@ -161,7 +161,7 @@ function! ale#job#ParseVim8ProcessID(job_string) abort
endfunction endfunction
function! ale#job#ValidateArguments(command, options) abort function! ale#job#ValidateArguments(command, options) abort
if a:options.mode !=# 'nl' && a:options.mode !=# 'raw' if a:options.mode isnot# 'nl' && a:options.mode isnot# 'raw'
throw 'Invalid mode: ' . a:options.mode throw 'Invalid mode: ' . a:options.mode
endif endif
endfunction endfunction

View File

@ -60,8 +60,8 @@ function! ale#linter#PreProcess(linter) abort
endif endif
let l:needs_address = l:obj.lsp is# 'socket' let l:needs_address = l:obj.lsp is# 'socket'
let l:needs_executable = l:obj.lsp !=# 'socket' let l:needs_executable = l:obj.lsp isnot# 'socket'
let l:needs_command = l:obj.lsp !=# 'socket' let l:needs_command = l:obj.lsp isnot# 'socket'
let l:needs_lsp_details = !empty(l:obj.lsp) let l:needs_lsp_details = !empty(l:obj.lsp)
if empty(l:obj.lsp) if empty(l:obj.lsp)
@ -377,7 +377,7 @@ function! ale#linter#StartLSP(buffer, linter, callback) abort
let l:address = '' let l:address = ''
let l:root = ale#util#GetFunction(a:linter.project_root_callback)(a:buffer) let l:root = ale#util#GetFunction(a:linter.project_root_callback)(a:buffer)
if empty(l:root) && a:linter.lsp !=# 'tsserver' if empty(l:root) && a:linter.lsp isnot# 'tsserver'
" If there's no project root, then we can't check files with LSP, " If there's no project root, then we can't check files with LSP,
" unless we are using tsserver, which doesn't use project roots. " unless we are using tsserver, which doesn't use project roots.
return {} return {}

View File

@ -62,7 +62,7 @@ function! ale#list#SetLists(buffer, loclist) abort
endif endif
" If focus changed, restore it (jump to the last window). " If focus changed, restore it (jump to the last window).
if l:winnr !=# winnr() if l:winnr isnot# winnr()
wincmd p wincmd p
endif endif

View File

@ -296,7 +296,7 @@ function! ale#lsp#ConnectToAddress(address, project_root, callback) abort
" Get the current connection or a new one. " Get the current connection or a new one.
let l:conn = !empty(l:conn) ? l:conn : s:NewConnection() let l:conn = !empty(l:conn) ? l:conn : s:NewConnection()
if !has_key(l:conn, 'channel') || ch_status(l:conn.channel) !=# 'open' if !has_key(l:conn, 'channel') || ch_status(l:conn.channel) isnot# 'open'
let l:conn.channnel = ch_open(a:address, { let l:conn.channnel = ch_open(a:address, {
\ 'mode': 'raw', \ 'mode': 'raw',
\ 'waittime': 0, \ 'waittime': 0,

View File

@ -10,7 +10,7 @@ function! ale#ruby#FindRailsRoot(buffer) abort
\ ':h:h' \ ':h:h'
\) \)
if l:dir !=# '.' if l:dir isnot# '.'
\&& isdirectory(l:dir . '/app') \&& isdirectory(l:dir . '/app')
\&& isdirectory(l:dir . '/config') \&& isdirectory(l:dir . '/config')
\&& isdirectory(l:dir . '/db') \&& isdirectory(l:dir . '/db')

View File

@ -40,7 +40,7 @@ if !hlexists('ALESignColumnWithoutErrors')
if !empty(l:match) if !empty(l:match)
execute 'highlight link ALESignColumnWithoutErrors ' . l:match[1] execute 'highlight link ALESignColumnWithoutErrors ' . l:match[1]
elseif l:highlight_syntax !=# 'cleared' elseif l:highlight_syntax isnot# 'cleared'
execute 'highlight ALESignColumnWithoutErrors ' . l:highlight_syntax execute 'highlight ALESignColumnWithoutErrors ' . l:highlight_syntax
endif endif
endfunction endfunction

View File

@ -12,7 +12,7 @@
" "
" This function should be run in a Vader Before: block. " This function should be run in a Vader Before: block.
function! ale#test#SetDirectory(docker_path) abort function! ale#test#SetDirectory(docker_path) abort
if a:docker_path[:len('/testplugin/') - 1] !=# '/testplugin/' if a:docker_path[:len('/testplugin/') - 1] isnot# '/testplugin/'
throw 'docker_path must start with /testplugin/!' throw 'docker_path must start with /testplugin/!'
endif endif

View File

@ -136,7 +136,7 @@ function! s:LoadArgCount(function) abort
endif endif
let l:match = matchstr(split(l:output, "\n")[0], '\v\([^)]+\)')[1:-2] let l:match = matchstr(split(l:output, "\n")[0], '\v\([^)]+\)')[1:-2]
let l:arg_list = filter(split(l:match, ', '), 'v:val !=# ''...''') let l:arg_list = filter(split(l:match, ', '), 'v:val isnot# ''...''')
return len(l:arg_list) return len(l:arg_list)
endfunction endfunction

View File

@ -67,6 +67,8 @@ if (( FIX_ERRORS )); then
sed -i "s/shellescape(/ale#Escape(/" "$directory"/**/*.vim sed -i "s/shellescape(/ale#Escape(/" "$directory"/**/*.vim
sed -i 's/==#/is#/g' "$directory"/**/*.vim sed -i 's/==#/is#/g' "$directory"/**/*.vim
sed -i 's/==?/is?/g' "$directory"/**/*.vim sed -i 's/==?/is?/g' "$directory"/**/*.vim
sed -i 's/!=#/isnot#/g' "$directory"/**/*.vim
sed -i 's/!=?/isnot?/g' "$directory"/**/*.vim
done done
fi fi
@ -84,5 +86,7 @@ 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 "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"
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"
exit $RETURN_CODE exit $RETURN_CODE

View File

@ -236,7 +236,7 @@ function! ALEInitAuGroups() abort
" opening a buffer. The FileType will fire when buffers are opened. " opening a buffer. The FileType will fire when buffers are opened.
autocmd FileType * autocmd FileType *
\ if has_key(b:, 'ale_original_filetype') \ if has_key(b:, 'ale_original_filetype')
\ && b:ale_original_filetype !=# expand('<amatch>') \ && b:ale_original_filetype isnot# expand('<amatch>')
\| call ale#Queue(300, 'lint_file') \| call ale#Queue(300, 'lint_file')
\| endif \| endif
endif endif

View File

@ -135,7 +135,7 @@ Execute (g:ale_lint_on_filetype_changed = 1 should bind FileType, and required b
\ 'BufReadPost * let b:ale_original_filetype = &filetype', \ 'BufReadPost * let b:ale_original_filetype = &filetype',
\ 'FileType * ' \ 'FileType * '
\ . 'if has_key(b:, ''ale_original_filetype'') ' \ . 'if has_key(b:, ''ale_original_filetype'') '
\ . '&& b:ale_original_filetype !=# expand(''<amatch>'')' \ . '&& b:ale_original_filetype isnot# expand(''<amatch>'')'
\ . '| call ale#Queue(300, ''lint_file'')' \ . '| call ale#Queue(300, ''lint_file'')'
\ . '| endif', \ . '| endif',
\], CheckAutocmd('ALERunOnFiletypeChangeGroup') \], CheckAutocmd('ALERunOnFiletypeChangeGroup')