findbugs、retrolambda 和 Android
findbugs, retrolambda and Android
我正在使用 Android studio 1.4.1
并且我正在尝试设置 findbugs 但即使使用 R
设置排除 xml 和 Manifest findbugs 仍然分析它们。
我想:
- 设置
findbugs
和 android 以避免 R
和所有那些生成的东西,比如 ViewBinder
和 Lambda
.
Gradle 文件:
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.get$Lambda(PlayerServicePresenter) is never called
UPM Private method com.test.android.sign_up.SignUpActivity$$Lambda.get$Lambda(SignUpActivity) is never called
UPM Private method com.test.android.sign_up.SignUpActivity$$Lambda.get$Lambda(SignUpActivity) is never called
UPM Private method com.test.android.sign_up.SignUpPresenter$$Lambda.get$Lambda(SignUpPresenter) is never called
UPM Private method com.test.android.sign_up.SignUpPresenter$$Lambda.get$Lambda(SignUpPresenter) is never called
UPM Private method com.test.android.tutorial.TutorialActivity$$Lambda.get$Lambda(TutorialActivity) is never called
UPM Private method com.test.android.tutorial.TutorialPresenter$$Lambda.get$Lambda(TutorialPresenter, String) is never called
UPM Private method com.test.android.tutorial.TutorialPresenter$$Lambda.get$Lambda(TutorialPresenter) is never called
UPM Private method com.test.android.tutorial.TutorialPresenter$$Lambda.get$Lambda(TutorialPresenter) is never called
UPM Private method com.test.android.utils.base.BaseView$$Lambda.get$Lambda(BaseView) is never called
也许这会有所帮助。只需添加到 findbugs-exclude.xml 此代码:
<Match>
<Bug code="UPM" />
<Class name="~.*$$Lambda$.*"/>
</Match>
我正在使用 Android studio 1.4.1
并且我正在尝试设置 findbugs 但即使使用 R
设置排除 xml 和 Manifest findbugs 仍然分析它们。
我想:
- 设置
findbugs
和 android 以避免R
和所有那些生成的东西,比如ViewBinder
和Lambda
.
Gradle 文件:
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.get$Lambda(PlayerServicePresenter) is never called
UPM Private method com.test.android.sign_up.SignUpActivity$$Lambda.get$Lambda(SignUpActivity) is never called
UPM Private method com.test.android.sign_up.SignUpActivity$$Lambda.get$Lambda(SignUpActivity) is never called
UPM Private method com.test.android.sign_up.SignUpPresenter$$Lambda.get$Lambda(SignUpPresenter) is never called
UPM Private method com.test.android.sign_up.SignUpPresenter$$Lambda.get$Lambda(SignUpPresenter) is never called
UPM Private method com.test.android.tutorial.TutorialActivity$$Lambda.get$Lambda(TutorialActivity) is never called
UPM Private method com.test.android.tutorial.TutorialPresenter$$Lambda.get$Lambda(TutorialPresenter, String) is never called
UPM Private method com.test.android.tutorial.TutorialPresenter$$Lambda.get$Lambda(TutorialPresenter) is never called
UPM Private method com.test.android.tutorial.TutorialPresenter$$Lambda.get$Lambda(TutorialPresenter) is never called
UPM Private method com.test.android.utils.base.BaseView$$Lambda.get$Lambda(BaseView) is never called
也许这会有所帮助。只需添加到 findbugs-exclude.xml 此代码:
<Match>
<Bug code="UPM" />
<Class name="~.*$$Lambda$.*"/>
</Match>