nvim-lint
nvim-lint copied to clipboard
Cppcheck v2.12.0 failing
Recent versions of Cppcheck (v2.12.0) are failing with nvim-lint
I'm going to describe my problem and a solution of it, I hope it'll help you
My setup
-
nvim v0.9.4
-
nvim-lint
3ffa176 -
cppcheck 2.12.1
-
OS OpenSUSE Leap 15.5
-
gcc (SUSE Linux) 7.5.0
Problem
No inline diagnostics, only the message Linter command 'cppcheck' exited with code: 1
on the nvim output panel
Solution
nvim-lint
passes --cppcheck-build-dir=build to the cppcheck
command, so after I've created a build
directory within the same directory where the C source file is located, the diagnostics appeared. You can change the passed arguments to suite your needs of course
I was able to fix this by checking in the linter itself if the build directory exists:
args = {
"--enable=warning,style,performance,information",
function()
if vim.bo.filetype == "cpp" then
return "--language=c++"
else
return "--language=c"
end
end,
"--inline-suppr",
"--quiet",
function()
if vim.fn.isdirectory("build") == 1 then
return "--cppcheck-build-dir=build"
else
return ""
end
end,
"--template={file}:{line}:{column}: [{id}] {severity}: {message}",
},
@ismasou could you create a PR for that change?