XRPLF / clio

An XRP Ledger API Server
https://xrpl.org
ISC License
57 stars 48 forks source link

Make clang-tidy to fail if there is no check after dynamic_cast #897

Open kuznetsss opened 9 months ago

kuznetsss commented 9 months ago

Currently there are places (mostly in tests) with code like:

auto ptr = dynamic_cast<Foo*>(mockFoo);
EXPECT_EQ(ptr->bar(), expected_value);

and clang-tidy is fine with it. We should force clang-tidy to fail on such places to force to check pointer after dynamic_cast.

godexsoft commented 9 months ago

Tried to use clang-analyzer-core and clang-analyzer-cplusplus (in particular core.NullDereference). Unfortunately it does not seem to catch the cases we want even with this option disabled as suggested in the above link:

CheckOptions:
  core.NullDereference:SuppressAddressSpaces: false