首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >findbugs,retrolambda和Android

findbugs,retrolambda和Android
EN

Stack Overflow用户
提问于 2015-11-07 03:31:33
回答 1查看 251关注 0票数 1

我正在使用Android studio 1.4.1,我正在尝试设置findbug,但是即使用R和Manifest设置排除xml,也仍然会对它们进行分析。

我想:

  1. 用android安装findbugs,以避免R和所有这些生成的东西,比如ViewBinderLambda

分级文件:

代码语言:javascript
复制
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

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?>
<FindBugsFilter>
  <Match>
    <Class name="~.*\.R\$.*" />
  </Match>
  <Match>
    <Class name="~.*\.Manifest\$.*" />
  </Match>
</FindBugsFilter>

响应:

代码语言:javascript
复制
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
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-11-12 22:55:49

也许这个能帮上忙。只需将以下代码添加到findbugs expde.xml中:

代码语言:javascript
复制
<Match>
    <Bug code="UPM" />
    <Class name="~.*\$\$Lambda\$.*"/>
</Match>
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33578837

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档