-
Notifications
You must be signed in to change notification settings - Fork 1.5k
cppcheck options: add --output-file-type option #3350
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
Closed
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
When used with tools such as cmake, cppcheck doesn't provide an convenient way to output into files. I've added two values for new --output-file-type option: uniq: this will create a output file name based on the --output-file and the current file(s) that are analyzed append: this will open the --output-file file in append mode and add the content to it example: Not using the new option: $ cppcheck --enable=all --xml --xml-version=2 --output-file=output_files/cppcheck.xml cli/cmdlineparser.cpp $ ls -la output_files/ total 12 drwxrwxr-x 2 user user 4096 Jul 22 14:47 . drwxrwxr-x 26 user user 4096 Jul 22 14:36 .. -rw-rw-r-- 1 user user 1283 Jul 22 14:47 cppcheck.xml Using the option with value "uniq" for one file: $ cppcheck --enable=all --xml --xml-version=2 --output-file=output_files/cppcheck.xml --output-file-type=uniq cli/cmdlineparser.cpp $ ls -la output_files/ total 12 drwxrwxr-x 2 user user 4096 Jul 22 14:48 . drwxrwxr-x 26 user user 4096 Jul 22 14:36 .. -rw-rw-r-- 1 user user 1283 Jul 22 14:48 cppcheck_cmdlineparser_cpp.xml Using the option with value "uniq" for two files: $ cppcheck --enable=all --xml --xml-version=2 --output-file=output_files/cppcheck.xml --output-file-type=uniq cli/cmdlineparser.cpp cli/cppcheckexecutor.cpp $ ls -la output_files/ total 16 drwxrwxr-x 2 user user 4096 Jul 22 14:49 . drwxrwxr-x 26 user user 4096 Jul 22 14:36 .. -rw-rw-r-- 1 user user 4308 Jul 22 14:49 cppcheck_cmdlineparser_cpp_cppcheckexecutor_cpp.xml Using the option with value "append" for one file on a empty/non-existing file: $ cppcheck --enable=all --xml --xml-version=2 --output-file=output_files/cppcheck.xml --output-file-type=append cli/cmdlineparser.cpp $ ls -la output_files/ total 12 drwxrwxr-x 2 user user 4096 Jul 22 14:51 . drwxrwxr-x 26 user user 4096 Jul 22 14:36 .. -rw-rw-r-- 1 user user 1283 Jul 22 14:51 cppcheck.xml Using the option with value "append" for two files on a empty/non-existing file: $ cppcheck --enable=all --xml --xml-version=2 --output-file=output_files/cppcheck.xml --output-file-type=append cli/cmdlineparser.cpp cli/cppcheckexecutor.cpp $ ls -la output_files/ total 16 drwxrwxr-x 2 user user 4096 Jul 22 14:53 . drwxrwxr-x 26 user user 4096 Jul 22 14:36 .. -rw-rw-r-- 1 user user 4308 Jul 22 14:53 cppcheck.xml Using the option with value twise "append" for one file on a empty/non-existing file: $ cppcheck --enable=all --xml --xml-version=2 --output-file=output_files/cppcheck.xml --output-file-type=append cli/cmdlineparser.cpp $ cppcheck --enable=all --xml --xml-version=2 --output-file=output_files/cppcheck.xml --output-file-type=append cli/cppcheckexecutor.cpp $ ls -la output_files/ total 16 drwxrwxr-x 2 user user 4096 Jul 22 14:54 . drwxrwxr-x 26 user user 4096 Jul 22 14:36 .. -rw-rw-r-- 1 user user 5613 Jul 22 14:55 cppcheck.xml /!\ the file is a pure concatenation of the files created without the "append" value which means that it's no more a valid XML file as it will have twice the "<?xml version="1.0" encoding="UTF-8"?>" entry $ cat output_files/cppcheck.xml <?xml version="1.0" encoding="UTF-8"?> <results version="2"> [...] </results> <?xml version="1.0" encoding="UTF-8"?> <results version="2"> [...] </results> Signed-off-by: Robert Wakim <robert.wakim@arm.com>
When used with tools such as cmake, cppcheck doesn't provide an convenient way to output into files. I've added two values for new --output-file-type option: uniq: this will create a output file name based on the --output-file and the current file(s) that are analyzed append: this will open the --output-file file in append mode and add the content to it example: Not using the new option: $ cppcheck --enable=all --xml --xml-version=2 --output-file=output_files/cppcheck.xml cli/cmdlineparser.cpp $ ls -la output_files/ total 12 drwxrwxr-x 2 user user 4096 Jul 22 14:47 . drwxrwxr-x 26 user user 4096 Jul 22 14:36 .. -rw-rw-r-- 1 user user 1283 Jul 22 14:47 cppcheck.xml Using the option with value "uniq" for one file: $ cppcheck --enable=all --xml --xml-version=2 --output-file=output_files/cppcheck.xml --output-file-type=uniq cli/cmdlineparser.cpp $ ls -la output_files/ total 12 drwxrwxr-x 2 user user 4096 Jul 22 14:48 . drwxrwxr-x 26 user user 4096 Jul 22 14:36 .. -rw-rw-r-- 1 user user 1283 Jul 22 14:48 cppcheck_cmdlineparser_cpp.xml Using the option with value "uniq" for two files: $ cppcheck --enable=all --xml --xml-version=2 --output-file=output_files/cppcheck.xml --output-file-type=uniq cli/cmdlineparser.cpp cli/cppcheckexecutor.cpp $ ls -la output_files/ total 16 drwxrwxr-x 2 user user 4096 Jul 22 14:49 . drwxrwxr-x 26 user user 4096 Jul 22 14:36 .. -rw-rw-r-- 1 user user 4308 Jul 22 14:49 cppcheck_cmdlineparser_cpp_cppcheckexecutor_cpp.xml Using the option with value "append" for one file on a empty/non-existing file: $ cppcheck --enable=all --xml --xml-version=2 --output-file=output_files/cppcheck.xml --output-file-type=append cli/cmdlineparser.cpp $ ls -la output_files/ total 12 drwxrwxr-x 2 user user 4096 Jul 22 14:51 . drwxrwxr-x 26 user user 4096 Jul 22 14:36 .. -rw-rw-r-- 1 user user 1283 Jul 22 14:51 cppcheck.xml Using the option with value "append" for two files on a empty/non-existing file: $ cppcheck --enable=all --xml --xml-version=2 --output-file=output_files/cppcheck.xml --output-file-type=append cli/cmdlineparser.cpp cli/cppcheckexecutor.cpp $ ls -la output_files/ total 16 drwxrwxr-x 2 user user 4096 Jul 22 14:53 . drwxrwxr-x 26 user user 4096 Jul 22 14:36 .. -rw-rw-r-- 1 user user 4308 Jul 22 14:53 cppcheck.xml Using the option with value twise "append" for one file on a empty/non-existing file: $ cppcheck --enable=all --xml --xml-version=2 --output-file=output_files/cppcheck.xml --output-file-type=append cli/cmdlineparser.cpp $ cppcheck --enable=all --xml --xml-version=2 --output-file=output_files/cppcheck.xml --output-file-type=append cli/cppcheckexecutor.cpp $ ls -la output_files/ total 16 drwxrwxr-x 2 user user 4096 Jul 22 14:54 . drwxrwxr-x 26 user user 4096 Jul 22 14:36 .. -rw-rw-r-- 1 user user 5613 Jul 22 14:55 cppcheck.xml /!\ the file is a pure concatenation of the files created without the "append" value which means that it's no more a valid XML file as it will have twice the "<?xml version="1.0" encoding="UTF-8"?>" entry $ cat output_files/cppcheck.xml <?xml version="1.0" encoding="UTF-8"?> <results version="2"> [...] </results> <?xml version="1.0" encoding="UTF-8"?> <results version="2"> [...] </results> Signed-off-by: Robert Wakim <robert.wakim@arm.com>
superseeded by #3365 the 3365 git history is much cleaner |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When used with tools such as cmake, cppcheck doesn't provide an convenient way to output into files.
"UTF-8"?>" entry
$ cat output_files/cppcheck.xml
[...]
[...]