llvm-project/clang-tools-extra/clang-tidy/readability
Roman Lebedev eb6d821cda [clang-tidy] readability-function-size: fix nesting level calculation
Summary:
A followup for D32942.

Malcolm Parsons has provided a valid testcase that the initial version of the check complained about nested `if`'s.
As it turns out, the culprit is the **partially** un-intentional `switch` fallthrough.
So rewrite the NestingThreshold logic without ab-using+mis-using that switch with fallthrough, and add testcases with nested `if`' where there should be a warning and shouldn't be a warning. This results in a cleaner, simpler code, too.

I guess, now it would be actually possible to pick some reasonable default for `NestingThreshold` setting.

Fixes PR33454.

Reviewers: malcolm.parsons, alexfh

Reviewed By: malcolm.parsons

Subscribers: sbenza, xazax.hun, cfe-commits, aaron.ballman

Tags: #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D34202

llvm-svn: 305554
2017-06-16 13:07:47 +00:00
..
AvoidConstParamsInDecls.cpp [clang-tools-extra] Format sources with clang-format. NFC. 2016-11-08 07:50:19 +00:00
AvoidConstParamsInDecls.h [clang-tidy] Fix MSVC build. 2016-03-30 12:35:05 +00:00
BracesAroundStatementsCheck.cpp (no commit message) 2017-05-25 11:43:06 +00:00
BracesAroundStatementsCheck.h [clang-tools-extra] Format sources with clang-format. NFC. 2016-11-08 07:50:19 +00:00
CMakeLists.txt [clang-tidy] Add readability-misleading-indentation check. 2017-02-14 10:03:27 +00:00
ContainerSizeEmptyCheck.cpp Extend readability-container-size-empty to add comparisons to empty-state objects. 2017-04-24 14:57:09 +00:00
ContainerSizeEmptyCheck.h [clang-tidy] Update docs for clang-tidy checks. NFC 2015-08-27 18:01:58 +00:00
DeleteNullPointerCheck.cpp [clang-tidy] Small cleanup. NFC. 2017-03-20 22:15:19 +00:00
DeleteNullPointerCheck.h [clang-tidy] Fix for bug 31838: readability-delete-null-pointer does not work for class members 2017-02-12 20:09:59 +00:00
DeletedDefaultCheck.cpp [clang-tidy] Add a readability-deleted-default clang-tidy check. 2016-04-13 11:33:40 +00:00
DeletedDefaultCheck.h [clang-tidy] Add a readability-deleted-default clang-tidy check. 2016-04-13 11:33:40 +00:00
ElseAfterReturnCheck.cpp [clang-tidy] Fixed readability-else-after-return for cascade statements 2016-11-04 16:32:14 +00:00
ElseAfterReturnCheck.h [clang-tidy] Update docs for clang-tidy checks. NFC 2015-08-27 18:01:58 +00:00
FunctionSizeCheck.cpp [clang-tidy] readability-function-size: fix nesting level calculation 2017-06-16 13:07:47 +00:00
FunctionSizeCheck.h [clang-tidy] readability-function-size: add NestingThreshold param. 2017-06-09 14:22:10 +00:00
IdentifierNamingCheck.cpp [clang-tidy] Update IdentifierNamingCheck to remove extra leading/trailing underscores 2017-04-26 16:39:11 +00:00
IdentifierNamingCheck.h [clang-tidy] clang-format the last patch. NFC 2017-03-22 12:50:05 +00:00
ImplicitBoolCastCheck.cpp [clang-tidy] Optimize readability-implicit-bool-cast, NFC 2017-05-16 16:40:46 +00:00
ImplicitBoolCastCheck.h [clang-tidy] readability-implicit-bool-cast forgets to store its options. 2016-08-16 11:15:05 +00:00
InconsistentDeclarationParameterNameCheck.cpp [clang-tools-extra] Format sources with clang-format. NFC. 2016-11-08 07:50:19 +00:00
InconsistentDeclarationParameterNameCheck.h [clang-tidy] Add inconsistent declaration parameter name check 2015-09-10 10:07:11 +00:00
MisleadingIndentationCheck.cpp [clang-tidy] readability-misleading-indentation: fix chained if 2017-03-17 09:58:30 +00:00
MisleadingIndentationCheck.h [clang-tidy] readability-misleading-indentation: fix chained if 2017-03-17 09:58:30 +00:00
MisplacedArrayIndexCheck.cpp [clang-tidy] readability-misplaced-array-index: add new check that warns when array index is misplaced. 2016-09-12 12:04:13 +00:00
MisplacedArrayIndexCheck.h [clang-tidy] readability-misplaced-array-index: add new check that warns when array index is misplaced. 2016-09-12 12:04:13 +00:00
NamedParameterCheck.cpp [clang-tidy] readability-named-parameter: don't complain about implicit parameters 2015-11-06 00:19:21 +00:00
NamedParameterCheck.h [clang-tidy] update links to Google Code Style in docs 2016-02-25 14:31:10 +00:00
NamespaceCommentCheck.cpp modernize-use-auto NFC fixes 2016-12-14 15:29:23 +00:00
NamespaceCommentCheck.h [clang-tidy] update links to Google Code Style in docs 2016-02-25 14:31:10 +00:00
NonConstParameterCheck.cpp [clang-tidy] readability-non-const-parameter: add new check that warns when function parameters should be const 2016-08-23 10:09:08 +00:00
NonConstParameterCheck.h [clang-tidy] readability-non-const-parameter: add new check that warns when function parameters should be const 2016-08-23 10:09:08 +00:00
ReadabilityTidyModule.cpp [clang-tidy] Add readability-misleading-indentation check. 2017-02-14 10:03:27 +00:00
RedundantControlFlowCheck.cpp [clang-tools-extra] Format sources with clang-format. NFC. 2016-11-08 07:50:19 +00:00
RedundantControlFlowCheck.h Add a new check, readability-redundant-control-flow, that check for some forms of redundant control flow statements. Currently checks for return statements at the end of a function with a void return type and continue statements at the end of looping statements. 2016-02-01 15:31:15 +00:00
RedundantDeclarationCheck.cpp [clang-tidy] readability-redundant-declaration false positive for defaulted function 2017-05-22 13:58:57 +00:00
RedundantDeclarationCheck.h [clang-tidy] Add check readability-redundant-declaration 2016-11-01 13:26:15 +00:00
RedundantFunctionPtrDereferenceCheck.cpp [clang-tidy] Add check for redundant function pointer dereferences 2016-12-13 08:04:11 +00:00
RedundantFunctionPtrDereferenceCheck.h [clang-tidy] Add check for redundant function pointer dereferences 2016-12-13 08:04:11 +00:00
RedundantMemberInitCheck.cpp [clang-tidy] Make 2 checks register matchers for C++ only. 2016-12-27 22:14:40 +00:00
RedundantMemberInitCheck.h [clang-tidy] Add check 'readability-redundant-member-init' 2016-10-20 16:08:03 +00:00
RedundantSmartptrGetCheck.cpp modernize-use-auto NFC fixes 2016-12-14 15:29:23 +00:00
RedundantSmartptrGetCheck.h [clang-tidy] Update docs for clang-tidy checks. NFC 2015-08-27 18:01:58 +00:00
RedundantStringCStrCheck.cpp Remove deprecated methods ast_matchers::BoundNodes::{getStmtAs,getDeclAs} 2016-12-13 16:19:19 +00:00
RedundantStringCStrCheck.h [clang-tidy] Update docs for clang-tidy checks. NFC 2015-08-27 18:01:58 +00:00
RedundantStringInitCheck.cpp [clang-tools-extra] Format sources with clang-format. NFC. 2016-11-08 07:50:19 +00:00
RedundantStringInitCheck.h Add a new check, readability-redundant-string-init, that checks unnecessary string initializations. 2016-02-25 23:57:23 +00:00
SimplifyBooleanExprCheck.cpp [clang-tidy] Partly rewrite readability-simplify-boolean-expr using RAV 2017-05-15 17:06:51 +00:00
SimplifyBooleanExprCheck.h [clang-tidy] Partly rewrite readability-simplify-boolean-expr using RAV 2017-05-15 17:06:51 +00:00
StaticDefinitionInAnonymousNamespaceCheck.cpp [clang-tidy] Use isStaticStorageClass ast matcher. 2016-09-27 07:58:52 +00:00
StaticDefinitionInAnonymousNamespaceCheck.h [clang-tools-extra] Format sources with clang-format. NFC. 2016-11-08 07:50:19 +00:00
UniqueptrDeleteReleaseCheck.cpp [clang-tools-extra] Format sources with clang-format. NFC. 2016-11-08 07:50:19 +00:00
UniqueptrDeleteReleaseCheck.h [clang-tools-extra] Format sources with clang-format. NFC. 2016-11-08 07:50:19 +00:00