QiuminGe / cpp-check-lint

MIT License
12 stars 6 forks source link

cppcheck filter argument needs a single quote #24

Closed heemonsu closed 3 years ago

heemonsu commented 3 years ago

While using cppcheck on a file, I noticed that the command was failing because the executing command was this:

executing: cppcheck --template={file}:{line}:{column}: {severity}: CWE-{cwe} {message}:[{id}] --enable=warning -j4 ....

Since there is a space in the given template, according to cppcheck documentation, it looks like the argument to the template needs to be wrapped with a single quote(').

--template='<text>'  Format the error messages. E.g.
                         '{file}:{line},{severity},{id},{message}' or
                         '{file}({line}):({severity}) {message}' or
                         '{callstack} {message}'
                         Pre-defined templates: gcc, vs, edit.

I tried that out locally by copying the full command and using single quotes, and the command ran without issues:

cppcheck --template='{file}:{line}:{column}: {severity}: CWE-{cwe} {message}:[{id}]' --enable=warning -j4 ...
QiuminGe commented 3 years ago

What is the plug-in version? and What is the cppcheck version?

I can add single quotes, but I don't think that's the root cause

QiuminGe commented 3 years ago

Try v1.4.0 and look forward to your feedback

heemonsu commented 3 years ago

Hey, sorry just saw this thread. When I had the issue, I was using 1.3.8 version of the extension and cppcheck 1.72. I gave 1.4.0 a try, and it looks like its working, thanks!

QiuminGe commented 3 years ago

I found the reason, template set "{file}:{line}:{column}: {severity}: CWE-{cwe} {message}:[{id}]", but cppckeck version less than 1.72 "template" is not supported "{column}"。 v1.72 result is :
main.cpp:10:{column}: error: CWE-{cwe} Possible null pointer dereference: p:[nullPointer] Higher version result is :
main.cpp:10:5: warning: CWE-476 Possible null pointer dereference: p:[nullPointer]

regular expression is: ^(.):(\d+):(\d+):\s(\w+):\s(.):[([A-Za-z]+)]$/ So the match failed。 now regular expression is: ^(.):(\d+):(\d+|{column}):\s(\w+):\s(.):[([A-Za-z]+)]$/

please try v1.4.1

QiuminGe commented 3 years ago

I gave 1.4.0 a try, and it looks like its working, thanks! ---- I don't think v1.4.0 can be working will