Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cppcheck v2.12.0 failing #492

Open
tomhampshire opened this issue Dec 21, 2023 · 3 comments
Open

Cppcheck v2.12.0 failing #492

tomhampshire opened this issue Dec 21, 2023 · 3 comments

Comments

@tomhampshire
Copy link

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

@kapkanov
Copy link

kapkanov commented Dec 31, 2023

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

@ismasou
Copy link
Contributor

ismasou commented Jan 28, 2024

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}",
                },

@mfussenegger
Copy link
Owner

@ismasou could you create a PR for that change?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants