Skip to content

Enable a lot more clang-tidy checks and enforce it in CI

Tim Starling requested to merge work/tstarling/clang-tidy into main

Previously I was only using the CLion default checks. Here I'm enabling broad categories of checks, except for a whitelist. This found some interesting issues, and made some fair points about the style I used. Possibly some C influence was creeping in.

There shouldn't be any runtime overhead -- the really scary code is all still there, doing its unbounded array writes and pointer arithmetic.

  • It doesn't like MemoryBudget as a non-const global. Fair enough, pass it down as a constructor dependency.
  • Rule of five, rule of zero. I feel like I should be able to manage my own pointers -- that was supposedly a very simple and normal thing when I first learnt C++. The only remaining place where I'm still insisting on this despite obvious alternatives is OutputImage, and that's just because it's easier to follow the rule of five than to do unique_ptr::get() on every JPEG library call.
  • Get rid of variable length C-style arrays. I have reasons for liking them which on reflection do not apply here.
  • In OutputPyramid I switched to std::vector although I'm still using memcpy() because I don't trust std::copy_n() etc. to have acceptable performance.

Merge request reports