Skip to content

Commit 888962b

Browse files
authored
fix: correct broken tool definitions (#79)
* fix: correct broken tool definitions Problem: several formatter and linter configs produced invalid commands when invoked by guard.nvim. pylint, shellcheck, and rubocop were missing fname=true so guard never appended the required filename argument. hadolint lacked the '-' arg needed to read stdin. ruff linter used the deprecated -e flag and was missing the 'check' subcommand. buf format was configured for stdin which it does not support. csharpier referenced the old dotnet-csharpier binary renamed in v1.0+. ruff_fix was missing the 'check' subcommand. Solution: add fname=true to pylint, shellcheck, and rubocop linters. Add '-' to hadolint args. Replace ruff linter's -e with check subcommand. Change buf from stdin to fname with -w flag. Update csharpier cmd and args for v1.0+. Add check to ruff_fix args. * test: add tests for fixed tool definitions Problem: the config fixes in the previous commit had no test coverage proving the definitions produce valid commands. Solution: add opts (cwd, tmpdir) and assert_diag to the test helper. Add tests for all 8 fixed tools using run_fmt/run_lint to exercise the actual configs. Add pylint to pip.txt, hadolint to binary.txt, shellcheck to the binary CI job, and new test-dotnet and test-ruby CI jobs.
1 parent a26b683 commit 888962b

30 files changed

Lines changed: 540 additions & 50 deletions

.github/scripts/install-binary-tools.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,10 @@ while read -r name type url extra; do
3030
chmod +x "$dest/$name"
3131
rm -rf "$tmpdir"
3232
;;
33+
jar)
34+
wget -q "$url" -O "$dest/$name.jar"
35+
printf '#!/usr/bin/env bash\nexec java -jar "%s/%s.jar" "$@"\n' "$(cd "$dest" && pwd)" "$name" > "$dest/$name"
36+
chmod +x "$dest/$name"
37+
;;
3338
esac
3439
done < "$manifest"

.github/tools/binary.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
alejandra bin https://github.com/kamadorueda/alejandra/releases/download/4.0.0/alejandra-x86_64-unknown-linux-musl
22
buf bin https://github.com/bufbuild/buf/releases/download/v1.47.2/buf-Linux-x86_64
3+
hadolint bin https://github.com/hadolint/hadolint/releases/download/v2.12.0/hadolint-Linux-x86_64
34
checkmake bin https://github.com/mrtazz/checkmake/releases/download/0.2.2/checkmake-0.2.2.linux.amd64
45
deno zip https://github.com/denoland/deno/releases/download/v2.1.4/deno-x86_64-unknown-linux-gnu.zip
6+
detekt jar https://github.com/detekt/detekt/releases/download/v1.23.7/detekt-cli-1.23.7-all.jar
57
hlint tar https://github.com/ndmitchell/hlint/releases/download/v3.10/hlint-3.10-x86_64-linux.tar.gz hlint-3.10/hlint
68
latexindent bin https://github.com/cmhughes/latexindent.pl/releases/download/V3.24.4/latexindent-linux
79
swiftformat zip https://github.com/nicklockwood/SwiftFormat/releases/download/0.55.3/swiftformat_linux.zip swiftformat_linux
10+
cbfmt tar https://github.com/lukas-reineke/cbfmt/releases/download/v0.2.0/cbfmt_linux-x86_64_v0.2.0.tar.gz cbfmt_linux-x86_64_v0.2.0/cbfmt
11+
dprint zip https://github.com/dprint/dprint/releases/download/0.49.0/dprint-x86_64-unknown-linux-gnu.zip
12+
ktlint bin https://github.com/pinterest/ktlint/releases/download/1.8.0/ktlint

.github/tools/npm.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@ prettier
22
@biomejs/biome
33
sql-formatter
44
@taplo/cli
5+
eslint
6+
eslint_d
7+
stylelint

.github/tools/pip.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ cpplint
55
docformatter
66
flake8
77
mypy
8+
pylint
89
ruff
910
sqlfluff
1011
yapf

.github/workflows/ci.yaml

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ jobs:
9090
- name: Install tools
9191
run: |
9292
xargs -L1 go install < .github/tools/go.txt
93+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.64.8
9394
luarocks install busted --local
9495
luarocks install nlua --local
9596
- name: Clone guard.nvim
@@ -163,13 +164,17 @@ jobs:
163164
with:
164165
neovim: true
165166
version: nightly
167+
- uses: actions/setup-java@v4
168+
with:
169+
distribution: temurin
170+
java-version: 21
166171
- uses: leso-kn/gh-actions-lua@master
167172
with:
168173
luaVersion: "5.1"
169174
- uses: hishamhm/gh-actions-luarocks@master
170175
- name: Install tools
171176
run: |
172-
sudo apt-get install -y zsh
177+
sudo apt-get install -y zsh shellcheck
173178
luarocks install busted --local
174179
luarocks install nlua --local
175180
bash .github/scripts/install-binary-tools.sh "$HOME/.local/bin"
@@ -205,3 +210,62 @@ jobs:
205210
export LUA_PATH="lua/?.lua;lua/?/init.lua;$LUA_PATH"
206211
busted --lua nlua test/apt/*_spec.lua
207212
213+
test-dotnet:
214+
runs-on: ubuntu-latest
215+
steps:
216+
- uses: actions/checkout@v4
217+
- uses: rhysd/action-setup-vim@v1
218+
with:
219+
neovim: true
220+
version: nightly
221+
- uses: actions/setup-dotnet@v4
222+
with:
223+
dotnet-version: '8.0'
224+
- uses: leso-kn/gh-actions-lua@master
225+
with:
226+
luaVersion: "5.1"
227+
- uses: hishamhm/gh-actions-luarocks@master
228+
- name: Install tools
229+
run: |
230+
dotnet tool install -g csharpier
231+
luarocks install busted --local
232+
luarocks install nlua --local
233+
- name: Clone guard.nvim
234+
run: git clone --depth 1 https://github.com/nvimdev/guard.nvim && mv guard.nvim/lua/guard lua/
235+
- name: Run tests
236+
run: |
237+
export LUA_PATH="lua/?.lua;lua/?/init.lua;$LUA_PATH"
238+
busted --lua nlua test/dotnet/*_spec.lua
239+
240+
test-ruby:
241+
runs-on: ubuntu-latest
242+
steps:
243+
- uses: actions/checkout@v4
244+
- uses: rhysd/action-setup-vim@v1
245+
with:
246+
neovim: true
247+
version: nightly
248+
- uses: ruby/setup-ruby@v1
249+
with:
250+
ruby-version: '3.3'
251+
- uses: leso-kn/gh-actions-lua@master
252+
with:
253+
luaVersion: "5.1"
254+
- uses: hishamhm/gh-actions-luarocks@master
255+
- name: Install tools
256+
run: |
257+
gem install rubocop bundler
258+
luarocks install busted --local
259+
luarocks install nlua --local
260+
- name: Setup rubocop Gemfile
261+
run: |
262+
mkdir -p /tmp/rubocop-test
263+
printf "source 'https://rubygems.org'\ngem 'rubocop'\n" > /tmp/rubocop-test/Gemfile
264+
cd /tmp/rubocop-test && bundle install
265+
- name: Clone guard.nvim
266+
run: git clone --depth 1 https://github.com/nvimdev/guard.nvim && mv guard.nvim/lua/guard lua/
267+
- name: Run tests
268+
run: |
269+
export LUA_PATH="lua/?.lua;lua/?/init.lua;$LUA_PATH"
270+
busted --lua nlua test/ruby/*_spec.lua
271+

lua/guard-collection/formatter.lua

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ M.cljfmt = {
4848
}
4949

5050
M.csharpier = {
51-
cmd = 'dotnet-csharpier',
52-
args = { '--write-stdout' },
51+
cmd = 'csharpier',
52+
args = { 'format', '--write-stdout' },
5353
stdin = true,
5454
}
5555

@@ -299,7 +299,7 @@ M.ruff = {
299299

300300
M.ruff_fix = {
301301
cmd = 'ruff',
302-
args = { '--fix', '-', '--stdin-filename' },
302+
args = { 'check', '--fix', '-', '--stdin-filename' },
303303
stdin = true,
304304
fname = true,
305305
}
@@ -319,8 +319,8 @@ M.biome = {
319319

320320
M.buf = {
321321
cmd = 'buf',
322-
args = { 'format' },
323-
stdin = true,
322+
args = { 'format', '-w' },
323+
fname = true,
324324
}
325325

326326
M.xmllint = {

lua/guard-collection/linter/hadolint.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
return {
22
cmd = 'hadolint',
3-
args = { '--no-fail', '--format=json' },
3+
args = { '--no-fail', '--format=json', '-' },
44
stdin = true,
55
parse = require('guard.lint').from_json({
66
attributes = {

lua/guard-collection/linter/pylint.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ return {
44
cmd = 'pylint',
55
args = { '--from-stdin', '--output-format', 'json' },
66
stdin = true,
7+
fname = true,
78
parse = lint.from_json({
89
attributes = {
910
severity = 'type',

lua/guard-collection/linter/rubocop.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ return {
44
cmd = 'bundle',
55
args = { 'exec', 'rubocop', '--format', 'json', '--force-exclusion', '--stdin' },
66
stdin = true,
7+
fname = true,
78
parse = lint.from_json({
89
get_diagnostics = function(...)
910
return vim.json.decode(...).files[1].offenses

lua/guard-collection/linter/ruff.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ local lint = require('guard.lint')
33
return {
44
cmd = 'ruff',
55
args = {
6+
'check',
67
'-n',
7-
'-e',
88
'--output-format',
99
'json',
1010
'-',

0 commit comments

Comments
 (0)