编写自定义lint.xml [英] Writing custom lint.xml

查看:263
本文介绍了编写自定义lint.xml的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的Andr​​oid项目依赖于在其上我们没有控制一些外部项目。所以我想设置自定义lint.xml文件,这样我们可以添加忽略这些规则。作为首发的情况我试图从ActionBarSherlock(没有进攻杰克)

Our Android project is dependent on some external projects over which we do not have control. Therefore I'm trying to setup custom lint.xml file so we can add ignore rules for them. As starting scenario I tried to remove warnings from ActionBarSherlock (no offence Jake)

<?xml version="1.0" encoding="UTF-8"?>
<lint>
  <issue id="FloatMath">
    <ignore path="app/target/classes/com/actionbarsherlock/*" />
  </issue>
  <issue id="DefaultLocale">
    <ignore path="app/target/classes/com/actionbarsherlock/*" />
  </issue>
  <issue id="ViewConstructor">
    <ignore path="app/target/classes/com/actionbarsherlock/*" />
  </issue>
</lint>

在下面的命令

with following command in

lint app --disable FloatMath,DefaultLocale,ViewConstructor --xml lint-result.xml

但是生产报告还包括了来自ABS的消息。

However produced report still included messages from ABS.

更新 我改变了命令

lint --disable FloatMath,DefaultLocale,ViewConstructor --xml lint-result.xml app

没有任何变化詹金斯仍然会产生相同的报告,不管是什么忽略,但是如果在它的命令行运行忽略禁用后列出的所有问题。我希望有简单的方式说,哎忽略/排除事物的排序方式的Maven呢......

Doesn't make any change for Jenkins still produce same report no matter what is in ignore, however if run in command line it does ignores all issues listed after disable. I wish that there was simple way to say, hey ignore/exclude things in sort of way Maven does...

推荐答案

再次回答我的问题? lint.xml现在看起来是这样,它会忽略ASB 4.2.0任何ActionBarSherlock报告

Once again answering my own question... lint.xml looks now like this and it will ignore any ActionBarSherlock reports on ASB 4.2.0

<?xml version="1.0" encoding="UTF-8"?>
<lint>
  <issue id="NewApi">
    <ignore path="target/classes/com/actionbarsherlock/internal/ActionBarSherlockNative.class" />
    <ignore path="target/classes/com/actionbarsherlock/internal/ActionBarSherlockNative$ActionModeWrapper.class" />
    <ignore path="target/classes/com/actionbarsherlock/internal/app/ActionBarWrapper.class" />
    <ignore path="target/classes/com/actionbarsherlock/internal/app/ActionBarWrapper$TabWrapper.class" />
    <ignore path="target/classes/com/actionbarsherlock/internal/view/ActionProviderWrapper.class" />
    <ignore path="target/classes/com/actionbarsherlock/internal/view/menu/ActionMenuItemView.class" />
    <ignore path="target/classes/com/actionbarsherlock/internal/view/menu/MenuItemWrapper.class" />
    <ignore path="target/classes/com/actionbarsherlock/internal/view/menu/ActionMenuPresenter$HasPermanentMenuKey.class" />
    <ignore path="target/classes/com/actionbarsherlock/internal/widget/IcsAdapterView.class" />
    <ignore path="target/classes/com/actionbarsherlock/internal/widget/IcsProgressBar.class" />
    <ignore path="target/classes/com/actionbarsherlock/internal/widget/ActionBarView$HomeView.class" />
    <ignore path="target/classes/com/actionbarsherlock/widget/SearchView.class" />
    <ignore path="target/classes/com/actionbarsherlock/internal/nineoldandroids/widget/NineFrameLayout.class" />
    <ignore path="target/classes/com/actionbarsherlock/internal/nineoldandroids/widget/NineHorizontalScrollView.class" />
    <ignore path="target/classes/com/actionbarsherlock/internal/nineoldandroids/widget/NineLinearLayout.class" />
    <ignore path="target/classes/com/actionbarsherlock/internal/nineoldandroids/view/NineViewGroup.class" />
    <ignore path="target/classes/com/actionbarsherlock/internal/view/menu/BaseMenuPresenter.class" />
    <ignore path="target/classes/com/actionbarsherlock/internal/widget/AbsActionBarView.class" />
    <ignore path="target/classes/com/actionbarsherlock/internal/widget/ActionBarContextView.class" />
    <ignore path="target/classes/com/actionbarsherlock/internal/widget/ActionBarView.class" />
    <ignore path="target/classes/com/actionbarsherlock/internal/widget/CapitalizingButton.class" />
    <ignore path="target/classes/com/actionbarsherlock/internal/widget/CapitalizingTextView.class" />
    <ignore path="target/classes/com/actionbarsherlock/internal/widget/IcsAbsSpinner.class" />
    <ignore path="target/classes/com/actionbarsherlock/internal/widget/IcsLinearLayout.class" />
    <ignore path="target/classes/com/actionbarsherlock/internal/widget/IcsListPopupWindow.class" />
    <ignore path="target/classes/com/actionbarsherlock/internal/widget/ScrollingTabContainerView.class" />
    <ignore path="target/classes/com/actionbarsherlock/widget/ActivityChooserView$SetActivated.class" />
    <ignore path="target/classes/com/actionbarsherlock/app/SherlockActivity.class" />
    <ignore path="target/classes/com/actionbarsherlock/app/SherlockExpandableListActivity.class" />
    <ignore path="target/classes/com/actionbarsherlock/app/SherlockListActivity.class" />
    <ignore path="target/classes/com/actionbarsherlock/app/SherlockPreferenceActivity.class" />
    <ignore path="target/classes/com/actionbarsherlock/internal/ActionBarSherlockNative$ActionModeCallbackWrapper.class" />
    <ignore path="target/classes/com/actionbarsherlock/internal/app/ActionBarImpl$1.class" />
    <ignore path="target/classes/com/actionbarsherlock/internal/app/ActionBarImpl.class" />
  </issue>

  <issue id="FloatMath">
    <ignore path="target/classes/com/actionbarsherlock/internal/nineoldandroids/view/animation/AnimatorProxy.class" />
  </issue>

  <issue id="DefaultLocale">
    <ignore path="target/classes/com/actionbarsherlock/internal/widget/CapitalizingTextView.class" />
    <ignore path="target/classes/com/actionbarsherlock/internal/widget/CapitalizingButton.class" />
  </issue>

  <issue id="ViewConstructor">
    <ignore path="target/classes/com/actionbarsherlock/internal/widget/CollapsibleActionViewWrapper.class" />
  </issue>

  <issue id="WrongCall">
    <ignore path="target/classes/com/actionbarsherlock/internal/widget/IcsAdapterView.class" />
  </issue>
</lint>

我们现在使用

shell执行的命令是

Shell execution command that we now use is

lint --config lint.xml --xml lint-results.xml .;

PS:请注意,这不会删除排除APKLIB的所有报告就像在这种情况下,ABS为到目前为止还没有办法排除,以R.class的未使用的资源报告。在链接库的编译过程R.class和你的项目也得到合并后的皮棉没有办法知道这一点。它只能看到单一R.class与未使用,并生成报告一定的参考。

PS: Please be aware that this will not remove all reports of excluded APKLIB like in this case ABS as so far there is no way to exclude reports to unused resources of R.class. On compile process R.class of linked library and your project do get merged and Lint has no way to know this. It does only see single R.class with some references that are not used and reports them.

这篇关于编写自定义lint.xml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆