nvim-lint icon indicating copy to clipboard operation
nvim-lint copied to clipboard

Cppcheck v2.12.0 failing

Open tomhampshire opened this issue 1 year ago • 3 comments

Recent versions of Cppcheck (v2.12.0) are failing with nvim-lint

tomhampshire avatar Dec 21 '23 18:12 tomhampshire

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

kapkanov avatar Dec 31 '23 15:12 kapkanov

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 avatar Jan 28 '24 09:01 ismasou

@ismasou could you create a PR for that change?

mfussenegger avatar Feb 01 '24 09:02 mfussenegger