Skip to content

Latest commit

 

History

History
281 lines (207 loc) · 7.19 KB

README_zh.md

File metadata and controls

281 lines (207 loc) · 7.19 KB

android-static-analysis-plugin


Download


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



Gradle

project build.gradle

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

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: true or false
        enable = true
        // 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: true or false
        enable = true
        // eg: "${project.project.rootDir}/d.xml"
        lintConfig = "${project.buildDir}/android-static-analysis/default-rules/lint.xml"
    }
    findBugs {
        // eg: true or false
        enable = true
        // 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: true or false
        enable = true
        // 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/checkstyle-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.com
asap.smtpUser=gmail 邮箱
asap.smtpPassword=刚才申请的 gmail 专用密码

gmail_1


QQ 邮箱 Stmp 配置

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

2. 生成授权码。

授权码 作为 QQ 邮箱stmp password

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

qq_1


网易 邮箱 Stmp 配置

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

2. 设置 客户端授权密码

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

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

netease_1 netease_2


Sina 邮箱 Stmp 配置

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

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

sina_1



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.