简体   繁体   English

为什么 cpplint 不关心缩进/空格,还有什么替代方法?

[英]Why cpplint doesn't care about indentation/spaces and what is the alternative?

This is my C++ code:这是我的 C++ 代码:

int    f()   {
               return 1 +      2;
                   }

I'm trying to run it through cpplint :我正在尝试通过cpplint运行它:

$ cpplint src/f.cpp
Done processing src/f.cpp

No errors found.未发现错误。 What am I doing wrong?我究竟做错了什么? Cpplint really does think that this code is properly formatted? Cpplint 真的认为这段代码的格式正确吗? If this is really the case, which style checker can help me catch errors in this piece of C++ code?如果真的是这样,哪个样式检查器可以帮助我在这段 C++ 代码中发现错误?

Cpplint only checks a few special indentation cases, it is not a complete style checker. Cpplint 只检查一些特殊的缩进情况,它不是一个完整的样式检查器。 The cause for this is that cpplint does not property parse files, but checks files line-by-line using regular expressions.造成这种情况的原因是 cpplint 不解析文件的属性,而是使用正则表达式逐行检查文件。 That makes it hard to write certain checks for issues that require reasoning about Multi-Line contexts.这使得为需要推理多行上下文的问题编写某些检查变得困难。

So cpplint does not check for the style flaws of your example.因此 cpplint 不会检查您的示例的样式缺陷。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM