Switch to v:t_ variables for type checks

This commit is contained in:
w0rp 2018-07-25 01:27:28 +01:00
parent 9f8c37e17c
commit 06132954b1
No known key found for this signature in database
GPG Key ID: 0FC1ECAA8C81CD83
17 changed files with 84 additions and 62 deletions

View File

@ -136,7 +136,7 @@ function! ale_linters#elm#make#ParseMessage(message) abort
endfunction endfunction
function! ale_linters#elm#make#ParseMessageItem(item) abort function! ale_linters#elm#make#ParseMessageItem(item) abort
if type(a:item) == type('') if type(a:item) is v:t_string
return a:item return a:item
else else
return a:item.string return a:item.string

View File

@ -95,7 +95,7 @@ function! ale#Queue(delay, ...) abort
throw "linting_flag must be either '' or 'lint_file'" throw "linting_flag must be either '' or 'lint_file'"
endif endif
if type(l:buffer) != type(0) if type(l:buffer) isnot v:t_number
throw 'buffer_number must be a Number' throw 'buffer_number must be a Number'
endif endif

View File

@ -30,7 +30,7 @@ function! ale#assert#Linter(expected_executable, expected_command) abort
let l:callbacks = map(copy(l:linter.command_chain), 'v:val.callback') let l:callbacks = map(copy(l:linter.command_chain), 'v:val.callback')
" If the expected command is a string, just check the last one. " If the expected command is a string, just check the last one.
if type(a:expected_command) is type('') if type(a:expected_command) is v:t_string
if len(l:callbacks) is 1 if len(l:callbacks) is 1
let l:command = call(l:callbacks[0], [l:buffer]) let l:command = call(l:callbacks[0], [l:buffer])
else else

View File

@ -113,7 +113,7 @@ function! ale#completion#Filter(buffer, suggestions, prefix) abort
for l:item in a:suggestions for l:item in a:suggestions
" A List of String values or a List of completion item Dictionaries " A List of String values or a List of completion item Dictionaries
" is accepted here. " is accepted here.
let l:word = type(l:item) == type('') ? l:item : l:item.word let l:word = type(l:item) is v:t_string ? l:item : l:item.word
" Add suggestions if the suggestion starts with a case-insensitive " Add suggestions if the suggestion starts with a case-insensitive
" match for the prefix. " match for the prefix.
@ -133,7 +133,7 @@ function! ale#completion#Filter(buffer, suggestions, prefix) abort
" Remove suggestions with words in the exclusion List. " Remove suggestions with words in the exclusion List.
call filter( call filter(
\ l:filtered_suggestions, \ l:filtered_suggestions,
\ 'index(l:excluded_words, type(v:val) is type('''') ? v:val : v:val.word) < 0', \ 'index(l:excluded_words, type(v:val) is v:t_string ? v:val : v:val.word) < 0',
\) \)
endif endif
@ -315,10 +315,10 @@ function! ale#completion#ParseLSPCompletions(response) abort
let l:item_list = [] let l:item_list = []
if type(get(a:response, 'result')) is type([]) if type(get(a:response, 'result')) is v:t_list
let l:item_list = a:response.result let l:item_list = a:response.result
elseif type(get(a:response, 'result')) is type({}) elseif type(get(a:response, 'result')) is v:t_dict
\&& type(get(a:response.result, 'items')) is type([]) \&& type(get(a:response.result, 'items')) is v:t_list
let l:item_list = a:response.result.items let l:item_list = a:response.result.items
endif endif

View File

@ -40,9 +40,9 @@ function! ale#definition#HandleLSPResponse(conn_id, response) abort
" The result can be a Dictionary item, a List of the same, or null. " The result can be a Dictionary item, a List of the same, or null.
let l:result = get(a:response, 'result', v:null) let l:result = get(a:response, 'result', v:null)
if type(l:result) is type({}) if type(l:result) is v:t_dict
let l:result = [l:result] let l:result = [l:result]
elseif type(l:result) isnot type([]) elseif type(l:result) isnot v:t_list
let l:result = [] let l:result = []
endif endif

View File

@ -557,7 +557,7 @@ function! s:RunJob(options) abort
if get(g:, 'ale_run_synchronously') == 1 if get(g:, 'ale_run_synchronously') == 1
" Run a command synchronously if this test option is set. " Run a command synchronously if this test option is set.
let s:job_info_map[l:job_id].output = systemlist( let s:job_info_map[l:job_id].output = systemlist(
\ type(l:command) == type([]) \ type(l:command) is v:t_list
\ ? join(l:command[0:1]) . ' ' . ale#Escape(l:command[2]) \ ? join(l:command[0:1]) . ' ' . ale#Escape(l:command[2])
\ : l:command \ : l:command
\) \)

View File

@ -4,11 +4,11 @@
" Given a filetype and a configuration for ignoring linters, return a List of " Given a filetype and a configuration for ignoring linters, return a List of
" Strings for linter names to ignore. " Strings for linter names to ignore.
function! ale#engine#ignore#GetList(filetype, config) abort function! ale#engine#ignore#GetList(filetype, config) abort
if type(a:config) is type([]) if type(a:config) is v:t_list
return a:config return a:config
endif endif
if type(a:config) is type({}) if type(a:config) is v:t_dict
let l:names_to_remove = [] let l:names_to_remove = []
for l:part in split(a:filetype , '\.') for l:part in split(a:filetype , '\.')

View File

@ -275,7 +275,7 @@ function! s:RunJob(options) abort
if get(g:, 'ale_run_synchronously') == 1 if get(g:, 'ale_run_synchronously') == 1
" Run a command synchronously if this test option is set. " Run a command synchronously if this test option is set.
let l:output = systemlist( let l:output = systemlist(
\ type(l:command) == type([]) \ type(l:command) is v:t_list
\ ? join(l:command[0:1]) . ' ' . ale#Escape(l:command[2]) \ ? join(l:command[0:1]) . ' ' . ale#Escape(l:command[2])
\ : l:command \ : l:command
\) \)
@ -313,10 +313,10 @@ function! s:RunFixer(options) abort
\ : call(l:Function, [l:buffer, copy(l:input)]) \ : call(l:Function, [l:buffer, copy(l:input)])
endif endif
if type(l:result) == type(0) && l:result == 0 if type(l:result) is v:t_number && l:result == 0
" When `0` is returned, skip this item. " When `0` is returned, skip this item.
let l:index += 1 let l:index += 1
elseif type(l:result) == type([]) elseif type(l:result) is v:t_list
let l:input = l:result let l:input = l:result
let l:index += 1 let l:index += 1
else else
@ -351,9 +351,9 @@ function! s:RunFixer(options) abort
endfunction endfunction
function! s:AddSubCallbacks(full_list, callbacks) abort function! s:AddSubCallbacks(full_list, callbacks) abort
if type(a:callbacks) == type('') if type(a:callbacks) is v:t_string
call add(a:full_list, a:callbacks) call add(a:full_list, a:callbacks)
elseif type(a:callbacks) == type([]) elseif type(a:callbacks) is v:t_list
call extend(a:full_list, a:callbacks) call extend(a:full_list, a:callbacks)
else else
return 0 return 0
@ -365,7 +365,7 @@ endfunction
function! s:GetCallbacks(buffer, fixers) abort function! s:GetCallbacks(buffer, fixers) abort
if len(a:fixers) if len(a:fixers)
let l:callback_list = a:fixers let l:callback_list = a:fixers
elseif type(get(b:, 'ale_fixers')) is type([]) elseif type(get(b:, 'ale_fixers')) is v:t_list
" Lists can be used for buffer-local variables only " Lists can be used for buffer-local variables only
let l:callback_list = b:ale_fixers let l:callback_list = b:ale_fixers
else else
@ -396,7 +396,7 @@ function! s:GetCallbacks(buffer, fixers) abort
" Variables with capital characters are needed, or Vim will complain about " Variables with capital characters are needed, or Vim will complain about
" funcref variables. " funcref variables.
for l:Item in l:callback_list for l:Item in l:callback_list
if type(l:Item) == type('') if type(l:Item) is v:t_string
let l:Func = ale#fix#registry#GetFunc(l:Item) let l:Func = ale#fix#registry#GetFunc(l:Item)
if !empty(l:Func) if !empty(l:Func)

View File

@ -245,32 +245,32 @@ function! ale#fix#registry#Add(name, func, filetypes, desc, ...) abort
" This command will throw from the sandbox. " This command will throw from the sandbox.
let &equalprg=&equalprg let &equalprg=&equalprg
if type(a:name) != type('') if type(a:name) isnot v:t_string
throw '''name'' must be a String' throw '''name'' must be a String'
endif endif
if type(a:func) != type('') if type(a:func) isnot v:t_string
throw '''func'' must be a String' throw '''func'' must be a String'
endif endif
if type(a:filetypes) != type([]) if type(a:filetypes) isnot v:t_list
throw '''filetypes'' must be a List' throw '''filetypes'' must be a List'
endif endif
for l:type in a:filetypes for l:type in a:filetypes
if type(l:type) != type('') if type(l:type) isnot v:t_string
throw 'Each entry of ''filetypes'' must be a String' throw 'Each entry of ''filetypes'' must be a String'
endif endif
endfor endfor
if type(a:desc) != type('') if type(a:desc) isnot v:t_string
throw '''desc'' must be a String' throw '''desc'' must be a String'
endif endif
let l:aliases = get(a:000, 0, []) let l:aliases = get(a:000, 0, [])
if type(l:aliases) != type([]) if type(l:aliases) isnot v:t_list
\|| !empty(filter(copy(l:aliases), 'type(v:val) != type('''')')) \|| !empty(filter(copy(l:aliases), 'type(v:val) isnot v:t_string'))
throw '''aliases'' must be a List of String values' throw '''aliases'' must be a List of String values'
endif endif

View File

@ -32,7 +32,7 @@ function! ale#handlers#rust#HandleRustErrors(buffer, lines) abort
let l:error = json_decode(l:errorline) let l:error = json_decode(l:errorline)
if has_key(l:error, 'message') && type(l:error.message) == type({}) if has_key(l:error, 'message') && type(l:error.message) is v:t_dict
let l:error = l:error.message let l:error = l:error.message
endif endif

View File

@ -63,19 +63,19 @@ function! ale#hover#HandleLSPResponse(conn_id, response) abort
let l:result = l:result.contents let l:result = l:result.contents
if type(l:result) is type('') if type(l:result) is v:t_string
" The result can be just a string. " The result can be just a string.
let l:result = [l:result] let l:result = [l:result]
endif endif
if type(l:result) is type({}) if type(l:result) is v:t_dict
" If the result is an object, then it's markup content. " If the result is an object, then it's markup content.
let l:result = [l:result.value] let l:result = [l:result.value]
endif endif
if type(l:result) is type([]) if type(l:result) is v:t_list
" Replace objects with text values. " Replace objects with text values.
call map(l:result, 'type(v:val) is type('''') ? v:val : v:val.value') call map(l:result, 'type(v:val) is v:t_string ? v:val : v:val.value')
let l:str = join(l:result, "\n") let l:str = join(l:result, "\n")
let l:str = substitute(l:str, '^\s*\(.\{-}\)\s*$', '\1', '') let l:str = substitute(l:str, '^\s*\(.\{-}\)\s*$', '\1', '')

View File

@ -57,11 +57,11 @@ function! ale#linter#GetLintersLoaded() abort
endfunction endfunction
function! s:IsCallback(value) abort function! s:IsCallback(value) abort
return type(a:value) == type('') || type(a:value) == type(function('type')) return type(a:value) is v:t_string || type(a:value) is v:t_func
endfunction endfunction
function! s:IsBoolean(value) abort function! s:IsBoolean(value) abort
return type(a:value) == type(0) && (a:value == 0 || a:value == 1) return type(a:value) is v:t_number && (a:value == 0 || a:value == 1)
endfunction endfunction
function! s:LanguageGetter(buffer) dict abort function! s:LanguageGetter(buffer) dict abort
@ -69,7 +69,7 @@ function! s:LanguageGetter(buffer) dict abort
endfunction endfunction
function! ale#linter#PreProcess(filetype, linter) abort function! ale#linter#PreProcess(filetype, linter) abort
if type(a:linter) != type({}) if type(a:linter) isnot v:t_dict
throw 'The linter object must be a Dictionary' throw 'The linter object must be a Dictionary'
endif endif
@ -79,7 +79,7 @@ function! ale#linter#PreProcess(filetype, linter) abort
\ 'lsp': get(a:linter, 'lsp', ''), \ 'lsp': get(a:linter, 'lsp', ''),
\} \}
if type(l:obj.name) != type('') if type(l:obj.name) isnot v:t_string
throw '`name` must be defined to name the linter' throw '`name` must be defined to name the linter'
endif endif
@ -114,7 +114,7 @@ function! ale#linter#PreProcess(filetype, linter) abort
elseif has_key(a:linter, 'executable') elseif has_key(a:linter, 'executable')
let l:obj.executable = a:linter.executable let l:obj.executable = a:linter.executable
if type(l:obj.executable) != type('') if type(l:obj.executable) isnot v:t_string
throw '`executable` must be a string if defined' throw '`executable` must be a string if defined'
endif endif
else else
@ -130,7 +130,7 @@ function! ale#linter#PreProcess(filetype, linter) abort
elseif has_key(a:linter, 'command_chain') elseif has_key(a:linter, 'command_chain')
let l:obj.command_chain = a:linter.command_chain let l:obj.command_chain = a:linter.command_chain
if type(l:obj.command_chain) != type([]) if type(l:obj.command_chain) isnot v:t_list
throw '`command_chain` must be a List' throw '`command_chain` must be a List'
endif endif
@ -148,7 +148,7 @@ function! ale#linter#PreProcess(filetype, linter) abort
endif endif
if has_key(l:link, 'output_stream') if has_key(l:link, 'output_stream')
if type(l:link.output_stream) != type('') if type(l:link.output_stream) isnot v:t_string
\|| index(['stdout', 'stderr', 'both'], l:link.output_stream) < 0 \|| index(['stdout', 'stderr', 'both'], l:link.output_stream) < 0
throw l:err_prefix . '`output_stream` flag must be ' throw l:err_prefix . '`output_stream` flag must be '
\ . "'stdout', 'stderr', or 'both'" \ . "'stdout', 'stderr', or 'both'"
@ -170,7 +170,7 @@ function! ale#linter#PreProcess(filetype, linter) abort
elseif has_key(a:linter, 'command') elseif has_key(a:linter, 'command')
let l:obj.command = a:linter.command let l:obj.command = a:linter.command
if type(l:obj.command) != type('') if type(l:obj.command) isnot v:t_string
throw '`command` must be a string if defined' throw '`command` must be a string if defined'
endif endif
else else
@ -217,7 +217,7 @@ function! ale#linter#PreProcess(filetype, linter) abort
" Default to using the filetype as the language. " Default to using the filetype as the language.
let l:obj.language = get(a:linter, 'language', a:filetype) let l:obj.language = get(a:linter, 'language', a:filetype)
if type(l:obj.language) != type('') if type(l:obj.language) isnot v:t_string
throw '`language` must be a string' throw '`language` must be a string'
endif endif
@ -257,7 +257,7 @@ function! ale#linter#PreProcess(filetype, linter) abort
let l:obj.output_stream = get(a:linter, 'output_stream', 'stdout') let l:obj.output_stream = get(a:linter, 'output_stream', 'stdout')
if type(l:obj.output_stream) != type('') if type(l:obj.output_stream) isnot v:t_string
\|| index(['stdout', 'stderr', 'both'], l:obj.output_stream) < 0 \|| index(['stdout', 'stderr', 'both'], l:obj.output_stream) < 0
throw "`output_stream` must be 'stdout', 'stderr', or 'both'" throw "`output_stream` must be 'stdout', 'stderr', or 'both'"
endif endif
@ -283,8 +283,8 @@ function! ale#linter#PreProcess(filetype, linter) abort
let l:obj.aliases = get(a:linter, 'aliases', []) let l:obj.aliases = get(a:linter, 'aliases', [])
if type(l:obj.aliases) != type([]) if type(l:obj.aliases) isnot v:t_list
\|| len(filter(copy(l:obj.aliases), 'type(v:val) != type('''')')) > 0 \|| len(filter(copy(l:obj.aliases), 'type(v:val) isnot v:t_string')) > 0
throw '`aliases` must be a List of String values' throw '`aliases` must be a List of String values'
endif endif
@ -336,7 +336,7 @@ function! s:GetAliasedFiletype(original_filetype) abort
let l:buffer_aliases = get(b:, 'ale_linter_aliases', {}) let l:buffer_aliases = get(b:, 'ale_linter_aliases', {})
" b:ale_linter_aliases can be set to a List. " b:ale_linter_aliases can be set to a List.
if type(l:buffer_aliases) is type([]) if type(l:buffer_aliases) is v:t_list
return l:buffer_aliases return l:buffer_aliases
endif endif
@ -360,7 +360,7 @@ endfunction
function! ale#linter#ResolveFiletype(original_filetype) abort function! ale#linter#ResolveFiletype(original_filetype) abort
let l:filetype = s:GetAliasedFiletype(a:original_filetype) let l:filetype = s:GetAliasedFiletype(a:original_filetype)
if type(l:filetype) != type([]) if type(l:filetype) isnot v:t_list
return [l:filetype] return [l:filetype]
endif endif
@ -376,7 +376,7 @@ function! s:GetLinterNames(original_filetype) abort
endif endif
" b:ale_linters can be set to a List. " b:ale_linters can be set to a List.
if type(l:buffer_ale_linters) is type([]) if type(l:buffer_ale_linters) is v:t_list
return l:buffer_ale_linters return l:buffer_ale_linters
endif endif
@ -414,9 +414,9 @@ function! ale#linter#Get(original_filetypes) abort
let l:all_linters = ale#linter#GetAll(l:filetype) let l:all_linters = ale#linter#GetAll(l:filetype)
let l:filetype_linters = [] let l:filetype_linters = []
if type(l:linter_names) == type('') && l:linter_names is# 'all' if type(l:linter_names) is v:t_string && l:linter_names is# 'all'
let l:filetype_linters = l:all_linters let l:filetype_linters = l:all_linters
elseif type(l:linter_names) == type([]) elseif type(l:linter_names) is v:t_list
" Select only the linters we or the user has specified. " Select only the linters we or the user has specified.
for l:linter in l:all_linters for l:linter in l:all_linters
let l:name_list = [l:linter.name] + l:linter.aliases let l:name_list = [l:linter.name] + l:linter.aliases

View File

@ -213,7 +213,7 @@ endfunction
" Update capabilities from the server, so we know which features the server " Update capabilities from the server, so we know which features the server
" supports. " supports.
function! s:UpdateCapabilities(conn, capabilities) abort function! s:UpdateCapabilities(conn, capabilities) abort
if type(a:capabilities) != type({}) if type(a:capabilities) isnot v:t_dict
return return
endif endif
@ -229,10 +229,10 @@ function! s:UpdateCapabilities(conn, capabilities) abort
let a:conn.capabilities.completion = 1 let a:conn.capabilities.completion = 1
endif endif
if type(get(a:capabilities, 'completionProvider')) is type({}) if type(get(a:capabilities, 'completionProvider')) is v:t_dict
let l:chars = get(a:capabilities.completionProvider, 'triggerCharacters') let l:chars = get(a:capabilities.completionProvider, 'triggerCharacters')
if type(l:chars) is type([]) if type(l:chars) is v:t_list
let a:conn.capabilities.completion_trigger_characters = l:chars let a:conn.capabilities.completion_trigger_characters = l:chars
endif endif
endif endif
@ -275,7 +275,7 @@ function! ale#lsp#HandleOtherInitializeResponses(conn, response) abort
endfunction endfunction
function! ale#lsp#HandleMessage(conn, message) abort function! ale#lsp#HandleMessage(conn, message) abort
if type(a:message) != type('') if type(a:message) isnot v:t_string
" Ignore messages that aren't strings. " Ignore messages that aren't strings.
return return
endif endif
@ -548,7 +548,7 @@ function! ale#lsp#WaitForCapability(conn_id, project_root, capability, callback)
return 0 return 0
endif endif
if type(get(l:conn.capabilities, a:capability, v:null)) isnot type(0) if type(get(l:conn.capabilities, a:capability, v:null)) isnot v:t_number
throw 'Invalid capability ' . a:capability throw 'Invalid capability ' . a:capability
endif endif

View File

@ -88,7 +88,7 @@ function! ale#lsp#response#ReadTSServerDiagnostics(response) abort
endfunction endfunction
function! ale#lsp#response#GetErrorMessage(response) abort function! ale#lsp#response#GetErrorMessage(response) abort
if type(get(a:response, 'error', 0)) isnot type({}) if type(get(a:response, 'error', 0)) isnot v:t_dict
return '' return ''
endif endif
@ -108,12 +108,12 @@ function! ale#lsp#response#GetErrorMessage(response) abort
" Include the traceback or error data as details, if present. " Include the traceback or error data as details, if present.
let l:error_data = get(a:response.error, 'data', {}) let l:error_data = get(a:response.error, 'data', {})
if type(l:error_data) is type('') if type(l:error_data) is v:t_string
let l:message .= "\n" . l:error_data let l:message .= "\n" . l:error_data
else else
let l:traceback = get(l:error_data, 'traceback', []) let l:traceback = get(l:error_data, 'traceback', [])
if type(l:traceback) is type([]) && !empty(l:traceback) if type(l:traceback) is v:t_list && !empty(l:traceback)
let l:message .= "\n" . join(l:traceback, "\n") let l:message .= "\n" . join(l:traceback, "\n")
endif endif
endif endif

View File

@ -211,7 +211,7 @@ function! s:BuildSignMap(buffer, current_sign_list, grouped_items) abort
if l:max_signs is 0 if l:max_signs is 0
let l:selected_grouped_items = [] let l:selected_grouped_items = []
elseif type(l:max_signs) is type(0) && l:max_signs > 0 elseif type(l:max_signs) is v:t_number && l:max_signs > 0
let l:selected_grouped_items = a:grouped_items[:l:max_signs - 1] let l:selected_grouped_items = a:grouped_items[:l:max_signs - 1]
else else
let l:selected_grouped_items = a:grouped_items let l:selected_grouped_items = a:grouped_items

View File

@ -79,7 +79,7 @@ function! ale#util#GetLineCount(buffer) abort
endfunction endfunction
function! ale#util#GetFunction(string_or_ref) abort function! ale#util#GetFunction(string_or_ref) abort
if type(a:string_or_ref) == type('') if type(a:string_or_ref) is v:t_string
return function(a:string_or_ref) return function(a:string_or_ref)
endif endif
@ -303,8 +303,8 @@ endfunction
" Only the first pattern which matches a line will be returned. " Only the first pattern which matches a line will be returned.
function! ale#util#GetMatches(lines, patterns) abort function! ale#util#GetMatches(lines, patterns) abort
let l:matches = [] let l:matches = []
let l:lines = type(a:lines) == type([]) ? a:lines : [a:lines] let l:lines = type(a:lines) is v:t_list ? a:lines : [a:lines]
let l:patterns = type(a:patterns) == type([]) ? a:patterns : [a:patterns] let l:patterns = type(a:patterns) is v:t_list ? a:patterns : [a:patterns]
for l:line in l:lines for l:line in l:lines
for l:pattern in l:patterns for l:pattern in l:patterns
@ -382,7 +382,7 @@ function! ale#util#FuzzyJSONDecode(data, default) abort
return a:default return a:default
endif endif
let l:str = type(a:data) == type('') ? a:data : join(a:data, '') let l:str = type(a:data) is v:t_string ? a:data : join(a:data, '')
try try
let l:result = json_decode(l:str) let l:result = json_decode(l:str)

View File

@ -78,6 +78,17 @@ if (( FIX_ERRORS )); then
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
sed -i 's/!=?/isnot?/g' "$directory"/**/*.vim sed -i 's/!=?/isnot?/g' "$directory"/**/*.vim
# Improving type checks.
sed -i $'s/\\(==.\\?\\|is\\) type([\'"]\+)/is v:t_string/g' "$directory"/**/*.vim
sed -i 's/\(==.\?\|is\) type([0-9]\+)/is v:t_number/g' "$directory"/**/*.vim
sed -i 's/\(==.\?\|is\) type(\[\])/is v:t_list/g' "$directory"/**/*.vim
sed -i 's/\(==.\?\|is\) type({})/is v:t_dict/g' "$directory"/**/*.vim
sed -i 's/\(==.\?\|is\) type(function([^)]\+))/is v:t_func/g' "$directory"/**/*.vim
sed -i $'s/\\(!=.\\?\\|isnot\\) type([\'"]\+)/isnot v:t_string/g' "$directory"/**/*.vim
sed -i 's/\(!=.\?\|isnot\) type([0-9]\+)/isnot v:t_number/g' "$directory"/**/*.vim
sed -i 's/\(!=.\?\|isnot\) type(\[\])/isnot v:t_list/g' "$directory"/**/*.vim
sed -i 's/\(!=.\?\|isnot\) type({})/isnot v:t_dict/g' "$directory"/**/*.vim
sed -i 's/\(!=.\?\|isnot\) type(function([^)]\+))/isnot v:t_func/g' "$directory"/**/*.vim
done done
fi fi
@ -103,5 +114,16 @@ 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" check_errors '^ *:\?echo' "Stray echo line. Use \`execute echo\` if you want to echo something"
check_errors $'name.:.*\'[a-z_]*[^a-z_0-9][a-z_0-9]*\',$' 'Use snake_case names for linters' '*/ale_linters/*' check_errors $'name.:.*\'[a-z_]*[^a-z_0-9][a-z_0-9]*\',$' 'Use snake_case names for linters' '*/ale_linters/*'
# Checks for improving type checks.
check_errors $'\\(==.\\?\\|is\\) type([\'"]\+)' "Use 'is v:t_string' instead"
check_errors '\(==.\?\|is\) type([0-9]\+)' "Use 'is v:t_number' instead"
check_errors '\(==.\?\|is\) type(\[\])' "Use 'is v:t_list' instead"
check_errors '\(==.\?\|is\) type({})' "Use 'is v:t_dict' instead"
check_errors '\(==.\?\|is\) type(function([^)]\+))' "Use 'is v:t_func' instead"
check_errors $'\\(!=.\\?\\|isnot\\) type([\'"]\+)' "Use 'isnot v:t_string' instead"
check_errors '\(!=.\?\|isnot\) type([0-9]\+)' "Use 'isnot v:t_number' instead"
check_errors '\(!=.\?\|isnot\) type(\[\])' "Use 'isnot v:t_list' instead"
check_errors '\(!=.\?\|isnot\) type({})' "Use 'isnot v:t_dict' instead"
check_errors '\(!=.\?\|isnot\) type(function([^)]\+))' "Use 'isnot v:t_func' instead"
exit $RETURN_CODE exit $RETURN_CODE