4

我正在使用 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.

我如何使用 cpplint:

我使用cpplint此命令检查源文件夹中的所有文件: cpplint src/*.c

好吧,有一个特殊文件foo.cc不能检查。所以我尝试创建一个CPPLIN.cfg使用该exclude_files属性。我的文件如下所示:

set noparent
filter=-build/include_dir
exclude_files=foo.cc

尽管如此foo.cc,仍然检查。

我已经尝试过做的事情:

我试过了 exclude_files=/.*\.cc/。这应该排除所有以 *.cc 结尾的文件。尽管如此,仍然检查所有文件。

我试图filter从文件中删除我的。这导致了比以前更多的错误。所以我现在确定我的CPPLINT.cfg文件被 cpplint 找到了。

问题:

如何正确使用 cpplint 中的 exclude_files 正则表达式?

4

1 回答 1

6

结果显然该文档是错误的:exclude_files仅排除与 相同目录中的文件CPPLINT.cfg,而不排除子目录中的文件。见https://github.com/google/styleguide/issues/220

所以解决方案是创建src/CPPLINT.cfg并放入exclude_files=.*\.cc它。

于 2018-05-11T11:27:42.703 回答