Code Review
CodeArts Agent IDE automates code reviews by efficiently coordinating two core commands, /codeagent-review-rules and /review, offering precise and powerful code quality control.
Constraints
| Category | Description |
|---|---|
| Environment requirements | The /review command must be executed in a Git repository whose working directory contains staged, unstaged, or untracked file changes. |
| Supported file formats | Only code files in the supported programming languages can be reviewed. Non-code files (such as .json, .md, and .css) are automatically excluded from the review process.
|
Command Usage
The following sections describe how to use the two core commands: /review and /codeagent-review-rules.
/review
Function: Starts the code review process to comprehensively review the current code changes or those in a specified commit.
Syntax: Select the syntax that suits your needs and press Enter to trigger a comprehensive review of the specified code changes.
| Syntax | Description |
|---|---|
| /review | Reviews all code changes in the current working directory, including staged changes, unstaged changes, and newly untracked files. |
| /review <commitId> | Reviews all code changes (separated by spaces) in a single commit. |
| /review commitid:<commitId> | Reviews all code changes (separated by colons) in a single commit. |
| /review commitid=<commitId> | Reviews all code changes (separated by equal signs) in a single commit. |
| /review Review the code changes in <commitId> | Reviews a specified commit using a natural language description. |
| Parameter | Type | Description |
|---|---|---|
| commitId | String (7 to 40 hexadecimal characters) | The commit SHA to be reviewed. If this parameter is not specified, the changes in the current working directory are reviewed by default. Supported commit ID formats:
|
Examples: The following three examples demonstrate how to call /review in different ways and what are the differences.
- Reviewing all uncommitted code changes
/review
- Reviewing all code changes in a specified commit
/review 8b480d1a3b5c4d6e7f8a9b0c1d2e3f4a5b6c7d8e
- Reviewing a specified commit using a natural language description
/review Review the code changes in commit 8b480d1a3b5c4d6e7f8a9b0c1d2e3f4a5b6c7d8e
/codeagent-review-rules
Function: Manages code review rule sets, including generating, displaying, and deleting rules.
Syntax: Table 4 provides four types of syntax for the /codeagent-review-rules command and their functions. Select the operation you need and press Enter to execute it.
| Syntax | Description |
|---|---|
| /codeagent-review-rules <File path><Rule set name> | Generates a new rule set based on a specification file. |
| /codeagent-review-rules --generate <File path><Rule set name> | |
| /codeagent-review-rules --show-rules <Rule set name> | Lists enabled rules (enabled=true). |
| /codeagent-review-rules --delete-rules <Rule set name> <Rule ID_1,Rule ID_2,...> | Disables a specified rule by setting its enabled field to false. |
| Parameter | Description |
|---|---|
| File path | Local path for storing a specification file. Currently, only specification files in the following formats are supported:
|
| Rule set name | Name of a rule set generated based on a specification file. The rule set name facilitates subsequent reference and management. |
| Rule ID list | ID of the rule to be disabled. Use commas (,) to separate multiple IDs, for example, rule_001,rule_002. |
Examples: The following examples demonstrate how to use /codeagent-review-rules to automate the management of code review rules.
- Generating a rule set based on a PDF specification file
/codeagent-review-rules --generate /path/to/Python Coding Style Guide.pdf Python Coding Style Guide V3.0
- Viewing enabled rules
/codeagent-review-rules --show-rules Python Coding Style Guide V3.0
- Disabling specified rules
/codeagent-review-rules --delete-rules Python Coding Style Guide V3.0 RULE_001,RULE_005
Using These Commands
- Log in to CodeArts Agent IDE as instructed in Quick Start.
- Run /codeagent-review-rules to generate a rule set based on a local specification file.
- Click
in the chat box, choose Shortcuts, and select /codeagent-review-rules from the displayed menu. - Enter the location of the specification file and the name of the rule set to generate, and click
. Figure 1 Generating a rule set
- View the generated rule set.
A rule set folder named codeagent-custom-review-rules is generated in the .codeartsdoer/skills directory of the explorer's project root directory.
Figure 2 Viewing a generated rule set
- Click
- Run /review to comprehensively review code changes based on the generated rule set.
- Click
in the chat box and choose Shortcuts. - Select /review from the displayed menu and click
. - Check the code review result.
In the .codeartsdoer/review directory of the explorer's project root directory, a folder named in the format "year-month-day_hour-minute-second-millisecond_random string" is generated. Each folder contains two subdirectories: preprocess and report. preprocess stores preprocessed files including code changes. report stores the final review report.
- Click
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot