Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

clang-format kinda does what it says - parses your code, then indents and spaces it according to the rules. It doesn't try to understand code intent, it just looks at syntax.

clang-tidy does some deeper inspection and can be used to flag things that are "bad practice", not just "bad formatting". There's a big list of checks here:

https://clang.llvm.org/extra/clang-tidy/checks/list.html

At a minimum, I like to enable all the `bugprone-*` tidy rules, they just seem sensible to turn on.

e.g. https://clang.llvm.org/extra/clang-tidy/checks/bugprone-stri...

You're able to run `clang-tidy -fix` to automate fixing of many of the things it will flag.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: