[PATCH] D31252: Clang-tidy: add readability-compound-statement-size check.

Jonas Toth via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 22 12:58:10 PDT 2017


JonasToth added a comment.

Hi and welcome to the clang/llvm community :)

It seems that you took `readability-size` as starting point and modified it. Thats a good way to learn!

My opinion is, that this should land in `readability-function-size`. This is somewhat recursive to function size. Whenever there is a compundstmt, the same (or maybe other constraints) exist for that compound statement. 
Thats, in my opinion, the connecting factor to `function-size`.
It should be configurable. Maybe something like "global" constaint on the function (e.g. max 800 lines in total) and "local" constraints for subcomponents. These two layers of configurability kinda already exist. Your check would implement the recursive and local part, and function size the global.

What are your thoughts on that? But generally i like that approach to limit subparts of the functions as well.
Recommending to refactor such code to use functions would be a good diagnostic in my opinion.

When creating or modifying checks it would be nice to include a note in the ReleaseNotes as well (in doc/ i believe), but i think we should discuss the placement of this functionality first.


https://reviews.llvm.org/D31252





More information about the cfe-commits mailing list