如何解决为什么叮当整洁的可读性隔离声明不修复代码?
我尝试在 clang-tidy 中使用 readability-isolate-declaration 检查,但没有修复。 test.cpp 文件中的代码示例:
void f() {
int a = 0,b = 1,c = 2;
}
我所做的:
clang-tidy -checks='readability-isolate-declaration' -fix test.cpp
输出:
Error while trying to load a compilation database:
Could not auto-detect compilation database for file "test.cpp"
No compilation database found in /home/anzipex/Downloads/clang-test or any parent directory
fixed-compilation-database: Error while opening fixed database: No such file or directory
json-compilation-database: Error while opening JSON database: No such file or directory
Running without flags.
解决方法
这里有几个问题:
-
readability-isolate-declaration
检查在 clang-tidy 6 中不存在。升级到更新的版本 - 如果您没有编译数据库,您可以使用
--
(双破折号)来指定编译选项。即使您指定 none,这也会告诉 clang-tidy 编译文件。请参阅documentation。 - 您没有告诉 clang-tidy 排除您想要的检查之外的其他检查
命令应该是这样的:
clang-tidy -checks='-*,readability-isolate-declaration' test.cpp -fix --
输出:
void f() {
int a = 0;
int b = 1;
int c = 2;
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。