【问题标题】:How to ignore folders with cpplint如何使用 cpplint 忽略文件夹
【发布时间】:2017-06-22 22:30:37
【问题描述】:

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

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

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

cpplint --recursive --exclude=.build src

但这没有任何效果。

我也试过了:

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

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

【问题讨论】:

    标签: c++ cpplint


    【解决方案1】:

    试试这个:

    ./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
    

    【讨论】:

      【解决方案2】:

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

      我正在使用以下命令:

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

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

      【讨论】:

      • 我收到此错误:致命错误:无效参数:选项 --exlude 无法识别
      • 你说得对,我的错,应该是--exclude="folder/path",谢谢
      【解决方案3】:
      cpplint --exclude=fold/ * --exclude=fold/ * / * --exclude=fold/ * / * / * 
         exam.c
      

      【讨论】:

      • 所提供的答案被标记为低质量帖子以供审核。以下是How do I write a good answer? 的一些指南。提供的这个答案可能是正确的,但它可以从解释中受益。仅代码答案不被视为“好”答案。来自review
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-11-02
      • 1970-01-01
      • 1970-01-01
      • 2016-07-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多