首页 > 解决方案 > 无法在 SonarQube 中验证 mule 应用程序的 pom.xml

问题描述

我正在使用 SonarQube 在 pom.xml 文件中为 mule 应用程序验证 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 文件的其他规则正在工作,但以上三个规则没有按预期工作。

标签: mavenxpathsonarqubemulexml-namespaces

解决方案


推荐阅读