新規則,我使用SonarQube 5.1,以收集所有的Java和林特誤差爲的Android應用程序。聲納:創建針對Android林特
幾乎每一個重要的問題是通過聲納使用lint插件已經抓住了,但我發現沒有包含至少一個問題:
<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=" <uses-sdk android:minSdkVersion="14" />"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="C:\Code\Android\TestApp\app\src\main\AndroidManifest.xml"
line="5"
column="15"/>
</issue>
這個問題涉及到AndroidManifest.xml
(傳統的方式來設置的Android minSdkVersion
屬性)和build.gradle
(當前設置minSdkVersion
元素的方式)。
我已閱讀documentation about creating new rules in Sonar,但我仍然困惑 。我已經下載了SSLR for XML並執行它來查找XPath字符串。
我的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字符串添加到新規則。
任何幫助將非常感激!
順便說一句,到SonarQube文檔的舊鏈接目前已被打破,如下所示:http://docs.codehaus.org/display/SONAR/Extending++oding+Rules。 SonarSource有人可以修復它? – frapen
是的,這是一個正在進行的過程,由於CodeHaus的關閉 - 新的URL是http://docs.sonarqube.org/display/DEV/Extending+Coding+Rules – Mithfindel