Use ale#Pad for option padding across the codebase (#5118)

Standardize option padding by replacing verbose ternary checks with ale#Pad()

Replace patterns like:
(empty(x) ? '' : '' . l:options)

with:
ale#Pad(l:options)

Similar to af5a38c697
This commit is contained in:
Mathis
2026-04-10 16:12:53 +02:00
committed by GitHub
parent 6b63f4e70a
commit 674a8cced8
42 changed files with 43 additions and 43 deletions

View File

@@ -7,7 +7,7 @@ function! ale#fixers#alejandra#Fix(buffer) abort
return {
\ 'command': ale#Escape(l:executable)
\ . (empty(l:options) ? '' : ' ' . l:options)
\ . ale#Pad(l:options)
\ . ' -- -'
\}
endfunction

View File

@@ -12,7 +12,7 @@ function! ale#fixers#apkbuild_fixer#Fix(buffer) abort
return {
\ 'command': ale#Escape(l:executable)
\ . ' -p ' . ale#Var(a:buffer, 'apkbuild_apkbuild_fixer_lint_executable')
\ . (empty(l:options) ? '' : ' ' . l:options)
\ . ale#Pad(l:options)
\ . ' %t',
\ 'read_temporary_file': 1,
\}

View File

@@ -36,7 +36,7 @@ function! ale#fixers#clangtidy#GetCommand(buffer) abort
return ' -fix' . (l:fix_errors ? ' -fix-errors' : '')
\ . (empty(l:checks) ? '' : ' -checks=' . ale#Escape(l:checks))
\ . (empty(l:extra_options) ? '' : ' ' . l:extra_options)
\ . ale#Pad(l:extra_options)
\ . (empty(l:build_dir) ? '' : ' -p ' . ale#Escape(l:build_dir))
\ . ' %t' . (empty(l:options) ? '' : ' -- ' . l:options)
endfunction

View File

@@ -10,7 +10,7 @@ function! ale#fixers#cmakeformat#Fix(buffer) abort
return {
\ 'command': ale#Escape(l:executable)
\ . (empty(l:options) ? '' : ' ' . l:options)
\ . ale#Pad(l:options)
\ . ' -'
\}
endfunction

View File

@@ -11,7 +11,7 @@ function! ale#fixers#dart_format#Fix(buffer) abort
return {
\ 'command': ale#Escape(l:executable)
\ . ' format'
\ . (empty(l:options) ? '' : ' ' . l:options)
\ . ale#Pad(l:options)
\ . ' %t',
\ 'read_temporary_file': 1,
\}

View File

@@ -11,7 +11,7 @@ function! ale#fixers#dartfmt#Fix(buffer) abort
return {
\ 'command': ale#Escape(l:executable)
\ . ' -w'
\ . (empty(l:options) ? '' : ' ' . l:options)
\ . ale#Pad(l:options)
\ . ' %t',
\ 'read_temporary_file': 1,
\}

View File

@@ -11,7 +11,7 @@ function! ale#fixers#dfmt#Fix(buffer) abort
return {
\ 'command': ale#Escape(l:executable)
\ . ' -i'
\ . (empty(l:options) ? '' : ' ' . l:options)
\ . ale#Pad(l:options)
\ . ' %t',
\ 'read_temporary_file': 1,
\}

View File

@@ -11,7 +11,7 @@ function! ale#fixers#dotnet_format#Fix(buffer) abort
return {
\ 'command': ale#Escape(l:executable)
\ . ' format'
\ . (empty(l:options) ? '' : ' ' . l:options)
\ . ale#Pad(l:options)
\ . ' --folder --include %t "$(dirname %t)"',
\ 'read_temporary_file': 1,
\}

View File

@@ -11,6 +11,6 @@ function! ale#fixers#dune#Fix(buffer) abort
return {
\ 'command': ale#Escape(l:executable)
\ . ' format'
\ . (empty(l:options) ? '' : ' ' . l:options),
\ . ale#Pad(l:options),
\}
endfunction

View File

@@ -17,7 +17,7 @@ function! ale#fixers#elm_format#Fix(buffer) abort
return {
\ 'command': ale#Escape(ale#fixers#elm_format#GetExecutable(a:buffer))
\ . ' %t'
\ . (empty(l:options) ? '' : ' ' . l:options),
\ . ale#Pad(l:options),
\ 'read_temporary_file': 1,
\}
endfunction

View File

@@ -12,7 +12,7 @@ function! ale#fixers#fish_indent#Fix(buffer) abort
return {
\ 'command': ale#Escape(l:executable)
\ . ' -w '
\ . (empty(l:options) ? '' : ' ' . l:options)
\ . ale#Pad(l:options)
\ . ' %t',
\ 'read_temporary_file': 1,
\}

View File

@@ -13,7 +13,7 @@ function! ale#fixers#fourmolu#Fix(buffer) abort
return {
\ 'command': l:executable
\ . (empty(l:options) ? '' : ' ' . l:options)
\ . ale#Pad(l:options)
\ . ' --stdin-input-file '
\ . ale#Escape(@%),
\}

View File

@@ -11,6 +11,6 @@ function! ale#fixers#gofmt#Fix(buffer) abort
return {
\ 'command': l:env . ale#Escape(l:executable)
\ . (empty(l:options) ? '' : ' ' . l:options)
\ . ale#Pad(l:options)
\}
endfunction

View File

@@ -16,7 +16,7 @@ function! ale#fixers#goimports#Fix(buffer) abort
return {
\ 'command': l:env . ale#Escape(l:executable)
\ . ' -l -w -srcdir %s'
\ . (empty(l:options) ? '' : ' ' . l:options)
\ . ale#Pad(l:options)
\ . ' %t',
\ 'read_temporary_file': 1,
\}

View File

@@ -16,6 +16,6 @@ function! ale#fixers#golines#Fix(buffer) abort
return {
\ 'command': l:env . ale#Escape(l:executable)
\ . (empty(l:options) ? '' : ' ' . l:options)
\ . ale#Pad(l:options)
\}
endfunction

View File

@@ -15,7 +15,7 @@ function! ale#fixers#google_java_format#Fix(buffer) abort
return {
\ 'command': ale#Escape(l:executable)
\ . ' ' . (empty(l:options) ? '' : ' ' . l:options)
\ . ' ' . ale#Pad(l:options)
\ . ' --replace'
\ . ' %t',
\ 'read_temporary_file': 1,

View File

@@ -11,7 +11,7 @@ function! ale#fixers#hackfmt#Fix(buffer) abort
return {
\ 'command': ale#Escape(l:executable)
\ . ' -i'
\ . (empty(l:options) ? '' : ' ' . l:options)
\ . ale#Pad(l:options)
\ . ' %t',
\ 'read_temporary_file': 1,
\}

View File

@@ -11,6 +11,6 @@ function! ale#fixers#latexindent#Fix(buffer) abort
return {
\ 'command': ale#Escape(l:executable)
\ . ' -l'
\ . (empty(l:options) ? '' : ' ' . l:options)
\ . ale#Pad(l:options)
\}
endfunction

View File

@@ -7,7 +7,7 @@ function! ale#fixers#luafmt#Fix(buffer) abort
return {
\ 'command': ale#Escape(l:executable)
\ . (empty(l:options) ? '' : ' ' . l:options)
\ . ale#Pad(l:options)
\ . ' --stdin',
\}
endfunction

View File

@@ -10,7 +10,7 @@ function! ale#fixers#nickel_format#Fix(buffer) abort
return {
\ 'command': ale#Escape(l:executable) . ' format'
\ . (empty(l:options) ? '' : ' ' . l:options)
\ . ale#Pad(l:options)
\}
endfunction

View File

@@ -7,6 +7,6 @@ function! ale#fixers#nixpkgsfmt#Fix(buffer) abort
return {
\ 'command': ale#Escape(l:executable)
\ . (empty(l:options) ? '' : ' ' . l:options),
\ . ale#Pad(l:options),
\}
endfunction

View File

@@ -10,7 +10,7 @@ function! ale#fixers#ocamlformat#Fix(buffer) abort
return {
\ 'command': ale#Escape(l:executable)
\ . (empty(l:options) ? '' : ' ' . l:options)
\ . ale#Pad(l:options)
\ . ' --name=%s'
\ . ' -'
\}

View File

@@ -13,6 +13,6 @@ function! ale#fixers#ocp_indent#Fix(buffer) abort
return {
\ 'command': ale#Escape(l:executable)
\ . (empty(l:config) ? '' : ' --config=' . ale#Escape(l:config))
\ . (empty(l:options) ? '': ' ' . l:options)
\ . ale#Pad(l:options)
\}
endfunction

View File

@@ -10,6 +10,6 @@ function! ale#fixers#opafmt#Fix(buffer) abort
return {
\ 'command': ale#Escape(l:executable)
\ . ' fmt'
\ . (empty(l:options) ? '' : ' ' . l:options)
\ . ale#Pad(l:options)
\}
endfunction

View File

@@ -7,6 +7,6 @@ function! ale#fixers#ormolu#Fix(buffer) abort
return {
\ 'command': ale#Escape(l:executable)
\ . (empty(l:options) ? '' : ' ' . l:options),
\ . ale#Pad(l:options),
\}
endfunction

View File

@@ -11,7 +11,7 @@ function! ale#fixers#packer#Fix(buffer) abort
return {
\ 'command': ale#Escape(l:executable)
\ . ' fmt'
\ . (empty(l:options) ? '' : ' ' . l:options)
\ . ale#Pad(l:options)
\ . ' -'
\}
endfunction

View File

@@ -11,7 +11,7 @@ function! ale#fixers#perltidy#Fix(buffer) abort
return {
\ 'command': ale#Escape(l:executable)
\ . ' -b'
\ . (empty(l:options) ? '' : ' ' . l:options)
\ . ale#Pad(l:options)
\ . ' %t',
\ 'read_temporary_file': 1,
\}

View File

@@ -7,6 +7,6 @@ function! ale#fixers#pgformatter#Fix(buffer) abort
return {
\ 'command': ale#Escape(l:executable)
\ . (empty(l:options) ? '' : ' ' . l:options),
\ . ale#Pad(l:options),
\}
endfunction

View File

@@ -10,7 +10,7 @@ function! ale#fixers#ptop#Fix(buffer) abort
return {
\ 'command': ale#Escape(l:executable)
\ . (empty(l:options) ? '' : ' ' . l:options)
\ . ale#Pad(l:options)
\ . ' %s %t',
\ 'read_temporary_file': 1,
\}

View File

@@ -10,6 +10,6 @@ function! ale#fixers#raco_fmt#Fix(buffer) abort
return {
\ 'command': ale#Escape(l:executable) . ' fmt'
\ . (empty(l:options) ? '' : ' ' . l:options),
\ . ale#Pad(l:options),
\}
endfunction

View File

@@ -10,7 +10,7 @@ function! ale#fixers#refmt#Fix(buffer) abort
return {
\ 'command': ale#Escape(l:executable)
\ . (empty(l:options) ? '' : ' ' . l:options)
\ . ale#Pad(l:options)
\ . ' --in-place'
\ . ' %t',
\ 'read_temporary_file': 1,

View File

@@ -10,7 +10,7 @@ function! ale#fixers#rubyfmt#Fix(buffer) abort
return {
\ 'command': ale#Escape(l:executable)
\ . (empty(l:options) ? '' : ' ' . l:options)
\ . ale#Pad(l:options)
\}
endfunction

View File

@@ -10,6 +10,6 @@ function! ale#fixers#rustfmt#Fix(buffer) abort
return {
\ 'command': ale#Escape(l:executable)
\ . (empty(l:options) ? '' : ' ' . l:options),
\ . ale#Pad(l:options),
\}
endfunction

View File

@@ -11,7 +11,7 @@ function! ale#fixers#rustywind#Fix(buffer) abort
return {
\ 'command': ale#Escape(l:executable)
\ . (empty(l:options) ? '' : ' ' . l:options)
\ . ale#Pad(l:options)
\ . ' --stdin'
\}
endfunction

View File

@@ -10,6 +10,6 @@ function! ale#fixers#scadformat#Fix(buffer) abort
return {
\ 'command': ale#Escape(l:executable)
\ . (empty(l:options) ? '' : ' ' . l:options),
\ . ale#Pad(l:options),
\}
endfunction

View File

@@ -13,7 +13,7 @@ function! ale#fixers#scalafmt#GetCommand(buffer) abort
\ : ''
return ale#Escape(l:executable) . l:exec_args
\ . (empty(l:options) ? '' : ' ' . l:options)
\ . ale#Pad(l:options)
\ . ' %t'
endfunction

View File

@@ -12,6 +12,6 @@ function! ale#fixers#shfmt#Fix(buffer) abort
return {
\ 'command': ale#Escape(l:executable)
\ . ' -filename=%s'
\ . (empty(l:options) ? '' : ' ' . l:options)
\ . ale#Pad(l:options)
\}
endfunction

View File

@@ -8,6 +8,6 @@ function! ale#fixers#sqlfmt#Fix(buffer) abort
return {
\ 'command': ale#Escape(l:executable)
\ . ' -w'
\ . (empty(l:options) ? '' : ' ' . l:options),
\ . ale#Pad(l:options),
\}
endfunction

View File

@@ -11,7 +11,7 @@ function! ale#fixers#terraform#Fix(buffer) abort
return {
\ 'command': ale#Escape(l:executable)
\ . ' fmt'
\ . (empty(l:options) ? '' : ' ' . l:options)
\ . ale#Pad(l:options)
\ . ' -'
\}
endfunction

View File

@@ -8,7 +8,7 @@ function! ale#fixers#textlint#Fix(buffer) abort
return {
\ 'command': ale#Escape(l:executable)
\ . ' --fix'
\ . (empty(l:options) ? '' : ' ' . l:options)
\ . ale#Pad(l:options)
\ . ' %t',
\ 'read_temporary_file': 1,
\}

View File

@@ -11,8 +11,8 @@ function! ale#handlers#ktlint#GetCommand(buffer) abort
let l:rulesets = ale#handlers#ktlint#GetRulesets(a:buffer)
return ale#Escape(l:executable)
\ . (empty(l:options) ? '' : ' ' . l:options)
\ . (empty(l:rulesets) ? '' : ' ' . l:rulesets)
\ . ale#Pad(l:options)
\ . ale#Pad(l:rulesets)
\ . ' --stdin'
endfunction

View File

@@ -13,7 +13,7 @@ function! ale#handlers#languagetool#GetCommand(buffer) abort
let l:options = ale#Var(a:buffer, 'languagetool_options')
return ale#Escape(l:executable)
\ . (empty(l:options) ? '' : ' ' . l:options) . ' %s'
\ . ale#Pad(l:options) . ' %s'
endfunction
function! ale#handlers#languagetool#HandleOutput(buffer, lines) abort