Android 静态代码工具-lint命令

1.工具位置

lint 工具在安卓 sdk 的 tools 目录下

2. lint使用

1>在命令行窗口 输入lint,得到lint 帮助说明如下:

Usage: lint [flags] <project directories>
Flags:
--help                   This message.
--help <topic>           Help on the given topic, such as "suppress".
--list                   List the available issue id's and exit.
--version                Output version information and exit.
--exitcode               Set the exit code to 1 if errors are found.
--show                   List available issues along with full explanations.
--show <ids>             Show full explanations for the given list of issue  id's.

Enabled Checks:
--disable <list>         Disable the list of categories or specific issue  id's. The list should be a comma-separated list of issue id's or categories.
--enable <list>          Enable the specific list of issues. This checks all the default issues plus the specifically enabled  issues. The list should be a comma-separated list   of  issue id's or categories.
--check <list>           Only check the specific list of issues. This will disable everything and re-enable the given list of  issues. The list should be a comma-separated list of
 issue id's or categories.
-w, --nowarn             Only check for errors (ignore warnings)
-Wall                    Check all warnings, including those off by default
-Werror                  Treat all warnings as errors
--config <filename>      Use the given configuration file to determine whether issues are enabled or disabled. If a project contains  a lint.xml file, then this config file will be used as a fallback.

Output Options:
--quiet                  Don't show progress.
--fullpath               Use full paths in the error output.
--showall                Do not truncate long messages, lists of alternate locations, etc.
--nolines                Do not include the source file lines with errors in  the output. By default, the error output includes snippets of source code on the line containing the
                         error, but this flag turns it off.
--html <filename>        Create an HTML report instead. If the filename is a   directory (or a new filename without an extension),   lint will create a separate report for each   scanned  project.
--url filepath=url       Add links to HTML report, replacing local path prefixes with url prefix. The mapping can be a comma-separated list of path prefixes to correspondingURL prefixes, such as C:\temp\Proj1=http://buildserver/sources/temp/Proj1.    To turn off linking to files, use --url none
--simplehtml <filename>  Create a simple HTML report
--xml <filename>         Create an XML report instead.

Project Options:
--resources <dir>        Add the given folder (or path) as a resource   directory for the project. Only valid when running   lint on a single project.
--sources <dir>          Add the given folder (or path) as a source directory  for the project. Only valid when running lint on a  single project.
--classpath <dir>        Add the given folder (or jar file, or path) as a class directory for the project. Only valid when running lint on a single project.
--libraries <dir>        Add the given folder (or jar file, or path) as a class library for the project. Only valid when  running lint on a single project.

2>常用命令讲解

lint --list 列出所有的问题id
lint --show 列出所有的问题,并给出详细解释

lint --check  <List>  只检查List列表中的问题id,其中List中的id 使用逗号分开
lint -w   只检查错误,忽略警告

lint --xml  filename   创建一个xml的结果报告
lint --html  filename  创建一个html 的结果报告
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值