[PATCH] D44602: [clang-tidy] readability-function-size: add VariableThreshold param.

Roman Lebedev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Mar 17 14:04:09 PDT 2018


lebedev.ri created this revision.
lebedev.ri added reviewers: alexfh, hokein, xazax.hun, JonasToth, aaron.ballman.
lebedev.ri added a project: clang-tools-extra.
Herald added a subscriber: rnkovacs.

Pretty straight-forward, just count all the variable declarations in the function's body, and if more than the configured threshold - do complain.

Note that this continues perverse practice of disabling the new option by default.
I'm not certain where is the balance point between not being too noisy, and actually enforcing the good practice.
If we really want to not disable this by default, but also to not cause too many new warnings, we could default to 50 or so.
But that is a lot of variables too...

      

I was able to find one coding style referencing variable count:

- https://www.kernel.org/doc/html/v4.15/process/coding-style.html#functions

  > Another measure of the function is the number of local variables. They shouldn’t exceed 5-10, or you’re doing something wrong.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44602

Files:
  clang-tidy/readability/FunctionSizeCheck.cpp
  clang-tidy/readability/FunctionSizeCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/readability-function-size.rst
  test/clang-tidy/readability-function-size.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44602.138828.patch
Type: text/x-patch
Size: 10597 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180317/c59cc884/attachment-0001.bin>


More information about the cfe-commits mailing list