Clang-Tidy:可读性-功能-认知-complexity.DescribeBasicIncrements 值无效
Clang-Tidy : readability-function-cognitive-complexity.DescribeBasicIncrements value has no effect
虽然 运行 clang-tidy 在 https://clang.llvm.org/extra/clang-tidy/checks/readability-function-cognitive-complexity.html 提供的示例代码中参考 function3。
使用以下命令
clang-tidy.exe Example.cpp -config="{Checks: '-*,readability-*',CheckOptions: [{key: readability-function-cognitive-complexity.Threshold, value: 2},{key: readability-function-cognitive-complexity.DescribeBasicIncrements, value: false} ]}"
我低于输出。
\Example.cpp:2:5: warning: function 'function3' has cognitive complexity of 3 (threshold 2) [readability-function-cognitive-complexity]
int function3(bool var1, bool var2) {
^
\Example.cpp:3:3: note: +1, including nesting penalty of 0, nesting level increased to 1
if(var1) { // +1, nesting level +1
^
\Example.cpp:4:5: note: +2, including nesting penalty of 1, nesting level increased to 2
if(var2) // +2 (1 + current nesting level of 1), nesting level +1
^
\Example.cpp:4:13: warning: statement should be inside braces [readability-braces-around-statements]
if(var2) // +2 (1 + current nesting level of 1), nesting level +1
^
{
\Example.cpp:5:14: warning: 42 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
return 42;
所以,好像readability-function-cognitive-complexity.DescribeBasicIncrements
这个键没有作用。我也试过
{key: readability-function-cognitive-complexity.DescribeBasicIncrements, value: 'false'}`
{key: readability-function-cognitive-complexity.DescribeBasicIncrements, value: '0'}
{key: readability-function-cognitive-complexity.DescribeBasicIncrements, value: 0}
但仍然在增加认知复杂性的线路上进行了额外的诊断。
所以,我认为 readability-function-cognitive-complexity.DescribeBasicIncrements 坏了还是我做错了什么?
附加信息:
- clang 版本 12.0
这是您问题的根源:
Additional info:
- clang version 12.0
DescribeBasicIncrements
选项是在 this commit 中引入的,它不是 clang 12.0
的一部分
安装最新的 clang 版本,它应该可以正常工作。
虽然 运行 clang-tidy 在 https://clang.llvm.org/extra/clang-tidy/checks/readability-function-cognitive-complexity.html 提供的示例代码中参考 function3。
使用以下命令
clang-tidy.exe Example.cpp -config="{Checks: '-*,readability-*',CheckOptions: [{key: readability-function-cognitive-complexity.Threshold, value: 2},{key: readability-function-cognitive-complexity.DescribeBasicIncrements, value: false} ]}"
我低于输出。
\Example.cpp:2:5: warning: function 'function3' has cognitive complexity of 3 (threshold 2) [readability-function-cognitive-complexity]
int function3(bool var1, bool var2) {
^
\Example.cpp:3:3: note: +1, including nesting penalty of 0, nesting level increased to 1
if(var1) { // +1, nesting level +1
^
\Example.cpp:4:5: note: +2, including nesting penalty of 1, nesting level increased to 2
if(var2) // +2 (1 + current nesting level of 1), nesting level +1
^
\Example.cpp:4:13: warning: statement should be inside braces [readability-braces-around-statements]
if(var2) // +2 (1 + current nesting level of 1), nesting level +1
^
{
\Example.cpp:5:14: warning: 42 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
return 42;
所以,好像readability-function-cognitive-complexity.DescribeBasicIncrements
这个键没有作用。我也试过
{key: readability-function-cognitive-complexity.DescribeBasicIncrements, value: 'false'}`
{key: readability-function-cognitive-complexity.DescribeBasicIncrements, value: '0'}
{key: readability-function-cognitive-complexity.DescribeBasicIncrements, value: 0}
但仍然在增加认知复杂性的线路上进行了额外的诊断。 所以,我认为 readability-function-cognitive-complexity.DescribeBasicIncrements 坏了还是我做错了什么?
附加信息:
- clang 版本 12.0
这是您问题的根源:
Additional info:
- clang version 12.0
DescribeBasicIncrements
选项是在 this commit 中引入的,它不是 clang 12.0
安装最新的 clang 版本,它应该可以正常工作。