cli: Change default --template format, Cppcheck will now use the gcc template by default. Added --template=cppcheck1 format.
This commit is contained in:
parent
2471266f12
commit
6431d1c58a
|
@ -44,6 +44,10 @@
|
|||
#include <tinyxml2.h>
|
||||
#endif
|
||||
|
||||
// The default template format is "gcc"
|
||||
static const char GCC_TEMPLATE_FORMAT[] = "{file}:{line}:{column}: warning: {message} [{id}]\\n{code}";
|
||||
static const char GCC_TEMPLATE_LOCATION[] = "{file}:{line}:{column}: note: {info}\\n{code}";
|
||||
|
||||
static void addFilesToList(const std::string& FileList, std::vector<std::string>& PathNames)
|
||||
{
|
||||
// To keep things initially simple, if the file can't be opened, just be silent and move on.
|
||||
|
@ -638,9 +642,8 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
|
|||
}
|
||||
|
||||
if (mSettings->templateFormat == "gcc") {
|
||||
//_settings->templateFormat = "{file}:{line}: {severity}: {message}";
|
||||
mSettings->templateFormat = "{file}:{line}:{column}: warning: {message} [{id}]\\n{code}";
|
||||
mSettings->templateLocation = "{file}:{line}:{column}: note: {info}\\n{code}";
|
||||
mSettings->templateFormat = GCC_TEMPLATE_FORMAT;
|
||||
mSettings->templateLocation = GCC_TEMPLATE_LOCATION;
|
||||
} else if (mSettings->templateFormat == "daca2") {
|
||||
mSettings->templateFormat = "{file}:{line}:{column}: {severity}: {message} [{id}]";
|
||||
mSettings->templateLocation = "{file}:{line}:{column}: note: {info}";
|
||||
|
@ -648,6 +651,8 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
|
|||
mSettings->templateFormat = "{file}({line}): {severity}: {message}";
|
||||
else if (mSettings->templateFormat == "edit")
|
||||
mSettings->templateFormat = "{file} +{line}: {severity}: {message}";
|
||||
else if (mSettings->templateFormat == "cppcheck1")
|
||||
mSettings->templateFormat = "{callstack}: ({severity}{inconclusive:, inconclusive}) {message}";
|
||||
}
|
||||
|
||||
else if (std::strcmp(argv[i], "--template-location") == 0 ||
|
||||
|
@ -883,6 +888,13 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
|
|||
}
|
||||
}
|
||||
|
||||
// Default template format..
|
||||
if (mSettings->templateFormat.empty()) {
|
||||
mSettings->templateFormat = GCC_TEMPLATE_FORMAT;
|
||||
if (mSettings->templateLocation.empty())
|
||||
mSettings->templateLocation = GCC_TEMPLATE_LOCATION;
|
||||
}
|
||||
|
||||
mSettings->project.ignorePaths(mIgnoredPaths);
|
||||
|
||||
if (mSettings->force)
|
||||
|
@ -1143,7 +1155,8 @@ void CmdLineParser::printHelp()
|
|||
" '{file}:{line},{severity},{id},{message}' or\n"
|
||||
" '{file}({line}):({severity}) {message}' or\n"
|
||||
" '{callstack} {message}'\n"
|
||||
" Pre-defined templates: gcc, vs, edit.\n"
|
||||
" Pre-defined templates: gcc, vs, edit, cppcheck1\n"
|
||||
" The default format is 'gcc'.\n"
|
||||
" --template-location='<text>'\n"
|
||||
" Format error message location. If this is not provided\n"
|
||||
" then no extra location info is shown.\n"
|
||||
|
|
|
@ -1 +1,3 @@
|
|||
[samples\AssignmentAddressToInteger\bad.c:3]: (portability) Assigning a pointer to an integer is not portable.
|
||||
samples\AssignmentAddressToInteger\bad.c:3:0: warning: Assigning a pointer to an integer is not portable. [AssignmentAddressToInteger]
|
||||
int a = p;
|
||||
^
|
||||
|
|
|
@ -1 +1,3 @@
|
|||
[samples\arrayIndexOutOfBounds\bad.c:7]: (error) Array 'a[2]' accessed at index 2, which is out of bounds.
|
||||
samples\arrayIndexOutOfBounds\bad.c:7:6: warning: Array 'a[2]' accessed at index 2, which is out of bounds. [arrayIndexOutOfBounds]
|
||||
a[2] = 0;
|
||||
^
|
||||
|
|
|
@ -1 +1,3 @@
|
|||
[samples\autoVariables\bad.c:4]: (error) Address of local auto-variable assigned to a function parameter.
|
||||
samples\autoVariables\bad.c:4:5: warning: Address of local auto-variable assigned to a function parameter. [autoVariables]
|
||||
*a = &b;
|
||||
^
|
||||
|
|
|
@ -1 +1,3 @@
|
|||
[samples\bufferAccessOutOfBounds\bad.c:6]: (error) Array 'a[2]' accessed at index 2, which is out of bounds.
|
||||
samples\bufferAccessOutOfBounds\bad.c:6:10: warning: Array 'a[2]' accessed at index 2, which is out of bounds. [arrayIndexOutOfBounds]
|
||||
a[i] = 0;
|
||||
^
|
||||
|
|
|
@ -1 +1,24 @@
|
|||
[samples\erase\bad.cpp:9] -> [samples\erase\bad.cpp:10] -> [samples\erase\bad.cpp:10] -> [samples\erase\bad.cpp:9] -> [samples\erase\bad.cpp:11] -> [samples\erase\bad.cpp:4] -> [samples\erase\bad.cpp:9]: (error) Using iterator to local container 'items' that may be invalid.
|
||||
samples\erase\bad.cpp:9:32: warning: Using iterator to local container 'items' that may be invalid. [invalidContainer]
|
||||
for (iter = items.begin(); iter != items.end(); ++iter) {
|
||||
^
|
||||
samples\erase\bad.cpp:9:17: note: Iterator to container is created here.
|
||||
for (iter = items.begin(); iter != items.end(); ++iter) {
|
||||
^
|
||||
samples\erase\bad.cpp:10:19: note: Assuming condition is true.
|
||||
if (*iter == 2) {
|
||||
^
|
||||
samples\erase\bad.cpp:10:19: note: Assuming condition is true.
|
||||
if (*iter == 2) {
|
||||
^
|
||||
samples\erase\bad.cpp:9:37: note: Assuming condition is true.
|
||||
for (iter = items.begin(); iter != items.end(); ++iter) {
|
||||
^
|
||||
samples\erase\bad.cpp:11:13: note: After calling 'erase', iterators or references to the container's data may be invalid .
|
||||
items.erase(iter);
|
||||
^
|
||||
samples\erase\bad.cpp:4:22: note: Variable created here.
|
||||
std::vector<int> items;
|
||||
^
|
||||
samples\erase\bad.cpp:9:32: note: Using iterator to local container 'items' that may be invalid.
|
||||
for (iter = items.begin(); iter != items.end(); ++iter) {
|
||||
^
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
[samples\memleak\bad.c:8]: (error) Memory leak: a
|
|
@ -1 +1,3 @@
|
|||
[samples\outOfBounds\bad.c:5]: (error) Buffer is accessed out of bounds: str
|
||||
samples\outOfBounds\bad.c:5:12: warning: Buffer is accessed out of bounds: str [bufferAccessOutOfBounds]
|
||||
strcpy(str, "0123456789abcdef");
|
||||
^
|
||||
|
|
|
@ -1 +1,3 @@
|
|||
[samples\resourceLeak\bad.c:8]: (error) Resource leak: a
|
||||
samples\resourceLeak\bad.c:8:5: warning: Resource leak: a [resourceLeak]
|
||||
return 0;
|
||||
^
|
||||
|
|
|
@ -1 +1,3 @@
|
|||
[samples\syntaxError\bad.c:2]: (error) Unmatched '{'. Configuration: ''.
|
||||
samples\syntaxError\bad.c:2:1: warning: Unmatched '{'. Configuration: ''. [syntaxError]
|
||||
|
||||
^
|
||||
|
|
Loading…
Reference in New Issue