P3C二次开发

4/3/2024 spring后端

# 编译

需要打包不同的idea兼容版本,跑sh命令 bash ./buildPlugin.sh idea 直接点击右侧的build是设置的java版本,直接执行gradle命令调用的是环境变量里面配置的java版本,因此会报错

# 命令行

# maven插件

修改pom文件

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-pmd-plugin</artifactId>
    <version>3.21.0</version>

    <configuration>
        <includes>
            <include>**/*.java</include>
            <include>**/*.js</include>
        </includes>
        <verbose>true</verbose>
        <!-- 规范的配置 -->
        <rulesets>
            <ruleset>rulesets/java/ali-comment.xml</ruleset>
  <!--                        <ruleset>rulesets/java/ali-concurrent.xml</ruleset>-->
            <ruleset>rulesets/java/ali-constant.xml</ruleset>
  <!--                        <ruleset>rulesets/java/ali-exception.xml</ruleset>-->
            <ruleset>rulesets/java/ali-flowcontrol.xml</ruleset>
            <ruleset>rulesets/java/ali-naming.xml</ruleset>
            <ruleset>rulesets/java/ali-oop.xml</ruleset>
            <ruleset>rulesets/java/ali-orm.xml</ruleset>
            <ruleset>rulesets/java/ali-other.xml</ruleset>
            <ruleset>rulesets/java/ali-set.xml</ruleset>
        </rulesets>
        <printFailingErrors>true</printFailingErrors>
        <!--扫描级别,小于等于这个级别的错误代码将不通过扫描。不配默认是5(这里不推荐使用默认的,否则任何一个规则校验不通过都不允许提交,推荐配置成1,否则可能会出现经常因不满足规则校验而无法提交的情况->当然也可以重新梳理一下规则配置,自定义本团队的规则级别)-->
        <minimumPriority>5</minimumPriority>
        <skip>false</skip>
        <showPmdLog>true</showPmdLog>
        <format>xml</format>
        <outputDirectory>${project.basedir}/target</outputDirectory>
    </configuration>
    <executions>
        <execution>
            <id>pmd-check-verify</id>
            <phase>verify</phase>
            <goals>
                <goal>check</goal>
            </goals>
        </execution>
        <execution>
            <id>pmd-pmd-site</id>
            <phase>site</phase>
            <goals>
                <goal>pmd</goal>
            </goals>
        </execution>
    </executions>
    <dependencies>
        <dependency>
            <groupId>io.github.godfather1103.p3c</groupId>
            <artifactId>p3c-pmd</artifactId>
            <version>2.1.1-ext-6</version>
        </dependency>
    </dependencies>
</plugin>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56

https://maven.apache.org/plugins/maven-pmd-plugin/pmd-mojo.html

# idea插件

# 代码调用

https://docs.pmd-code.org/pmd-doc-6.55.0/pmd_userdocs_tools_java_api.html

https://developer.aliyun.com/article/950202#:~:text=%E4%B8%8B%E8%BD%BD%EF%BC%9AFile%20-%3E%20Settings%20-%3E%20Plugins%20-%3E%20Marketplace,%E6%90%9C%E7%B4%A2%20%E2%80%9CPMDPlugin%E2%80%9D%20%EF%BC%8C%E4%B8%8B%E8%BD%BD%E6%8F%92%E4%BB%B6%E3%80%82%20%E4%BD%BF%E7%94%A8%E6%96%B9%E6%B3%95%EF%BC%9A%E5%9C%A8%E4%BB%A3%E7%A0%81%E7%BC%96%E8%BE%91%E6%A1%86%E6%88%96Project%20%E7%AA%97%E5%8F%A3%E7%9A%84%E6%96%87%E4%BB%B6%E5%A4%B9%E3%80%81%E5%8C%85%E3%80%81%E6%96%87%E4%BB%B6%E5%8F%B3%E9%94%AE%EF%BC%8C%E9%80%89%E6%8B%A9%E2%80%9CRun%20PMD%E2%80%9D-%3E%E2%80%9CPre%20Defined%E2%80%9D-%3E%E2%80%9CAll%E2%80%9D%EF%BC%8C%E5%AF%B9%E6%8C%87%E5%AE%9A%E7%9A%84%E6%96%87%E4%BB%B6%E5%A4%B9%E3%80%81%E5%8C%85%E3%80%81%E6%96%87%E4%BB%B6%E8%BF%9B%E8%A1%8C%E5%88%86%E6%9E%90%EF%BC%8C%E5%88%86%E6%9E%90%E7%BB%93%E6%9E%9C%E5%9C%A8%E6%8E%A7%E5%88%B6%E5%8F%B0%E8%BE%93%E5%87%BA%E3%80%82

https://www.cnblogs.com/liveandevil/p/3616949.html

ChuckJonas/vscode-apex-pmd: PMD static analysis for Apex in vscode (github.com) (opens new window) p3c-pmd扩展开发自定义规则 - 掘金 (juejin.cn) (opens new window)

# 本地启动开发

# LockShouldWithTryFinallyRule causes jvm ClassNotFoundException

https://github.com/alibaba/p3c/issues/636

# 与GitLab集成

"message": "404 Project Not Found" token没有权限