我正在使用SonarQube 5.1来收集Android应用程序的所有Java和Lint错误。
Sonar已使用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
(设置AndroidminSdkVersion
属性的旧方法)和build.gradle
(设置minSdkVersion
元素的当前方法)有关。
我已经阅读了有关在Sonar中创建新规则的文档,但是我仍然感到困惑。我已经下载了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>
...而要查找minSdkVersion
元素的XPath是:
//manifest/uses-sdk/@android:minSdkVersion
我不确定现在该怎么办。此外,SonarQube 5.1 Web界面已更改,我看不到如何将XPath字符串添加到新规则。
任何帮助将不胜感激!
偶然我发现了如何做到这一点。脚步:
不要忘记在您的个人资料中激活此自定义规则。
PS:恕我直言,潜在的问题是文档未更新,并且由于CodeHaus终止,目前绝大多数URL已损坏。在纠正旧的断开链接之前,如果执行自动重定向将非常有用。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句