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 专用密码




QQ 邮箱 Stmp 配置

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

2. 生成授权码。

授权码 作为 QQ 邮箱stmp password

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



网易 邮箱 Stmp 配置

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

2. 设置 客户端授权密码

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

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



Sina 邮箱 Stmp 配置

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

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



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学习之 UI效果
  2. Android(安卓)UI开发第一篇——android的九宫格式实现
  3. 在Android上授权Adobe AIR应用程序
  4. android仿网易云音乐、即时通讯、bilibili、沙漏动画等源码
  5. Android(安卓)正则表达式验证手机和邮箱格式是否正确
  6. spring-android的使用
  7. spring-android的使用
  8. 1236546545
  9. 浅谈 Docker 容器与镜像

随机推荐

  1. android 的OOM
  2. Android 二进制、10进制、16进制互相转换
  3. 详解Android中获取SD卡和内存的空间信息
  4. busybox tools
  5. GitHub上优秀Android 开源项目
  6. Android应用程序消息处理机制(Looper、Han
  7. android camera 各版本差异
  8. /2015/6/12/ BiliBili Android 新客户端
  9. android 原生系统服务定位实现
  10. 动态壁纸开发指南(一)概述介绍