kvrocks icon indicating copy to clipboard operation
kvrocks copied to clipboard

Use clang-format and clang-tidy instead of cpplint and cppcheck

Open PragmaTwice opened this issue 3 years ago • 0 comments

Search before asking

  • [X] I had searched in the issues and found no similar issues.

Motivation

clang-tidy is described in #602.

clang-format is currently the de facto standard of C++ code formatting.

It has lots of benefits, like:

  • currently, cpplint reports some format error, but it can hardly automatically fix the code. So we need check errors in CI, and manually fix them one by one. But in clang-format, we can format code to a consistent style with just one command. And we can even add the auto-fix phase to CI (lots of projects do so). That is a huge convenience for developers.
  • we cannot control the version of cpplint well: it has different report in different version for same code. So different report in local and CI, it is unacceptable.
  • cpplint cannot handle some detail of C++ language well. clang-format uses Clang AST and every powerful compiler technology in Clang. C++ is a super complicated language, no one can handle the syntax and semantics in different C++ standard well, except compilers like GCC or Clang. It is the core reason why cpplint and cppcheck failed to become great tools (recently cppcheck supports to use libClang instead of its own toy parser and type/semantics checker).

Solution

No response

Are you willing to submit a PR?

  • [ ] I'm willing to submit a PR!

PragmaTwice avatar Aug 30 '22 13:08 PragmaTwice