当我对 Android 项目运行 Sonar 分析时,我总是收到很多有关 Android 资源编译生成的 .class 文件的消息,如下所示
Run sonar: The class 'foo.bar.R$string' could not be matched to its original source file. It might be a dynamically generated class.
我猜这些消息来自 Findbugs。
我尝试从 Sonar 分析中排除 **/R.class
**/R$*.class
,但没有成功。
关于如何消除此类消息有什么想法吗?
最佳答案
问题已通过 sonar.findbugs.excludesFilters
属性解决
sonarqube {
properties {
property 'sonar.findbugs.excludesFilters', 'findbugs-filter.xml'
}
}
findbugs-filter.xml 是
<FindBugsFilter>
<Match>
<Or>
<Class name="~.*\.R\$.*"/>
<Class name="~.*\.Manifest\$.*"/>
</Or>
</Match>
</FindBugsFilter>
关于android - 在android项目上运行 Sonar : The class 'foo.bar.R$string' could not be matched to its original source file,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45137864/