我为了收集所有的Java和皮棉错误for Android应用程序使用SonarQube 5.1。
几乎每一个重要的问题是通过声纳使用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
元素)。
我已阅读有关声纳创建新规则的文件 ,但我仍然感到困惑。 我已经下载了对XML SSLR并执行它找到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字符串添加新的规则。
任何帮助将非常感激!