One of the issues that I face with the CLion plugin for Cppcheck is that I am shelling out to execute Cppcheck from within the IDE and passing it a path to a file. The issue is that the file on disc may not be in sync with what is displayed in the editor, so there is a lag where the line highlights are inconsisent.
From within the plugin, I have access to the entire contents of the file as they appear at the moment (before being saved to disc), so if I could pipe that into Cppcheck somehow from memory (stdin came to mind) I could greatly improve the performance for the user.
Can something like this be done?
Last edit: John Hagen 2016-09-14
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
One way is to use cppcheck-core directly (e.g. writing your own front-end instead of using CLI, in case you are using that one). It takes a stream (call CppCheck::processFile() then) or the file content just as a string (call CppCheck::check()). This probably in general is the smartest solution to the issue. As an additional advantage of this approach, cppcheck-core is prepared to be compiled into a dll (the official Widnows releases make use of that), so that cppcheck could be updated by just replacing the dll without necessarily updating your front-end (as long as the API and ABI does not change).
However, this will still have the issue that cppcheck will try to read header files that are included from disc. However, I am not sure how you would solve that with a single stream, anyway. At least Visual Studio (as the IDE I use) saves files before it starts compiling them.
Last edit: Mr. X 2016-09-14
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
If you call cppcheck-core like that then as far as I know your plugin must be GPL-compliant.
you could also save the code in a temporary file.
It would not be technically very difficult to add a flag that makes cppcheck read input from stdin, it's just that we are very careful about adding flags.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
And it looks like at the moment --file-list can read from stdin, so adding a new flag would probably add confusion?
--file-list=<file> Specify the files to check in a text file. Add one filename per line. When file is '-,' the file list will be read from standard input.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
One of the issues that I face with the CLion plugin for Cppcheck is that I am shelling out to execute Cppcheck from within the IDE and passing it a path to a file. The issue is that the file on disc may not be in sync with what is displayed in the editor, so there is a lag where the line highlights are inconsisent.
From within the plugin, I have access to the entire contents of the file as they appear at the moment (before being saved to disc), so if I could pipe that into Cppcheck somehow from memory (stdin came to mind) I could greatly improve the performance for the user.
Can something like this be done?
Last edit: John Hagen 2016-09-14
One way is to use cppcheck-core directly (e.g. writing your own front-end instead of using CLI, in case you are using that one). It takes a stream (call CppCheck::processFile() then) or the file content just as a string (call CppCheck::check()). This probably in general is the smartest solution to the issue. As an additional advantage of this approach, cppcheck-core is prepared to be compiled into a dll (the official Widnows releases make use of that), so that cppcheck could be updated by just replacing the dll without necessarily updating your front-end (as long as the API and ABI does not change).
However, this will still have the issue that cppcheck will try to read header files that are included from disc. However, I am not sure how you would solve that with a single stream, anyway. At least Visual Studio (as the IDE I use) saves files before it starts compiling them.
Last edit: Mr. X 2016-09-14
If you call cppcheck-core like that then as far as I know your plugin must be GPL-compliant.
you could also save the code in a temporary file.
It would not be technically very difficult to add a flag that makes cppcheck read input from stdin, it's just that we are very careful about adding flags.
And it looks like at the moment
--file-list
can read from stdin, so adding a new flag would probably add confusion?--file-list=<file> Specify the files to check in a text file. Add one
filename per line. When file is '-,' the file list will
be read from standard input.