我正在使用SonarQube为mule应用程序验证pom.xml文件中的artifactId、modelVersion等。为了验证这些节点,我在SonarQube中构建了一些规则。但是,POM规则似乎不起作用。这是我的pom-xml和代码规则。
<rule id ="2" name="Pom Model Version should be 4.0.0"
description="Pom Model Version should be 4.0.0"
severity="MAJOR" type="code_smell">
//*[local-name()='project']/*[local-name()='modelVersion']= '4.0.0'
</rule>
<rule id="3" name="Application Name is too long ok"
description="Application Name is too long, give a proper name"
severity="MAJOR" applies="application" type="code_smell">
string-length(//*[local-name()='project' ]/*[local-name()='artifactId'])>20
</rule>
<rule id ="4" name="Mule Runtime Version should be 4.2.0"
description="Mule Runtime Version should be 4.2.0"
severity="MAJOR" type="code_smell">
//*[local-name()='project']/*[local-name()='properties']/*[local-name()='app.runtime']= '4.2.0'
</rule>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany</groupId>
<artifactId>security</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>mule-application</packaging>
<name>security-token-project</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<app.runtime>4.3.0-20201013</app.runtime>
<mule.maven.plugin.version>3.3.5</mule.maven.plugin.version>
<sonar.sources>/</sonar.sources>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>3.0.0</version>
</plugin>
<plugin>
<groupId>org.mule.tools.maven</groupId>
<artifactId>mule-maven-plugin</artifactId>
<version>${mule.maven.plugin.version}</version>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.mule.connectors</groupId>
<artifactId>mule-http-connector</artifactId>
<version>1.5.22</version>
<classifier>mule-plugin</classifier>
</dependency>
<dependency>
<groupId>org.mule.connectors</groupId>
<artifactId>mule-sockets-connector</artifactId>
<version>1.2.0</version>
<classifier>mule-plugin</classifier>
</dependency>
</dependencies>
<repositories>
<repository>
<id>anypoint-exchange-v2</id>
<name>Anypoint Exchange</name>
<url>https://maven.anypoint.mulesoft.com/api/v2/maven</url>
<layout>default</layout>
</repository>
<repository>
<id>mulesoft-releases</id>
<name>MuleSoft Releases Repository</name>
<url>https://repository.mulesoft.org/releases/</url>
<layout>default</layout>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>mulesoft-releases</id>
<name>mulesoft release repository</name>
<layout>default</layout>
<url>https://repository.mulesoft.org/releases/</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</project>
我用来验证其他xml文件的其他规则正在运行,但以上三条规则并没有按预期运行。
<sonar.sources>/</sonar.sources>
<sonar.inclusions>**.xml</sonar.inclusions>
<sonar.exclusions>target/**.xml</sonar.exclusions>