quality for code

gradle

Gradle User Guide

Gradle Plugin User Guide

使用 Groovy 的简单语法开发 Java 应用程序

Groovy Differences with Java

checkstyle

官网: http://checkstyle.sourceforge.net

Checkstyle 它定义了一系列可用的模块,每一个模块提供了严格程度(强制的,可选的…)可配置的检查规则。规则可以触发通知(notification),警告(warning)和错误(error)。

report

findbugs

官网: http://findbugs.sourceforge.net

filter-file

FindBugs 它是一个基于静态规则集的Java字节码分析器(所以你至少需要编译一次代码,然后才能够测试它)。它能检测到java程序中常见的错误。

report

pmd

官网: http://pmd.sourceforge.net/pmd-5.1.1/howtomakearuleset.html

What does it mean?

Pmd 它是一个基于静态规则集的Java源码分析器,工作有点类似Findbugs,但是(PMD)直接检查源代码而不是检查字节码。

它可以识别出潜在的如下问题:

  • 可能的bug——空的try/catch/finally/switch块。
  • 无用代码(Dead code):无用的本地变量,方法参数和私有方法。
  • 空的if/while语句。
  • 过度复杂的表达式——不必要的if语句,本来可以用while循环但是却用了for循环。
  • 可优化的代码:浪费性能的String/StringBuffer的使用。

report

lint

官网: http://tools.android.com/tips/lint-checks

android lint相关的源码:

Android-Lint 检查问题列表: lint –show or lint –list

android lintOptions 选项配置:

在gradle中忽略掉lint task

tasks.whenTaskAdded { task ->
    if (task.name.equals("lint")) {
        task.enabled = false
    }
}

Android 自动化测试

Android 测试教程:
http://wiki.jikexueyuan.com/project/android-test-course/test-foundation.html

Android Testing Options :
https://github.com/codepath/android_guides/wiki/Android-Testing-Options

知乎:种类介绍 http://www.zhihu.com/question/19716849

Developing Android unit and instrumentation tests - Tutorial
http://www.vogella.com/tutorials/AndroidTesting/article.html

Android 测试原则:

  • 70-80 % unit tests to ensure stability of your code basis

  • 20-30 % functional tests to ensure that the application really works

  • some cross functional tests if your application integrates intensively with other Application components

参考:

  1. How to improve quality and syntax of your Android code
    http://vincentbrison.com/2014/07/19/how-to-improve-quality-and-syntax-of-your-android-code/

  2. gradle func for checkstyle:
    https://docs.gradle.org/current/dsl/org.gradle.api.plugins.quality.Checkstyle.html

  3. google java style
    http://checkstyle.sourceforge.net/reports/google-java-style.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值