【问题标题】:How to generate Codenarc report for Main and Test classes using different rule-sets?如何使用不同的规则集为 Main 和 Test 类生成 Codenarc 报告?
【发布时间】:2013-01-16 12:26:52
【问题描述】:

我在我的项目中使用 CodeNarc 来编写最佳实践,它工作得非常好。一般来说,Codenarc 根据配置文件中定义的规则集(在我的例子中为 codenarc.xml)为所有 Main 类和 Test 类分别生成报告。我已经习惯在我的项目中遵循代码sn-p:

apply plugin: 'codenarc'

dependencies {
    codenarc group: 'org.codenarc', name: 'CodeNarc', version: '0.17'
}

codenarc {
    configFile = file('src/conf/codenarc.xml')
}

我不想强制执行 Main 和 Test 类的所有规则(例如,我可能想从 Test 类中排除一些规则集)。有什么办法吗?

【问题讨论】:

    标签: gradle codenarc


    【解决方案1】:

    您可以单独配置CodeNarc 任务:

    codenarcMain {
        configFile = ...
    }
    
    codenarcTest {
        configFile = ...
    }
    

    PS:我推荐使用简写依赖表示法:

    dependencies {
        codenarc "org.codenarc:CodeNarc:0.17"
    }
    

    【讨论】:

      猜你喜欢
      • 2011-08-17
      • 1970-01-01
      • 1970-01-01
      • 2018-01-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多