Googletest: Suppress Clang-Tidy warnings

Created on 3 Sep 2019  路  2Comments  路  Source: google/googletest

When we run clang-tidy on our source code, it finds hundreds of issues related to usages of gtest. We currently have to disable a few clang-tidy checks because of this. In the longer run, we want to enable these checks again. I believe the reported issues are false positives, so it would be beneficial for us if gtest would suppress these warnings.

I found out (among others in https://github.com/google/googletest/issues/853) that gtest already contains 'NOLINT' comments to suppress clang-tidy warnings. I would like to point out a few additional places to add them (based on the code in version 1.8.1):

  • clang-tidy warning 'cert-err58-cpp'

    • gtest_internal.h

    • affects usages of TEST and TEST_F

    • add nolint comment to the assignment on line 1319

    • gtest-param-test.h

    • affects usages of TEST_P and INSTANTIATE_TEST_CASE_P

    • add nolint comment to the assignment on lines 1396/1397

    • add nolint comment to the assignment on line 1421

  • clang-tidy warning 'cppcoreguidelines-avoid-goto'

    • gtest-internal.h

    • affects usages of EXPECT_NO_THROW and similar

    • add nolint comment to lines 1231, 1237, 1250, 1268, 1294

    • gtest-death-test-internal.h

    • affects usages of EXPECT_DEATH and similar

    • add nolint comment to lines 196, 204

If I can help out in any other way, let me know.

Most helpful comment

Two more I hit:

  • cppcoreguidelines-owning-memory

    • gtest.h - (initializing non-owner argument of type 'testing::internal::TestFactoryBase *' with a newly created 'gsl::owner<>' )

  • cppcoreguidelines-special-member-functions

    • gtest-param-test.h - (class 'SleepTest_Sleep_Test' defines a copy constructor and a copy assignment operator but does not define a destructor, a move constructor or a move assignment operator)

All 2 comments

Two more I hit:

  • cppcoreguidelines-owning-memory

    • gtest.h - (initializing non-owner argument of type 'testing::internal::TestFactoryBase *' with a newly created 'gsl::owner<>' )

  • cppcoreguidelines-special-member-functions

    • gtest-param-test.h - (class 'SleepTest_Sleep_Test' defines a copy constructor and a copy assignment operator but does not define a destructor, a move constructor or a move assignment operator)

One more:

  • cppcoreguidelines-avoid-non-const-global-variables

    • gtest.h: - Variable 'test_info_' provides global access to a non-const object; consider making the pointed-to data 'const'

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pepe82sh picture pepe82sh  路  5Comments

apivovarov picture apivovarov  路  3Comments

ebioman picture ebioman  路  3Comments

kdawgwilk picture kdawgwilk  路  3Comments

octoploid picture octoploid  路  3Comments