Skip to content

Commit 72e4ea1

Browse files
authored
[CI] Enable function cognitive complexity check in clang-tidy (#165)
1 parent 0cda45b commit 72e4ea1

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

Diff for: .clang-tidy

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ Checks: >
2323
-modernize-loop-convert,
2424
-modernize-use-nodiscard,
2525
-modernize-use-trailing-return-type,
26-
-readability-function-cognitive-complexity,
2726
-readability-identifier-length,
2827
-readability-magic-numbers,
2928
-readability-named-parameter
@@ -79,3 +78,5 @@ CheckOptions:
7978
value: lower_case
8079
- key: readability-identifier-naming.IgnoreMainLikeFunctions
8180
value: 1
81+
- key: readability-function-cognitive-complexity.Threshold
82+
value: 25 # default: 25

Diff for: modules/ref/most_different_neighbor_elements/func_tests/ref_tests.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,9 @@ TEST(most_different_neighbor_elements, check_int64_t) {
138138
for (size_t i = 0; i < in.size(); i++) {
139139
if (i % 3 == 0) {
140140
in[i] = 10;
141-
}
142-
if (i % 3 == 1) {
141+
} else if (i % 3 == 1) {
143142
in[i] = 30;
144-
}
145-
if (i % 3 == 2) {
143+
} else { // (i % 3 == 2)
146144
in[i] = 70;
147145
}
148146
}

Diff for: modules/ref/nearest_neighbor_elements/func_tests/ref_tests.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,9 @@ TEST(nearest_neighbor_elements, check_int64_t) {
138138
for (size_t i = 0; i < in.size(); i++) {
139139
if (i % 3 == 0) {
140140
in[i] = 10;
141-
}
142-
if (i % 3 == 1) {
141+
} else if (i % 3 == 1) {
143142
in[i] = 30;
144-
}
145-
if (i % 3 == 2) {
143+
} else { // (i % 3 == 2)
146144
in[i] = 70;
147145
}
148146
}

0 commit comments

Comments
 (0)