问题标签 [clang-tidy]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
0 回答
243 浏览

c++ - 自动将 clang-tidy 重构应用到 CLion 项目文件夹

有没有办法通过应用所有clang-tidy快速修复来运行并自动重构整个 CLion 项目源代码?

0 投票
1 回答
2289 浏览

c++ - 我想在 CentOS 7 上安装 clang-tidy 作为 cpp 的 linter 但找不到包

我能够通过 epel 存储库安装 llvm 和 clang。但是,它们不包括 clang-tidy 二进制文件。我一直在搜索 llvm 网站,但他们没有任何可用于 CentOS 7 的软件包。 ius 存储库也没有 clang-tidy。我想在从源代码构建之前仔细检查。谢谢你。

0 投票
1 回答
166 浏览

c++ - c/c++ linting 或格式检查代码文档

无论如何使用 clang-tidy 或 cppcheck 或任何其他工具来检查缺少的文档,包括对类成员的文件头注释。我假设doxygen。

0 投票
3 回答
7418 浏览

clang - 多行的 Clang-Tidy `NOLINT`?

我正在开发一个 C++ 项目,该项目有一些自动生成的大段代码,我不想被 linted。有没有类似于//NOLINT可以应用于多行的注释的东西?如下所示:

我只能在网上找到一个建议,即应该实施。有没有办法避免在// NOLINT每一行的末尾写?

0 投票
1 回答
583 浏览

c++ - 如何在没有 reinterpret_cast 的情况下使用 dlsym() 加载函数?

我正在尝试使用 clang-tidy 来执行 C++ 核心指南。虽然它确实有很多有效点,但有一件事我无法真正解决:dlsym 返回一个void*我需要以某种方式将其变成正确的函数指针。为此,我使用reinterpret_cast. 由于指南禁止这样做,我对此有警告。当然,我可以在//NOLINT任何地方发表评论,但我正在寻找一种不使用的解决方案,reinterpret_cast这样警告就会消失。

有没有解决这个问题的方法?

0 投票
1 回答
368 浏览

c++ - Clang-tidy 不正确的舍入

clang-tidy [bugprone-incorrect-roundings]检查的文档说:

数字 0.499999975(小于 0.5 的最小可表示浮点数)四舍五入为 1.0

据我所知,下面的最小浮点数0.50.4999999702,而不是0.499999975。但尽管如此,这两个数字都为我提供0了天真的四舍五入计算的值

我错过了什么吗?

0 投票
1 回答
136 浏览

c++ - 如何让 clang-tidy 一个接一个地依次应用 FixItHints?

我正在写clang-tidy check,它将在正确的位置移动评论:

前:

后:

我正在尝试删除/// comment 3然后将其插入之前void func3();

但首先 clang-tidy-check 应该阅读之前的评论void func3();。检查读取/// comment 2,因为/// comment 2没有时间删除。

如何让 tidy-check 按找到方法的顺序应用修复?

0 投票
1 回答
1798 浏览

c++ - 模板类 + 委托构造函数 = 未初始化的字段?(整洁)

我正在运行 clang-tidy 8.0 并收到警告:

constructor does not initialize these fields:

在模板类上使用委托构造函数时。我想知道这是否是我应该压制的误报,或者我的代码是否确实是错误的。

有问题的示例代码是这样的:

在此代码上运行 clang-tidy 时:

clang-tidy-8 --checks=* test.cpp

除其他外,我得到:

但是,如果我从类中删除模板并使其成为普通类,则不会出现此类错误。

在模板类上使用委托构造函数时我是否缺少某些东西,或者这是 clang-tidy 中的错误?

谢谢!

0 投票
1 回答
1040 浏览

c++ - clang-tidy duplicate errors when invoked by CMake

I have a problem with clang-tidy. Basically, it analyzes each of my project files, but for the headers that are included in more than one .cpp file, it prints redundant errors.

The problem is, Visual Studio Code has its PROBLEMS tab, which picks every single one of them, so for a file definitions.hpp which is included in 3 separate .cpp files I end up with something like this:

enter image description here

The console output is:

So, is there a way to prevent something like this? I mean it doubles of triples my error list.

@Edit

So this is my clang-tidy-relevant part of CMakeLists.txt:

And this is my .clang-tidy file:

0 投票
1 回答
1807 浏览

cmake - 安装后找不到 Clang-Tidy

在我安装了 CLion 之后。我使用brew install llvm@7并安装成功。

CMake 选项设置为

Clang-Tidy 的路径也是正确的。

Clang-Tidy 的路径

但是它仍然会出现错误“未找到 Clang-Tidy”

if(NOT CLANG_TIDY_EXECUTABLE) message(FATAL_ERROR "clang-tidy not found") endif()

项目

那么 Clang-Tidy 不可用的原因可能是什么?我需要使用它,因为 Clang-tidy 是我课程中使用的 linter。(我是 CLion 和 CMake 的新手)

谢谢!