mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-06 04:34:25 +08:00
Implement support for apkbuild-fixer (#4881)
I am not the author of a single file, but have full permissions from the original author for permission for submitting this to ALE under the 2-Clause BSD licence. See: https://gitlab.alpinelinux.org/Leo/apkbuild.vim/-/issues/3
This commit is contained in:
@@ -17,6 +17,11 @@ let s:default_registry = {
|
||||
\ 'suggested_filetypes': ['help'],
|
||||
\ 'description': 'Align help tags to the right margin',
|
||||
\ },
|
||||
\ 'apkbuild-fixer': {
|
||||
\ 'function': 'ale#fixers#apkbuild_fixer#Fix',
|
||||
\ 'suggested_filetypes': ['apkbuild'],
|
||||
\ 'description': 'Fix policy violations found by apkbuild-lint in APKBUILDs',
|
||||
\ },
|
||||
\ 'autoimport': {
|
||||
\ 'function': 'ale#fixers#autoimport#Fix',
|
||||
\ 'suggested_filetypes': ['python'],
|
||||
|
||||
19
autoload/ale/fixers/apkbuild_fixer.vim
Normal file
19
autoload/ale/fixers/apkbuild_fixer.vim
Normal file
@@ -0,0 +1,19 @@
|
||||
" Author: Leo <thinkabit.ukim@gmail.com>
|
||||
" Description: Fix policy violations found by apkbuild-lint
|
||||
|
||||
call ale#Set('apkbuild_apkbuild_fixer_executable', 'apkbuild-fixer')
|
||||
call ale#Set('apkbuild_apkbuild_fixer_lint_executable', get(g:, 'ale_apkbuild_apkbuild_lint_executable'))
|
||||
call ale#Set('apkbuild_apkbuild_fixer_options', '')
|
||||
|
||||
function! ale#fixers#apkbuild_fixer#Fix(buffer) abort
|
||||
let l:executable = ale#Var(a:buffer, 'apkbuild_apkbuild_fixer_executable')
|
||||
let l:options = ale#Var(a:buffer, 'apkbuild_apkbuild_fixer_options')
|
||||
|
||||
return {
|
||||
\ 'command': ale#Escape(l:executable)
|
||||
\ . ' -p ' . ale#Var(a:buffer, 'apkbuild_apkbuild_fixer_lint_executable')
|
||||
\ . (empty(l:options) ? '' : ' ' . l:options)
|
||||
\ . ' %t',
|
||||
\ 'read_temporary_file': 1,
|
||||
\}
|
||||
endfunction
|
||||
@@ -2,10 +2,41 @@
|
||||
ALE APKBUILD Integration *ale-apkbuild-options*
|
||||
|
||||
|
||||
===============================================================================
|
||||
apkbuild-fixer *ale-apkbuild-apkbuild-fixer*
|
||||
|
||||
g:apkbuild_apkbuild_fixer_options *g:apkbuild_apkbuild_fixer_options*
|
||||
*b:apkbuild_apkbuild_fixer_options*
|
||||
Type: |String|
|
||||
Default: `''`
|
||||
|
||||
This variable can be set to pass additional options to the apkbuild_fixer
|
||||
fixer.
|
||||
|
||||
|
||||
g:apkbuild_apkbuild_fixer_executable *g:apkbuild_apkbuild_fixer_executable*
|
||||
*b:apkbuild_apkbuild_fixer_executable*
|
||||
Type: |String|
|
||||
Default: `'apkbuild-fixer'`
|
||||
|
||||
This variable can be modified to change the executable path for
|
||||
`apkbuild-fixer`.
|
||||
|
||||
|
||||
g:apkbuild_apkbuild_fixer_lint_executable
|
||||
*g:apkbuild_apkbuild_fixer_lint_executable*
|
||||
*b:apkbuild_apkbuild_fixer_lint_executable*
|
||||
Type: |String|
|
||||
Default: `'apkbuild-fixer'`
|
||||
|
||||
This variable can be modified to change the executable path for
|
||||
`apkbuild-lint`, the binary used to find violations.
|
||||
|
||||
|
||||
===============================================================================
|
||||
apkbuild-lint *ale-apkbuild-apkbuild-lint*
|
||||
|
||||
g:ale_apkbuild_apkbuild_lint_executable
|
||||
g:ale_apkbuild_apkbuild_lint_executable
|
||||
*g:ale_apkbuild_apkbuild_lint_executable*
|
||||
*b:ale_apkbuild_apkbuild_lint_executable*
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ Notes:
|
||||
* API Blueprint
|
||||
* `drafter`
|
||||
* APKBUILD
|
||||
* `apkbuild-fixer`
|
||||
* `apkbuild-lint`
|
||||
* `secfixes-check`
|
||||
* AsciiDoc
|
||||
|
||||
@@ -2898,6 +2898,7 @@ documented in additional help files.
|
||||
ansible-language-server...............|ale-ansible-language-server|
|
||||
ansible-lint..........................|ale-ansible-ansible-lint|
|
||||
apkbuild................................|ale-apkbuild-options|
|
||||
apkbuild-fixer........................|ale-apkbuild-apkbuild-fixer|
|
||||
apkbuild-lint.........................|ale-apkbuild-apkbuild-lint|
|
||||
secfixes-check........................|ale-apkbuild-secfixes-check|
|
||||
asciidoc................................|ale-asciidoc-options|
|
||||
|
||||
@@ -32,6 +32,7 @@ formatting.
|
||||
* API Blueprint
|
||||
* [drafter](https://github.com/apiaryio/drafter)
|
||||
* APKBUILD
|
||||
* [apkbuild-fixer](https://gitlab.alpinelinux.org/Leo/atools)
|
||||
* [apkbuild-lint](https://gitlab.alpinelinux.org/Leo/atools)
|
||||
* [secfixes-check](https://gitlab.alpinelinux.org/Leo/atools)
|
||||
* AsciiDoc
|
||||
|
||||
20
test/fixers/test_apkbuild_fixer_callback.vader
Normal file
20
test/fixers/test_apkbuild_fixer_callback.vader
Normal file
@@ -0,0 +1,20 @@
|
||||
Before:
|
||||
call ale#assert#SetUpFixerTest('apkbuild', 'apkbuild-fixer')
|
||||
|
||||
After:
|
||||
call ale#assert#TearDownFixerTest()
|
||||
|
||||
Execute(The apkbuild-fixer callback should return the correct default values):
|
||||
AssertFixer {
|
||||
\ 'read_temporary_file': 1,
|
||||
\ 'command': ale#Escape('apkbuild-fixer') . ' -p apkbuild-lint %t',
|
||||
\}
|
||||
|
||||
Execute(The apkbuild-fixer callback should include custom apkbuild-fixer options):
|
||||
let g:ale_apkbuild_apkbuild_fixer_executable = "another-apkbuild-fixer"
|
||||
let g:ale_apkbuild_apkbuild_fixer_options = "-s"
|
||||
|
||||
AssertFixer {
|
||||
\ 'read_temporary_file': 1,
|
||||
\ 'command': ale#Escape('another-apkbuild-fixer') . ' -p apkbuild-lint -s %t'
|
||||
\}
|
||||
Reference in New Issue
Block a user