Skip to content

Commit

Permalink
Add zizmor linter (#710)
Browse files Browse the repository at this point in the history
  • Loading branch information
hejops authored Jan 5, 2025
1 parent 0f43320 commit 3c801cb
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ Other dedicated linters that are built-in are:
| [write-good][write-good] | `write_good` |
| [yamllint][yamllint] | `yamllint` |
| [yq][yq] | `yq` |
| [zizmor][zizmor] | `zizmor` |
| [zsh][zsh] | `zsh` |

## Custom Linters
Expand Down Expand Up @@ -586,3 +587,4 @@ busted tests/
[yq]: https://mikefarah.gitbook.io/yq
[svlint]: https://github.com/dalance/svlint
[slang]: https://github.com/MikePopoloski/slang
[zizmor]: https://github.com/woodruffw/zizmor
41 changes: 41 additions & 0 deletions lua/lint/linters/zizmor.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
local severities = {
High = vim.diagnostic.severity.ERROR,
Medium = vim.diagnostic.severity.WARN,
}

return {
cmd = "zizmor",
args = { "--format", "json" },
stdin = false,
ignore_exitcode = true, -- 14

parser = function(output, _)
local items = {}

if output == "" then
return items
end

local decoded = vim.json.decode(output) or {}
local bufpath = vim.fn.expand("%:p")

for _, diag in ipairs(decoded) do
if diag.locations[1].symbolic.key.Local.path == bufpath then
table.insert(items, {
source = "zizmor",
lnum = diag.locations[1].concrete.location.start_point.row,
col = diag.locations[1].concrete.location.start_point.column,
end_lnum = diag.locations[1].concrete.location.end_point.row - 1,
end_col = diag.locations[1].concrete.location.end_point.column,
message = diag.desc,
severity = assert(
severities[diag.determinations.severity],
"missing mapping for severity " .. diag.determinations.severity
),
})
end
end

return items
end,
}

0 comments on commit 3c801cb

Please sign in to comment.