diff --git a/cli/cmdlineparser.cpp b/cli/cmdlineparser.cpp index 811dc93124e..7c2e00de8de 100644 --- a/cli/cmdlineparser.cpp +++ b/cli/cmdlineparser.cpp @@ -1200,6 +1200,9 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a mSettings.templateFormat = "{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]\\n{code}"; mSettings.templateLocation = "{file}:{line}:{column}: note: {info}\\n{code}"; mSettings.daca = true; + } else if (mSettings.templateFormat == "simple") { + mSettings.templateFormat = "{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]"; + mSettings.templateLocation = ""; } // TODO: bail out when no placeholders are found? } diff --git a/releasenotes.txt b/releasenotes.txt index d6dd912498e..39882ba5f03 100644 --- a/releasenotes.txt +++ b/releasenotes.txt @@ -20,3 +20,4 @@ Other: - The minimum required compiler versions have been bumped to GCC 5.1 / Clang 3.5 / Visual Studio 2015 - The minimum required CMake version has been bumped to 3.5 - Using Visual Studio with CMake now checks if the CMake version is at least 3.13. This was always required but was not checked explicitly. +- Added '--template=simple'. It is expands to '{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]' without any additional location details. diff --git a/test/cli/helloworld_test.py b/test/cli/helloworld_test.py index 97632114a3a..cc68d0bad8c 100644 --- a/test/cli/helloworld_test.py +++ b/test/cli/helloworld_test.py @@ -224,7 +224,7 @@ def test_checkers_report(): def __test_missing_include_system(use_j): - args = ['--enable=missingInclude', '--suppress=zerodiv', '--template={file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]', 'helloworld'] + args = ['--enable=missingInclude', '--suppress=zerodiv', '--template=simple', 'helloworld'] if use_j: args.insert(0, '-j2') diff --git a/test/cli/other_test.py b/test/cli/other_test.py index dc8c0e818fe..52fe1371e0d 100644 --- a/test/cli/other_test.py +++ b/test/cli/other_test.py @@ -16,7 +16,7 @@ def __test_missing_include(tmpdir, use_j): #include "test.h" """) - args = ['--enable=missingInclude', '--template={file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]', test_file] + args = ['--enable=missingInclude', '--template=simple', test_file] if use_j: args.insert(0, '-j2') @@ -247,7 +247,7 @@ def test_addon_y2038(tmpdir): } """) - args = ['--addon=y2038', '--enable=all', '--template={file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]', test_file] + args = ['--addon=y2038', '--enable=all', '--template=simple', test_file] exitcode, stdout, stderr = cppcheck(args) assert exitcode == 0 @@ -268,7 +268,7 @@ def test_addon_threadsafety(tmpdir): } """) - args = ['--addon=threadsafety', '--enable=all', '--template={file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]', test_file] + args = ['--addon=threadsafety', '--enable=all', '--template=simple', test_file] exitcode, stdout, stderr = cppcheck(args) assert exitcode == 0 @@ -298,7 +298,7 @@ def test_addon_naming(tmpdir): int Var; """) - args = ['--addon={}'.format(addon_file), '--enable=all', '--template={file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]', test_file] + args = ['--addon={}'.format(addon_file), '--enable=all', '--template=simple', test_file] exitcode, stdout, stderr = cppcheck(args) assert exitcode == 0 @@ -590,7 +590,7 @@ def test_addon_findcasts(tmpdir): } """) - args = ['--addon=findcasts', '--enable=all', '--template={file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]', test_file] + args = ['--addon=findcasts', '--enable=all', '--template=simple', test_file] exitcode, stdout, stderr = cppcheck(args) assert exitcode == 0 @@ -611,7 +611,7 @@ def test_addon_misc(tmpdir): } """) - args = ['--addon=misc', '--enable=all', '--template={file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]', test_file] + args = ['--addon=misc', '--enable=all', '--template=simple', test_file] exitcode, stdout, stderr = cppcheck(args) assert exitcode == 0 @@ -757,7 +757,7 @@ class A { }; """) - args = ['--enable=unusedFunction', '--inline-suppr', '--template={file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]', test_cpp_file] + args = ['--enable=unusedFunction', '--inline-suppr', '--template=simple', test_cpp_file] _, _, stderr = cppcheck(args) assert stderr == "{}:4:0: style: The function 'f' is never used. [unusedFunction]\n".format(test_h_file) diff --git a/test/fixture.cpp b/test/fixture.cpp index fd8ac2ffafe..6318dc151b3 100644 --- a/test/fixture.cpp +++ b/test/fixture.cpp @@ -412,7 +412,7 @@ void TestFixture::setTemplateFormat(const std::string &templateFormat) mTemplateFormat = "{file}:{line}:{severity}:{message}"; mTemplateLocation = "{file}:{line}:note:{info}"; } - else if (templateFormat == "simple") { + else if (templateFormat == "simple") { // TODO: use the existing one in CmdLineParser mTemplateFormat = "{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]"; mTemplateLocation = ""; } diff --git a/test/testcmdlineparser.cpp b/test/testcmdlineparser.cpp index 617b1a6d01a..99dd0c6fa97 100644 --- a/test/testcmdlineparser.cpp +++ b/test/testcmdlineparser.cpp @@ -253,6 +253,7 @@ class TestCmdlineParser : public TestFixture { TEST_CASE(templatesCppcheck1); TEST_CASE(templatesDaca2); TEST_CASE(templatesSelfcheck); + TEST_CASE(templatesSimple); TEST_CASE(templatesNoPlaceholder); TEST_CASE(templateFormatInvalid); TEST_CASE(templateFormatEmpty); @@ -1553,6 +1554,16 @@ class TestCmdlineParser : public TestFixture { ASSERT_EQUALS("{file}:{line}:{column}: note: {info}\n{code}", settings->templateLocation); } + void templatesSimple() { + REDIRECT; + const char * const argv[] = {"cppcheck", "--template=simple", "file.cpp"}; + settings->templateFormat.clear(); + settings->templateLocation.clear(); + ASSERT_EQUALS(CmdLineParser::Result::Success, parser->parseFromArgs(3, argv)); + ASSERT_EQUALS("{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]", settings->templateFormat); + ASSERT_EQUALS("", settings->templateLocation); + } + // TODO: we should bail out on this void templatesNoPlaceholder() { REDIRECT;