Skip to content

Commit 2f4a866

Browse files
doc-sheetds
andauthored
Add initial support for named-checkzone linter (#4961)
Co-authored-by: ds <ds@local>
1 parent f9de268 commit 2f4a866

File tree

7 files changed

+126
-0
lines changed

7 files changed

+126
-0
lines changed

ale_linters/bindzone/checkzone.vim

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
" Description: named-checkzone for bindzone
2+
3+
call ale#Set('bindzone_checkzone_executable', 'named-checkzone')
4+
call ale#Set('bindzone_checkzone_options', '-c IN')
5+
6+
function! ale_linters#bindzone#checkzone#GetCommand(buffer) abort
7+
return '%e' . ale#Pad(ale#Var(a:buffer, 'bindzone_checkzone_options'))
8+
\ . ' example.com %t'
9+
endfunction
10+
11+
function! ale_linters#bindzone#checkzone#Handle(buffer, lines) abort
12+
let l:warning_pattern = '\vzone example.com/IN: (.+)$'
13+
let l:error_pattern = '\v:(\d+): (.+)$'
14+
let l:output = []
15+
16+
for l:match in ale#util#GetMatches(a:lines, l:error_pattern)
17+
let l:lnum = l:match[1]
18+
let l:text = l:match[2]
19+
20+
call add(l:output, {'text': l:text, 'lnum': l:lnum + 0, 'type': 'E'})
21+
endfor
22+
23+
for l:match in ale#util#GetMatches(a:lines, l:warning_pattern)
24+
let l:text = l:match[1]
25+
26+
" Ignore information messages
27+
let l:scrub_match = matchlist(l:text, '\v(loaded serial|not loaded due to) ')
28+
29+
if empty(l:scrub_match)
30+
call add(l:output, {'text': l:text, 'lnum': 0, 'type': 'W'})
31+
endif
32+
endfor
33+
34+
return l:output
35+
endfunction
36+
37+
call ale#linter#Define('bindzone', {
38+
\ 'name': 'checkzone',
39+
\ 'executable': {b -> ale#Var(b, 'bindzone_checkzone_executable')},
40+
\ 'command': function('ale_linters#bindzone#checkzone#GetCommand'),
41+
\ 'callback': 'ale_linters#bindzone#checkzone#Handle',
42+
\ 'read_buffer': 0,
43+
\})

doc/ale-bindzone.txt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
===============================================================================
2+
ALE BINDZone Integration *ale-bindzone-options*
3+
4+
===============================================================================
5+
checkzone *ale-bindzone-checkzone*
6+
7+
*ale-options.bindzone_checkzone_executable*
8+
*g:ale_bindzone_checkzone_executable*
9+
*b:ale_bindzone_checkzone_executable*
10+
bindzone_checkzone_executable
11+
g:ale_bindzone_checkzone_executable
12+
Type: |String|
13+
Default: `named-checkzone`
14+
15+
This variable can be changed to set the path to named-checkzone executable.
16+
17+
*ale-options.bindzone_checkzone_options*
18+
*g:ale_bindzone_checkzone_options*
19+
*b:ale_bindzone_checkzone_options*
20+
bindzone_checkzone_options
21+
g:ale_bindzone_checkzone_options
22+
Type: |String|
23+
Default: `-c IN`
24+
25+
This variable can be changed to add additional command-line arguments.
26+
All available options can be found at:
27+
28+
https://bind9.readthedocs.io/en/stable/manpages.html#named-checkzone-zone-file-validation-tool
29+
30+
31+
===============================================================================
32+
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:

doc/ale-supported-languages-and-tools.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ Notes:
6060
* `bibclean`
6161
* Bicep
6262
* `bicep`
63+
* Bindzone
64+
* `checkzone` (named-checkzone)
6365
* BitBake
6466
* `oelint-adv`
6567
* Bourne Shell

doc/ale.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3361,6 +3361,8 @@ documented in additional help files.
33613361
bicep...................................|ale-bicep-options|
33623362
bicep.................................|ale-bicep-bicep|
33633363
az_bicep..............................|ale-bicep-az_bicep|
3364+
bindzone................................|ale-bindzone-options|
3365+
checkzone.............................|ale-bindzone-checkzone|
33643366
bitbake.................................|ale-bitbake-options|
33653367
oelint-adv............................|ale-bitbake-oelint_adv|
33663368
c.......................................|ale-c-options|

supported-tools.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ formatting.
6969
* [bibclean](http://ftp.math.utah.edu/pub/bibclean/)
7070
* Bicep
7171
* [bicep](https://github.com/Azure/bicep) :floppy_disk:
72+
* Bindzone
73+
* [checkzone](https://bind9.readthedocs.io/en/stable/manpages.html#named-checkzone-zone-file-validation-tool)
7274
* BitBake
7375
* [oelint-adv](https://github.com/priv-kweihmann/oelint-adv)
7476
* Bourne Shell
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
Before:
2+
runtime ale_linters/bindzone/checkzone.vim
3+
4+
After:
5+
call ale#linter#Reset()
6+
7+
Execute(The checkzone handler should handle basic warnings):
8+
AssertEqual
9+
\ [
10+
\ {
11+
\ 'lnum': 2,
12+
\ 'type': 'E',
13+
\ 'text': 'unknown RR type ''fasd''',
14+
\ },
15+
\ {
16+
\ 'lnum': 0,
17+
\ 'type': 'W',
18+
\ 'text': '_some_srv._tcp.example.com/SRV ''some.example.com'' (out of zone) has no addresses records (A or AAAA)',
19+
\ },
20+
\ ],
21+
\ ale_linters#bindzone#checkzone#Handle(1, [
22+
\ 'zone example.com/IN: _some_srv._tcp.example.com/SRV ''some.example.com'' (out of zone) has no addresses records (A or AAAA)',
23+
\ 'zone example.com/IN: loaded serial 2025050400',
24+
\ 'zone example.com/IN: not loaded due to errors',
25+
\ '/tmp/vb3wXsu/2/example.com:2: unknown RR type ''fasd''',
26+
\ ])
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Before:
2+
call ale#assert#SetUpLinterTest('bindzone', 'checkzone')
3+
4+
After:
5+
call ale#assert#TearDownLinterTest()
6+
7+
Execute(The default command should be correct):
8+
AssertLinter 'named-checkzone',
9+
\ ale#Escape('named-checkzone') . ' -c IN example.com %t'
10+
11+
Execute(The default command should be overridden):
12+
let b:ale_bindzone_checkzone_executable = '/bin/bind9-checkzone'
13+
AssertLinter '/bin/bind9-checkzone',
14+
\ ale#Escape('/bin/bind9-checkzone') . ' -c IN example.com %t'
15+
16+
Execute(The default options should be overridden):
17+
let b:ale_bindzone_checkzone_options = '-c IN -d'
18+
AssertLinter 'named-checkzone',
19+
\ ale#Escape('named-checkzone') . ' -c IN -d example.com %t'

0 commit comments

Comments
 (0)