c52e7bcf1adccc622a67c5843763f3a28ba3312b
[lldb.git] / clang-tools-extra / test / clang-tidy / checkers / readability-function-cognitive-complexity-flags.cpp
1 // RUN: %check_clang_tidy %s readability-function-cognitive-complexity %t -- \
2 // RUN:   -config='{CheckOptions: \
3 // RUN:             [{key: readability-function-cognitive-complexity.Threshold, \
4 // RUN:               value: 0}, \
5 // RUN:              {key: readability-function-cognitive-complexity.DescribeBasicIncrements, \
6 // RUN:               value: "false"} ]}'
7 // RUN: %check_clang_tidy -check-suffix=THRESHOLD5 %s readability-function-cognitive-complexity %t -- \
8 // RUN:   -config='{CheckOptions: \
9 // RUN:             [{key: readability-function-cognitive-complexity.Threshold, \
10 // RUN:               value: 5}, \
11 // RUN:              {key: readability-function-cognitive-complexity.DescribeBasicIncrements, \
12 // RUN:               value: "false"} ]}'
13
14 void func_of_complexity_4() {
15   // CHECK-NOTES: :[[@LINE-1]]:6: warning: function 'func_of_complexity_4' has cognitive complexity of 4 (threshold 0) [readability-function-cognitive-complexity]
16   if (1) {
17     if (1) {
18     }
19   }
20   if (1) {
21   }
22 }
23
24 #define MacroOfComplexity10 \
25   if (1) {                  \
26     if (1) {                \
27       if (1) {              \
28         if (1) {            \
29         }                   \
30       }                     \
31     }                       \
32   }
33
34 void function_with_macro() {
35   // CHECK-NOTES: :[[@LINE-1]]:6: warning: function 'function_with_macro' has cognitive complexity of 11 (threshold 0) [readability-function-cognitive-complexity]
36   // CHECK-NOTES-THRESHOLD5: :[[@LINE-2]]:6: warning: function 'function_with_macro' has cognitive complexity of 11 (threshold 5) [readability-function-cognitive-complexity]
37
38   MacroOfComplexity10;
39
40   if (1) {
41   }
42 }