声纳:创建Android的皮棉新规则 [英] Sonar: Create new rule for Android Lint

查看:299
本文介绍了声纳:创建Android的皮棉新规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的 SonarQube 5.1 ,以收集所有的的Java 皮棉对于 Android版应用错误。

I am using SonarQube 5.1 in order to collect all Java and Lint errors for Android apps.

几乎每一个重要的问题已经被使用的声纳插件皮棉抓住了,但我发现没有包含至少一个问题:

Almost every important issue is already caught by Sonar using Lint plugin, but I have found at least one issue not included:

<issue
    id="GradleOverrides"
    severity="Warning"
    message="This `minSdkVersion` value (`14`) is not used; it is always overridden by the value specified in the Gradle build script (`15`)"
    category="Correctness"
    priority="4"
    summary="Value overridden by Gradle build script"
    explanation="The value of (for example) `minSdkVersion` is only used if it is not specified in the `build.gradle` build scripts. When specified in the Gradle build scripts, the manifest value is ignored and can be misleading, so should be removed to avoid ambiguity."
    errorLine1="    &lt;uses-sdk android:minSdkVersion=&quot;14&quot; />"
    errorLine2="              ~~~~~~~~~~~~~~~~~~~~~~~~~~">
    <location
        file="C:\Code\Android\TestApp\app\src\main\AndroidManifest.xml"
        line="5"
        column="15"/>
</issue>

此问题与的Andr​​oidManifest.xml (传统的方式来设置的Andr​​oid 的minSdkVersion 属性)和的build.gradle (电流的方法来设置的minSdkVersion 元素)。

This issue is related to AndroidManifest.xml (legacy way to set Android minSdkVersion attribute) and build.gradle (current way to set minSdkVersion element).

我已阅读文档有关创建声纳的新规则,但我是
仍是一头雾水。我已经下载了 SSLR对XML 并执行它找到XPath字符串。

I have read the documentation about creating new rules in Sonar, but I am still confused. I have downloaded the SSLR for XML and executed it to find the XPath string.

我的XML文件是:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.juanacaja.testapp" >

    <uses-sdk android:minSdkVersion="14" />

    <application
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>

...和XPath来寻找的minSdkVersion 元素是:

//manifest/uses-sdk/@android:minSdkVersion

我不知道我现在要做的。此外,SonarQube 5.1 Web界面发生了变化,我不知道如何将XPath字符串添加到新的规则。

I am not sure what I must do now. Moreover, the SonarQube 5.1 web interface has changed and I don't see how to add the XPath string to the new rule.

任何帮助将是非常美联社preciated!

Any help will be very appreciated!

推荐答案

无意中我发现如何做到这一点。操作步骤:

Accidentally I have found how to do this. Steps:


  1. 身份登录的管理员的或具有足够权限其它用户。

  2. 寻找在这种情况下,该语言的XPath规则,XML。

  3. preSS 创建附近的自定义规则文本,并填写表单按钮。

  1. Log in as administrator or other user with sufficient rights.
  2. Look for XPath rule for the language, XML in this case.
  3. Press Create button near "Custom Rules" text and fill form.

不要忘了您的个人资料,以激活该自定义规则。

Do not forget to activate this custom rule in your profile.

PS :恕我直言,根本的问题是,文件不更新,并且绝大多数的网址正在打破,由于的 codeHaus终止。直到老断开的链接将被纠正,这将是巨大的,如果进行自动重定向。

PS: IMHO, the underlying problem is that documentation is not updated, and the vast majority of URLs are currently broken, due CodeHaus termination. Until old broken links will be corrected, it would be great if automatic redirection be performed.

这篇关于声纳:创建Android的皮棉新规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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