如何使用 cpplint 忽略文件夹

How to ignore folders with cpplint

本文关键字:文件夹 cpplint 何使用      更新时间:2023-10-16

你如何告诉cpplint忽略特定名称的文件夹?

我有.build包含自动生成文件的文件夹,当我运行cpplint --recursive src时,它会遍历这些文件夹并发现大量我不关心的错误。

我尝试使用 --exclude 参数,例如:

cpplint --recursive --exclude=.build src

但这没有效果。

我也试过:

cpplint --recursive --exclude=*/.build src

以及其他使用通配符的变体,但这些变体也没有效果。

试试这个:

./cpplint.py 
    $( find . -name *.h -or -name *.cc | grep -vE "^./<excluded_folder_name>/" )

您可以将此参数与 cpplint 命令一起使用:

find $PWD -not ( -path $PWD/<folder1> -prune ) -not ( -path $PWD/<folder2> -prune ) -not ( -path $PWD/<folder3> -prune ) -name *.cpp

要在所有子文件夹上递归运行而不检查特定的文件夹或文件,第一个参数应该从递归检查中排除,然后才启用递归。

我正在使用以下命令:

cpplint --exclude=./src/autogenerated --recursive ./src/ > /dev/null 2> ./codestyle.log

在这种情况下,cpplint将以递归方式在所有文件夹中运行./src但会省略./src/autogenerated dir
所有标准输出都将重定向到/dev/null 垃圾箱,所有我要修复的错误都将重定向到我的日志文件./codestyle.log

cpplint --exclude=fold/ * --exclude=fold/ * / * --exclude=fold/ * / * / * 
   exam.c