Java P3C custom rules

更新时间:
复制 MD 格式

Learn how to use a custom ruleset to perform code scanning in a pipeline.

Background information

In a pipeline, a custom ruleset helps you enforce specific rules and standards during the build, test, and deployment processes. This ensures code quality, security, and compliance.

Custom ruleset

  1. Get the default ruleset file from GitHub.

  2. Commit the ruleset file to a Codeup repository.

  3. Configure the pipeline source and rules.

    1. Add a pipeline source. For more information, see Configure a Code Source. On the pipeline configuration page, click Add Pipeline Source. In the pane that appears, select Codeup as the pipeline source type. Then, configure the service connection and select a repository and default branch. As needed, configure options such as clone submodules, custom clone depth, code source trigger, and branch mode.

    2. Add a Java code scanning task. On the pipeline orchestration page, click Add Task. In the Select Task Type dialog box, select the Code Scan category on the left, and then select the Java Code Scan (Alibaba Java Coding Guidelines scan) task.

    3. In the task configuration, select the Use Custom Rule Directory option. In the Java Code Guidelines Scan step, select Use Custom Rule Directory. For Custom Rule Directory, enter src/resources/rules, and for Exclude Subdirectories, enter test/.

Save and run the pipeline to scan your code with the custom ruleset.