summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2021-03-14 23:34:38 +0000
committerw0rp <devw0rp@gmail.com>2021-03-14 23:34:38 +0000
commitf43e4abc8872a10519309d78f44ad2fc276ad596 (patch)
treeaf7d8f7b161ded500fc3698d02ea97d5b49d3793
parentb45ee8ec6c760089c68fb28a5436ec8275ca5381 (diff)
downloadale-f43e4abc8872a10519309d78f44ad2fc276ad596.zip
Check user systemd unit files with systemd-analyze
-rw-r--r--ale_linters/systemd/systemd_analyze.vim25
-rw-r--r--doc/ale-supported-languages-and-tools.txt7
-rw-r--r--doc/ale-systemd.txt14
-rw-r--r--doc/ale.txt2
-rw-r--r--supported-tools.md2
-rw-r--r--test/command_callback/test_systemd_analyze_command_callback.vader9
-rw-r--r--test/handler/test_systemd_analyze_hander.vader19
7 files changed, 77 insertions, 1 deletions
diff --git a/ale_linters/systemd/systemd_analyze.vim b/ale_linters/systemd/systemd_analyze.vim
new file mode 100644
index 00000000..7e8bba2f
--- /dev/null
+++ b/ale_linters/systemd/systemd_analyze.vim
@@ -0,0 +1,25 @@
+function! ale_linters#systemd#systemd_analyze#Handle(buffer, lines) abort
+ let l:re = '\v(.+):([0-9]+): (.+)'
+ let l:output = []
+
+ for l:match in ale#util#GetMatches(a:lines, l:re)
+ call add(l:output, {
+ \ 'lnum': str2nr(l:match[2]),
+ \ 'col': 1,
+ \ 'type': 'W',
+ \ 'text': l:match[3],
+ \})
+ endfor
+
+ return l:output
+endfunction
+
+call ale#linter#Define('systemd', {
+\ 'name': 'systemd_analyze',
+\ 'aliases': ['systemd-analyze'],
+\ 'executable': 'systemd-analyze',
+\ 'command': 'SYSTEMD_LOG_COLOR=0 %e --user verify %s',
+\ 'callback': 'ale_linters#systemd#systemd_analyze#Handle',
+\ 'output_stream': 'both',
+\ 'lint_file': 1,
+\})
diff --git a/doc/ale-supported-languages-and-tools.txt b/doc/ale-supported-languages-and-tools.txt
index cc25ca95..2e7d2f77 100644
--- a/doc/ale-supported-languages-and-tools.txt
+++ b/doc/ale-supported-languages-and-tools.txt
@@ -167,7 +167,7 @@ Notes:
* Git Commit Messages
* `gitlint`
* GLSL
- * glslang
+ * `glslang`
* `glslls`
* Go
* `bingo`
@@ -492,6 +492,8 @@ Notes:
* `sourcekit-lsp`
* `swiftformat`
* `swiftlint`
+* systemd
+ * `systemd-analyze`!!
* Tcl
* `nagelfar`!!
* Terraform
@@ -562,3 +564,6 @@ Notes:
* `yang-lsp`
* Zig
* `zls`
+
+===============================================================================
+ vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
diff --git a/doc/ale-systemd.txt b/doc/ale-systemd.txt
new file mode 100644
index 00000000..13c7037f
--- /dev/null
+++ b/doc/ale-systemd.txt
@@ -0,0 +1,14 @@
+===============================================================================
+ALE systemd Integration *ale-systemd-options*
+
+
+===============================================================================
+systemd-analyze *ale-systemd-analyze*
+
+ALE supports checking user systemd units with `systemd-analyze --user verify`
+Checks will only work with user unit files in their proper location. There
+aren't any options, and checks can only run after saving the file.
+
+
+===============================================================================
+ vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
diff --git a/doc/ale.txt b/doc/ale.txt
index 66b2e4ce..36e02d54 100644
--- a/doc/ale.txt
+++ b/doc/ale.txt
@@ -3010,6 +3010,8 @@ documented in additional help files.
stylelint.............................|ale-sugarss-stylelint|
swift...................................|ale-swift-options|
sourcekitlsp..........................|ale-swift-sourcekitlsp|
+ systemd.................................|ale-systemd-options|
+ systemd-analyze.......................|ale-systemd-analyze|
tcl.....................................|ale-tcl-options|
nagelfar..............................|ale-tcl-nagelfar|
terraform...............................|ale-terraform-options|
diff --git a/supported-tools.md b/supported-tools.md
index 616008cc..b73d4607 100644
--- a/supported-tools.md
+++ b/supported-tools.md
@@ -501,6 +501,8 @@ formatting.
* [sourcekit-lsp](https://github.com/apple/sourcekit-lsp)
* [swiftformat](https://github.com/nicklockwood/SwiftFormat)
* [swiftlint](https://github.com/realm/SwiftLint)
+* systemd
+ * [systemd-analyze](https://www.freedesktop.org/software/systemd/man/systemd-analyze.html) :floppy_disk:
* Tcl
* [nagelfar](http://nagelfar.sourceforge.net) :floppy_disk:
* Terraform
diff --git a/test/command_callback/test_systemd_analyze_command_callback.vader b/test/command_callback/test_systemd_analyze_command_callback.vader
new file mode 100644
index 00000000..d97c87be
--- /dev/null
+++ b/test/command_callback/test_systemd_analyze_command_callback.vader
@@ -0,0 +1,9 @@
+Before:
+ call ale#assert#SetUpLinterTest('systemd', 'systemd_analyze')
+
+After:
+ call ale#assert#TearDownLinterTest()
+
+Execute(The default command should be correct):
+ AssertLinter 'systemd-analyze',
+ \ 'SYSTEMD_LOG_COLOR=0 ' . ale#Escape('systemd-analyze') . ' --user verify %s'
diff --git a/test/handler/test_systemd_analyze_hander.vader b/test/handler/test_systemd_analyze_hander.vader
new file mode 100644
index 00000000..c7d668e0
--- /dev/null
+++ b/test/handler/test_systemd_analyze_hander.vader
@@ -0,0 +1,19 @@
+Before:
+ runtime ale_linters/systemd/systemd_analyze.vim
+
+After:
+ call ale#linter#Reset()
+
+Execute(The systemd-analyze handler should parse lines correctly):
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 9,
+ \ 'col': 1,
+ \ 'type': 'W',
+ \ 'text': 'Unknown key name ''Wat'' in section ''Service'', ignoring.',
+ \ },
+ \ ],
+ \ ale_linters#systemd#systemd_analyze#Handle(bufnr(''), [
+ \ '/home/user/.config/systemd/user/foo.service:9: Unknown key name ''Wat'' in section ''Service'', ignoring.',
+ \ ])