59. Android 静态分析插件



Android 大杂烩静态代码质量检查 gradle plugin . (。>﹏<。)



Github

android-static-analysis-plugin



Gradle

project build.gradle

dependencies {    com.camnter.gradle.plugin:static-analysis-plugin:1.0.5}

module build.gradle

apply plugin: 'com.camnter.gradle.plugin.static.analysis'



关于配置

你可以不做任何配置。插件自动生成一组规则。只要在你想要应用的模块添加依赖配置即可。你可以找到自动生成的规则文件。

${project.buildDir}/android-static-analysis/default-rules

module build.gradle

apply plugin: 'com.camnter.gradle.plugin.static.analysis'



如果你想要配置

全部默认配置:

androidStaticAnalysis {    // eg: true or false    debugAnalysis = false    // eg: true or false    releaseAnalysis = true    pmd {        // eg: "6.2.0"        toolVersion = "6.2.0"        // eg: true or false        ignoreFailures = true        // eg: ["${project.project.rootDir}/a.xml", "${project.project.rootDir}/b.xml"]        ruleSets = []        // eg: "${project.project.rootDir}/c.xml"        ruleSetFiles = "${project.buildDir}/android-static-analysis/default-rules/pmd-ruleset.xml"    }    lint {        // eg: "${project.project.rootDir}/d.xml"        lintConfig = "${project.buildDir}/android-static-analysis/default-rules/lint.xml"    }    findBugs {        // eg: "3.0.1"        toolVersion = "3.0.1"        // eg: true or false        ignoreFailures = true        // "min", "default", "max"        effort = "max"        // eg: "${project.project.rootDir}/e.xml"        excludeFilter =                "${project.buildDir}/android-static-analysis/default-rules/findbugs-filter.xml"        // eg: "low", "medium", "high"                reportLevel = "high"    }    checkstyle {        // eg: "8.8"        toolVersion = "8.8"        // eg: true or false        ignoreFailures = true        // eg: "${project.project.rootDir}/f.xml"        configDir = "${project.buildDir}/android-static-analysis/default-rules/checkstyle.xml"        // eg: 0 - Integer.MAX_VALUE        maxErrors = 30        // eg: 0 - Integer.MAX_VALUE        maxWarnings = 2147483647        // eg: "${project.project.rootDir}/h.xml"        suppressionsPath = "${project.buildDir}/android-static-analysis/default-rules/suppressions.xml"    }}



运行

gradle check

如果你打开了配置

androidStaticAnalysis {    debugAnalysis = true    releaseAnalysis = true}

运行以下命令也会执行

gradle assembleDebug
gradle assembleRelease



自动发邮件

androidStaticAnalysis {    email{        // 是否自动发邮件,默认 false        // eg: true or false        send = true        // 发信人昵称        nickname = 'CaMnter'        // 邮件主题        theme = 'Android static analysis'        // 邮件内容        // enclosureType = 'html' 的时候,失效        // enclosureType = 'zip'  的时候,有效        content = 'Android static analysis'        // 收信人,多人则以 ; 号隔开        // eg: 'a@gmail.com;b@gmail.com'        receivers = 'yuanyu.camnter@gmail.com'        // 抄送,多人则以 ; 号隔开        // eg: 'c@gmail.com;d@gmail.com'        carbonCopy = 'yuanyu.camnter@gmail.com'        // eg: html or zip        // 分析内容,html 格式还是 zip 格式,默认 html 格式        enclosureType = 'html'    }}

这只是一部分。


Stmp 相关配置

local.properties 内完成以下配置

asap.smtpHost=公司 stmp 服务器地址asap.smtpUser=公司邮箱asap.smtpPassword=公司邮箱密码


Google 邮箱 Stmp 配置

1. 打开 gmail 设置页面中的 “转发和 POP/IMAP”。

2. 勾选上 “启用 IMAP“。

3. 开启 两步验证。

4. 生成 gmail 专用密码。

gmail 专用密码 作为 gmailstmp password

asap.smtpHost=smtp.gmail.comasap.smtpUser=gmail 邮箱asap.smtpPassword=刚才申请的 gmail 专用密码

59. Android 静态分析插件_第1张图片
59. Android 静态分析插件_第2张图片
59. Android 静态分析插件_第3张图片


QQ 邮箱 Stmp 配置

1. QQ 邮箱设置页面,打开 “POP3/SMTP服务“。

2. 生成授权码。

授权码 作为 QQ 邮箱stmp password

asap.smtpHost=smtp.qq.comasap.smtpUser=qq 邮箱asap.smtpPassword=刚才申请的 qq 邮箱授权码

59. Android 静态分析插件_第4张图片
59. Android 静态分析插件_第5张图片


网易 邮箱 Stmp 配置

1. 网易邮箱 设置页面,打开 “POP3/SMTP服务“。

2. 设置 客户端授权密码

客户端授权密码 作为 网易邮箱stmp password

asap.smtpHost=smtp.163.comasap.smtpUser=网易 邮箱asap.smtpPassword=刚才申请的 网易邮箱 客户端授权密码

59. Android 静态分析插件_第6张图片
59. Android 静态分析插件_第7张图片


Sina 邮箱 Stmp 配置

Sina 邮箱 设置页面,打开 “POP3/SMTP服务

asap.smtpHost=smtp.sina.comasap.smtpUser=sina 邮箱asap.smtpPassword=sina 邮箱密码

59. Android 静态分析插件_第8张图片



License

  Copyright (C) 2018 CaMnter yuanyu.camnter@gmail.com  Licensed under the Apache License, Version 2.0 (the "License");  you may not use this file except in compliance with the License.  You may obtain a copy of the License at     http://www.apache.org/licenses/LICENSE-2.0  Unless required by applicable law or agreed to in writing, software  distributed under the License is distributed on an "AS IS" BASIS,  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the specific language governing permissions and  limitations under the License.

更多相关文章

  1. Android NDK编译libPng为静态库
  2. Android SDK 2.2 和ADT插件下载
  3. Android实现插件化(热加载)和插件加密
  4. 使用 Kotlin 开发 Android 应用 | 8 个最优秀的 Android Studio
  5. 使用 Kotlin 开发 Android 应用 | 8 个最优秀的 Android Studio
  6. Android dp方式的屏幕适配工具使用(Android Studio插件方式)
  7. Android ADT插件配置
  8. Android 电量显示Widgets插件实现
  9. Android安装以及Eclipse插件(Google Android) ,在Android 中goog

随机推荐

  1. Android原生(Native)C开发之八:Toolchain
  2. Android官方说明-Activity任务栈
  3. Android 基础:常用布局 介绍 & 使用(附 属
  4. Android设置沉浸式状态栏时改变状态栏的
  5. android 将app添加进入文件的打开方式
  6. Android 监听EditText输入框软键盘显示及
  7. 【Android】源码项目编译ccache配置
  8. 【Android】九宫格手势锁简单实现
  9. 如何利用Eclipse运行android程序
  10. [android]android权限体系深入分析