eDe*_*ser 3 regex google-style-guide cpplint
我正在使用 cpplint 根据谷歌风格指南检查我的源代码。
Cpplint 的帮助说:
cpplint.py supports per-directory configurations specified in CPPLINT.cfg
files. CPPLINT.cfg file can contain a number of key=value pairs.
Currently the following options are supported:
"exclude_files" allows to specify a regular expression to be matched against
a file name. If the expression matches, the file is skipped and not run
through liner.
Example file:
filter=-build/include_order,+build/include_alpha
exclude_files=.*\.cc
The above example disables build/include_order warning and enables
build/include_alpha as well as excludes all .cc from being
processed by linter, in the current directory (where the .cfg
file is located) and all sub-directories.
Run Code Online (Sandbox Code Playgroud)
我如何使用cpplint:
我用cpplint这个命令来检查我的源文件夹中的所有文件:
cpplint src/*.c
嗯,有一个特殊的文件foo.cc不能检查。所以我尝试创建一个CPPLIN.cfg来使用该exclude_files属性。我的文件看起来像这样:
set noparent
filter=-build/include_dir
exclude_files=foo.cc
Run Code Online (Sandbox Code Playgroud)
尽管如此foo.cc仍然被检查。
我已经尝试做的事情:
我试过了 exclude_files=/.*\.cc/。这应该排除所有以 *.cc 结尾的文件。尽管如此,仍会检查所有文件。
我试图filter从文件中删除我的。这导致了比以前更多的错误。所以我现在确定我的CPPLINT.cfg文件是由 cpplint 找到的。
题:
如何正确使用 cpplint 中的 exclude_files 正则表达式?
显然,该文档是错误的:exclude_files仅排除与 同一目录中的文件CPPLINT.cfg,而不排除子目录中的文件。见https://github.com/google/styleguide/issues/220
所以解决方案是创建src/CPPLINT.cfg并放入exclude_files=.*\.cc它。
| 归档时间: |
|
| 查看次数: |
1866 次 |
| 最近记录: |