我正在使用Android studio 1.4.1,我正在尝试设置findbug,但是即使用R和Manifest设置排除xml,也仍然会对它们进行分析。
我想:
findbugs,以避免R和所有这些生成的东西,比如ViewBinder和Lambda。分级文件:
apply plugin: 'findbugs'
apply plugin: 'pmd'
findbugs {
ignoreFailures = true
reportsDir = file("$project.buildDir/outputs/")
reportLevel = "low"
effort = "max"
excludeFilter = file("../setup/findbugs-exclude.xml")
}
pmd {
ignoreFailures = true
reportsDir = file("$project.buildDir/outputs/")
}
task findbugs(type: FindBugs, dependsOn: assembleDebug) {
description 'Run findbugs'
group 'verification'
classes = fileTree("build/intermediates/classes/debug/")
source = fileTree('src/main/java')
classpath = files()
reports {
xml.enabled = false
html.enabled = true
}
}
task pmd(type: Pmd, dependsOn: assembleDebug) {
description 'Run pmd'
group 'verification'
ruleSets = ["java-basic", "java-braces", "java-strings", "java-design", "java-unusedcode"]
source = fileTree('src/main/java')
reports {
xml.enabled = false
html.enabled = true
}
}
check.doLast {
project.tasks.getByName("findbugs").execute()
project.tasks.getByName("pmd").execute()
}findbugs-exclude.xml
<?xml version="1.0" encoding="UTF-8"?>
<FindBugsFilter>
<Match>
<Class name="~.*\.R\$.*" />
</Match>
<Match>
<Class name="~.*\.Manifest\$.*" />
</Match>
</FindBugsFilter>响应:
Code analyzed:
/Users/me/Documents/test-android/app/build/intermediates/classes/debug/android/support/design/R$anim.class
/Users/me/Documents/test-android/app/build/intermediates/classes/debug/android/support/design/R$attr.class
/Users/me/Documents/test-android/app/build/intermediates/classes/debug/android/support/design/R$bool.class
/Users/me/Documents/test-android/app/build/intermediates/classes/debug/android/support/design/R$color.class
/Users/me/Documents/test-android/app/build/intermediates/classes/debug/android/support/design/R$dimen.class
/Users/me/Documents/test-android/app/build/intermediates/classes/debug/android/support/design/R$drawable.class
/Users/me/Documents/test-android/app/build/intermediates/classes/debug/android/support/design/R$id.class
/Users/me/Documents/test-android/app/build/intermediates/classes/debug/android/support/design/R$integer.class
/Users/me/Documents/test-android/app/build/intermediates/classes/debug/android/support/design/R$layout.class
/Users/me/Documents/test-android/app/build/intermediates/classes/debug/android/support/design/R$string.class
UPM Private method com.test.android.player.service.PlayerServicePresenter$$Lambda$1.get$Lambda(PlayerServicePresenter) is never called
UPM Private method com.test.android.sign_up.SignUpActivity$$Lambda$1.get$Lambda(SignUpActivity) is never called
UPM Private method com.test.android.sign_up.SignUpActivity$$Lambda$4.get$Lambda(SignUpActivity) is never called
UPM Private method com.test.android.sign_up.SignUpPresenter$$Lambda$1.get$Lambda(SignUpPresenter) is never called
UPM Private method com.test.android.sign_up.SignUpPresenter$$Lambda$2.get$Lambda(SignUpPresenter) is never called
UPM Private method com.test.android.tutorial.TutorialActivity$$Lambda$1.get$Lambda(TutorialActivity) is never called
UPM Private method com.test.android.tutorial.TutorialPresenter$$Lambda$1.get$Lambda(TutorialPresenter, String) is never called
UPM Private method com.test.android.tutorial.TutorialPresenter$$Lambda$2.get$Lambda(TutorialPresenter) is never called
UPM Private method com.test.android.tutorial.TutorialPresenter$$Lambda$3.get$Lambda(TutorialPresenter) is never called
UPM Private method com.test.android.utils.base.BaseView$$Lambda$1.get$Lambda(BaseView) is never called发布于 2015-11-12 22:55:49
也许这个能帮上忙。只需将以下代码添加到findbugs expde.xml中:
<Match>
<Bug code="UPM" />
<Class name="~.*\$\$Lambda\$.*"/>
</Match>https://stackoverflow.com/questions/33578837
复制相似问题