问题标签 [cpplint]

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 投票
1 回答
1658 浏览

atom-editor - uncrustify google style c++ config

I am using uncrustify and atom-beautify in atom.io to format my C++ code according to google styling guide. I am using CPPlint to verify whether the code is formatted correctly. I am using the config file from https://gist.githubusercontent.com/philectron/1a1e1ccb06d5643cd61d85fc5ecaf429/raw/8813567b8f7dd49003228e19c3d10719b49995a1/uncrustify-preferences.cfg. But after beautifying, cpplint is reporting the following problems.

  1. "At least two spaces is best between code and comments [whitespace/comments]" is not enforced and I am getting this error in multiple places. The answer for this question at Uncrustify - How do I align trailing comments by two-space gap? is not working.
  2. "protected: should be indented +1 space inside." I am getting the same error for private and public as well.

If this is not the right way, how can I beautify and lint inside atom.io.

0 投票
1 回答
11756 浏览

c++ - 禁用来自 cpplint 的特定警告

运行 cpplint 时,我遇到了一些我想完全禁用的警告。特别是版权信息和空格:

range.h:0:未找到版权信息。你应该有一行:

“版权 [年份]” [法律/版权] [5]

range.h:10:代码和注释之间最好至少有两个空格

[空白/评论] [2]

我该如何做到这一点?理想情况下会修改 CPPLINT.cfg 文件,但我会采用内联注释或命令行标志。我找不到任何有关禁用规则的文档。

0 投票
1 回答
379 浏览

coding-style - Advanced code style in Clion

I want to have google-style like code style checker that would automatically run within Clion.

However, what I found as solutions (predeclared code style for google and others, direct Editor settings and EditorConfig support in Clion help) are all rather primitive. For example, I want to use snake case with final underscore for class member fileds (e.g. my_class_member_) and usual snake case for function arguments (e.g. some_argument), and none of the suggested options would do the trick as far as I am concerned. Furthermore, some politics associated with endless loops and so are to be added, which is even more context-specific.

I consider creating cpplint.py-like script for this, but it is going to be very time-consuming and is likely to be run outside Clion. Are there any elegant ways to solve my problem?

0 投票
1 回答
390 浏览

c++ - 为什么 cpplint 没有发现丢失的分号?

我在 NodeJS 中使用 linter 已经有一段时间了,eslint并且已经开始cpplint在我的 Arduino 库中使用 C++。它似乎没有掌握一些基本知识,例如缺少分号(但它确实识别出错误行上的大括号)。它似乎也没有区分用于缩进的空格和制表符或实现文件中缩进严重的代码。

来自 NodeJS 背景,cpplint似乎遗漏了很多检查,还是我完全错过了重点?

0 投票
1 回答
3857 浏览

c++ - C++ 中不允许使用静态/全局变量

我在我的 C++ 类中定义了一个全局变量,如下所示:

但是cpplint告诉我:

不允许使用静态/全局字符串变量。[运行时/字符串] [4]

你知道为什么吗?

0 投票
0 回答
202 浏览

c++ - CPP lint:你能强制对类变量使用这个吗?

是否有一个 lint 脚本可以强制将其用于类变量?

前任 -

应该 -

0 投票
1 回答
65 浏览

c++ - Sublimelinter cpplint 无法识别 ipp 文件

我正在尝试设置 sublime text 3 来进行 C++ 开发。

我安装了 cpplint 并按照安装说明进行操作。虽然文档表明 cpplint 将对语法设置为“C++”的任何文件进行 lint,但对我来说并非如此。cpplint 仅在我的文件具有扩展名“cpp”或“hpp”时才有效。当我将文件扩展名从“hpp”更改为“ipp”时,linter 停止工作。

有人知道我需要做什么配置吗?

0 投票
0 回答
51 浏览

python - 查找/索引使用正则表达式找到的多条语句

我正在寻找一种方法来解析 cpplint.py 的 Junit XML 输出并对结果进行分类。现在输出被放入一个文本文件中,我想让它更容易阅读报告。cpplint.py 按行号、错误、错误类别和严重性报告每个错误。每个错误看起来像这样: 65: { should almost always be at the end of the previous line [whitespace/braces] [4]linter 还解析一堆不同的文件并将它们列为一个长字符串,大多数似乎由换行符分隔,但有些不是。每个文件都由这样的标题分解: <testcase name="proj/apps/prod/nnj/src/prod1.cpp"><failure>

我正在尝试找到一种方法来按项目分解每个项目并更好地呈现数据。我尝试使用正则表达式逐行迭代,但许多错误都进入下一行并且它们被遗漏了,它也没有捕获我的标题。

这是我可以用一个正则表达式完成的事情,还是需要多个?

我可以使用正则表达式附加文件并在每个错误的末尾添加换行符吗?

如果我可以合并主标题,那就太好了:

<?xml version="1.0" encoding="UTF-8" ?> <testsuite errors="0" failures="177" name="cpplint" tests="177">

所以我可以解释总回购错误,但它是同一个问题。任何帮助表示赞赏。

0 投票
3 回答
4337 浏览

cmake - 如何在 CMake 中使用 cpplint 代码样式检查?

我发现的唯一在线资源是 CMake 文档CMAKE_<LANG>_CPPLINT此处链接)和此示例(此处链接),但我无法弄清楚如何在 CMakeLists.txt 文件中实际使用它。我尝试了提供的示例,但无法使其工作。仅供参考,我按照此处的说明安装了 cpplint 。

到目前为止,我可以使用以下 CMake 命令在 CMakeLists.txt 中运行 cpplint python 脚本:

但是,我很确定这不是正确的方法。

0 投票
1 回答
176 浏览

c++ - CppLint Cast Char* 错误

我在 CppLint 上遇到了这个错误:

当我尝试投射这样的东西时:

但如果我这样做:

我在构建时遇到此错误:

请问你能帮帮我吗 ?