Java代码静态检查技术探究Java代码静态检查技术探究(二)使用案例-PMD
运行全部规则
PS D:\tool\openapi\out\java> pmd -d . -f text -R rulesets/java/quickstart.xml
May 01, 2020 1:44:58 PM net.sourceforge.pmd.PMD encourageToUseIncrementalAnalysis
WARNING: This analysis could be faster, please consider using Incremental Analysis: https://pmd.github.io/pmd-6.23.0/pmd_userdocs_incremental_analysis.html
D:\tool\openapi\out\java\src\main\java\org\openapitools\client\ApiCallback.java:16: Avoid unused imports such as 'java.io.IOException'
D:\tool\openapi\out\java\src\main\java\org\openapitools\client\ApiClient.java:16: Avoid unused imports such as 'okhttp3'
D:\tool\openapi\out\java\src\main\java\org\openapitools\client\ApiClient.java:27: Avoid unused imports such as 'org.apache.oltu.oauth2.common.message.types.GrantType'
D:\tool\openapi\out\java\src\main\java\org\openapitools\client\ApiClient.java:44: Avoid unused imports such as 'java.security.cert.X509Certificate'
D:\tool\openapi\out\java\src\main\java\org\openapitools\client\ApiClient.java:54: Avoid unused imports such as 'org.openapitools.client.auth.HttpBearerAuth'
D:\tool\openapi\out\java\src\main\java\org\openapitools\client\ApiClient.java:71: Avoid unused private fields such as 'datetimeFormat'.
D:\tool\openapi\out\java\src\main\java\org\openapitools\client\ApiClient.java:72: Avoid unused private fields such as 'lenientDatetimeFormat'.
D:\tool\openapi\out\java\src\main\java\org\openapitools\client\ApiClient.java:73: Avoid unused private fields such as 'dateLength'.
运行指定规则
PS D:\tool\openapi\out\java> pmd -d . -f text -R rulesets/java/quickstart.xml/ImportFromSamePackage
May 01, 2020 1:53:09 PM net.sourceforge.pmd.PMD encourageToUseIncrementalAnalysis
WARNING: This analysis could be faster, please consider using Incremental Analysis: https://pmd.github.io/pmd-6.23.0/pmd_userdocs_incremental_analysis.html
D:\tool\openapi\out\java\src\main\java\org\openapitools\client\model\Pet.java:28: No need to import a type that lives in the same package
D:\tool\openapi\out\java\src\main\java\org\openapitools\client\model\Pet.java:29: No need to import a type that lives in the same package
D:\tool\openapi\out\java\src\test\java\org\openapitools\client\model\PetTest.java:26: No need to import a type that lives in the same package
D:\tool\openapi\out\java\src\test\java\org\openapitools\client\model\PetTest.java:27: No need to import a type that lives in the same package
XML格式输出
PS D:\tool\openapi\out\java> pmd -d . -f xml -R rulesets/java/quickstart.xml/ImportFromSamePackage
May 01, 2020 1:53:50 PM net.sourceforge.pmd.PMD encourageToUseIncrementalAnalysis
WARNING: This analysis could be faster, please consider using Incremental Analysis: https://pmd.github.io/pmd-6.23.0/pmd_userdocs_incremental_analysis.html
<?xml version="1.0" encoding="UTF-8"?>
<pmd xmlns="http://pmd.sourceforge.net/report/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pmd.sourceforge.net/report/2.0.0 http://pmd.sourceforge.net/report_2_0_0.xsd" version="6.23.0" timestamp="2020-05-01T13:53:50.934">
<file name="D:\tool\openapi\out\java\src\main\java\org\openapitools\client\model\Pet.java">
<violation beginline="28" endline="28" begincolumn="1" endcolumn="46" rule="ImportFromSamePackage" ruleset="Error Prone" package="org.openapitools.client.model" class="Pet" externalInfoUrl="https://pmd.github.io/pmd-6.23.0/pmd_rules_java_errorprone.html#importfromsamepackage" priority="3">
No need to import a type that lives in the same package
</violation>
<violation beginline="29" endline="29" begincolumn="1" endcolumn="41" rule="ImportFromSamePackage" ruleset="Error Prone" package="org.openapitools.client.model" class="Pet" externalInfoUrl="https://pmd.github.io/pmd-6.23.0/pmd_rules_java_errorprone.html#importfromsamepackage" priority="3">
No need to import a type that lives in the same package
</violation>
</file>
<file name="D:\tool\openapi\out\java\src\test\java\org\openapitools\client\model\PetTest.java">
<violation beginline="26" endline="26" begincolumn="1" endcolumn="46" rule="ImportFromSamePackage" ruleset="Error Prone" package="org.openapitools.client.model" class="PetTest" externalInfoUrl="https://pmd.github.io/pmd-6.23.0/pmd_rules_java_errorprone.html#importfromsamepackage" priority="3">
No need to import a type that lives in the same package
</violation>
<violation beginline="27" endline="27" begincolumn="1" endcolumn="41" rule="ImportFromSamePackage" ruleset="Error Prone" package="org.openapitools.client.model" class="PetTest" externalInfoUrl="https://pmd.github.io/pmd-6.23.0/pmd_rules_java_errorprone.html#importfromsamepackage" priority="3">
No need to import a type that lives in the same package
</violation>
</file>
</pmd>
- 点赞
- 收藏
- 关注作者
评论(0)