Added --template=cppcheck2 output format

This commit is contained in:
Daniel Marjamäki 2017-05-23 12:19:11 +02:00
parent 6cb563b3fe
commit a3c0eecccf
4 changed files with 14 additions and 6 deletions

View File

@ -996,7 +996,7 @@ void CmdLineParser::PrintHelp()
" '{file}:{line},{severity},{id},{message}' or\n"
" '{file}({line}):({severity}) {message}' or\n"
" '{callstack} {message}'\n"
" Pre-defined templates: clang, gcc, vs, edit.\n"
" Pre-defined templates: clang, cppcheck2, gcc, vs, edit.\n"
" -v, --verbose Output more detailed error information.\n"
" --version Print out version number.\n"
" --xml Write results in xml format to error stream (stderr).\n"

View File

@ -169,7 +169,7 @@ protected:
ErrorPath errorPath;
if (!value) {
errorPath.push_back(ErrorPathItem(errtok,bug));
} else if (_settings->verbose || _settings->xml || _settings->outputFormat == "clang") {
} else if (_settings->verbose || _settings->xml || _settings->outputFormat == "clang" || _settings->outputFormat == "cppcheck2") {
errorPath = value->errorPath;
errorPath.push_back(ErrorPathItem(errtok,bug));
} else {

View File

@ -413,7 +413,7 @@ std::string ErrorLogger::ErrorMessage::toString(bool verbose, const std::string
return text.str();
}
else if (outputFormat == "clang") {
else if (outputFormat == "clang" || outputFormat == "cppcheck2") {
std::ostringstream text;
if (_callStack.empty()) {
text << "nofile:0:0: ";
@ -421,8 +421,16 @@ std::string ErrorLogger::ErrorMessage::toString(bool verbose, const std::string
const ErrorLogger::ErrorMessage::FileLocation &loc = _callStack.back();
text << loc.getfile() << ':' << loc.line << ':' << loc.col << ": ";
}
text << ((_id == "syntaxError" || _id=="internalError") ? "error: " : "warning: ")
<< (verbose ? _verboseMessage : _shortMessage)
if (outputFormat == "clang")
text << ((_id == "syntaxError" || _id=="internalError") ? "error: " : "warning: ");
else {
if (_inconclusive)
text << "inconclusive ";
text << Severity::toString(_severity) << ": ";
}
text << (verbose ? _verboseMessage : _shortMessage)
<< " [" << _id << ']';
if (_callStack.size() <= 1U)

View File

@ -152,7 +152,7 @@ def scanarchive(filepath, jobs, cpulimit):
cmd = 'cpulimit --limit=' + cpulimit
else:
cmd = 'nice --adjustment=1000'
cmd = cmd + ' ../cppcheck-O2 -D__GCC__ --enable=style --inconclusive --error-exitcode=0 --exception-handling=stderr ' + jobs + ' --template=clang .'
cmd = cmd + ' ../cppcheck-O2 -D__GCC__ --enable=style --inconclusive --error-exitcode=0 --exception-handling=stderr ' + jobs + ' --template=cppcheck2 .'
cmds = cmd.split()
p = subprocess.Popen(cmds, stdout=subprocess.PIPE, stderr=subprocess.PIPE)