diff --git a/lib/cppcheck.cpp b/lib/cppcheck.cpp index e514c9dc409..d8be7be309d 100644 --- a/lib/cppcheck.cpp +++ b/lib/cppcheck.cpp @@ -1985,11 +1985,11 @@ void CppCheck::analyseClangTidy(const FileSettings &fileSettings) for (const auto& id : splitString(errorString.substr(1, errorString.length() - 2), ',')) { errmsg.id = "clang-tidy-" + id; - if (errmsg.id.find("performance") != std::string::npos) + if (startsWith(id, "performance-")) errmsg.severity = Severity::performance; - else if (errmsg.id.find("portability") != std::string::npos) + else if (startsWith(id, "portability-")) errmsg.severity = Severity::portability; - else if (errmsg.id.find("cert") != std::string::npos || errmsg.id.find("misc") != std::string::npos || errmsg.id.find("unused") != std::string::npos) + else if (startsWith(id, "cert-") || startsWith(id, "misc-") || startsWith(id, "bugprone-") || (id.find("-unused-") != std::string::npos)) errmsg.severity = Severity::warning; else errmsg.severity = Severity::style; diff --git a/test/cli/other_test.py b/test/cli/other_test.py index 31b1e27b97c..dd0f803f8e5 100644 --- a/test/cli/other_test.py +++ b/test/cli/other_test.py @@ -3464,7 +3464,7 @@ def test_clang_tidy_project(tmpdir): @pytest.mark.skipif(not has_clang_tidy, reason='clang-tidy is not available') -def test_clang_tidy_error_exit(tmp_path): # #13828 +def test_clang_tidy_error_exit(tmp_path): # #13828 / #13829 test_file = tmp_path / 'test.cpp' with open(test_file, 'wt') as f: f.write( @@ -3495,7 +3495,7 @@ def test_clang_tidy_error_exit(tmp_path): # #13828 exitcode, stdout, stderr = cppcheck(args) assert stdout.splitlines() == [] assert stderr.splitlines() == [ - "{}:10:12: style: 'str' used after it was moved [clang-tidy-bugprone-use-after-move]".format(test_file), + "{}:10:12: warning: 'str' used after it was moved [clang-tidy-bugprone-use-after-move]".format(test_file), "{}:10:12: style: 'str' used after it was moved [clang-tidy-hicpp-invalid-access-moved]".format(test_file) ] assert exitcode == 0, stdout