Help Center/ CodeArts Check/ User Guide/ Reference/ Using CodeArts Check Plug-in in IntelliJ IDEA
Updated on 2024-11-29 GMT+08:00

Using CodeArts Check Plug-in in IntelliJ IDEA

This plug-in is a powerful assistant for developers to protect the code quality. It provides industry standard check, one-click code style formatting, and automatic code fixing, adhering to the concepts of simplicity, high speed, and real-time monitoring.

Installing the Plug-in

  1. On the IntelliJ IDEA editor, choose File > Settings on the top menu bar.
  2. Click Plugins in the navigation pane on the left and click Marketplace in the right pane.
  3. Enter Huawei Cloud CodeArts Check or CodeArts Check in the search box.
  4. Click Install. Then IntelliJ IDEA restarts. After the restart, IntelliJ IDEA automatically downloads the engine package and the JDK package.
  5. Once the download is finished, a message appears in the lower right corner confirming the successful download.

Configuring the Plug-in

  1. Click CodeArts Check at the bottom of the IntelliJ IDEA editor and click Setting on the toolbar.

  2. In the displayed window, click on the left to view the rule details.
  3. Decide whether to enable automatic code check, enter the masked directory, and specify directory to be checked.

  4. See the activated or applied rule details (including status, level, language, engine tag, and rule type) or filter rules by all/recommended rule set.

  5. After the configuration, click Apply.

Checking and Fixing Files by the Plug-in

Take a local Java project as an example.

The CodeArts Check plug-in allows you to check one or multiple Java files, as well as the entire project. You can also correct code style issues with just one click. For details, see Plug-in Functions, One-Click Formatting and Automatic Fix, and Rule Configuration.

Plug-in Functions

  • Checking one or multiple files, as well as the entire project, and viewing the results.
    • Checking one file: In the editor area, right-click and click File Check with CodeArts Check. Alternatively, in the Project window, right-click the file to be checked and click File Check with CodeArts Check.

    • Checking multiple files: In the Project window, hold down Ctrl and select multiple files. Then, right-click and click File Check with CodeArts Check.

    • Checking the entire project: In the editor area, right-click and click Project Check with CodeArts Check. Alternatively, in the Project window, right-click the file and click Project Check with CodeArts Check.

  • Viewing defect details, severity, type, compliant example, non-compliant example, and fixing suggestion. Filtering defects by severity, rule, and file.
    • Viewing defects by file: Open the CodeArts Check window, click Defects > > View By File.

    • Viewing defects by severity: Open the CodeArts Check window, click Defects > , and select a defect type as required.

    • Triggering automatic check and defect update.

      The plug-in automatically checks code in real time and updates defects after you fix the code defects based on fixing suggestions.

One-Click Formatting and Automatic Fix

  • One-click formatting on a single file, multiple files, a folder, or an entire project.

    With one-click formatting, you can easily resolve common code specification issues in your project, such as extra spaces or blank lines.

    In the editor area, right-click and click Auto Format with CodeArts Check. Alternatively, in the Project window, right-click the file and click Auto Format with CodeArts Check.

  • Automatic fix for a single defect checked by the plug-in.

    The plug-in provides a preview window with suggestions on how to fix and the automatic fix function.

Rule Configuration

Open the CodeArts Check window, click Setting.

Table 1 Configurations

No.

Configuration

Description

1

Automatic code check after editing and before commit

  • Automatic code check after saved editing: Select whether to automatically trigger CodeArts Check after code is edited and saved. Automatic check does not affect the current window. Once you modify and save the code, the latest check results will be automatically updated in the Defects tab.
  • Automatic code check before commit: Select whether to automatically trigger CodeArts Check before code is committed.

2

Check mode

The local mode is used by default.

3

Excluded directory

Specify multiple directories by separating them with commas (,). To check the dir1 directory, enter dir1. To check dir2 in the dir1 directory, enter dir1/dir2.

If no directory is specified, all content of the entire project is checked by default. This parameter is valid only during project check.

4

Search by category

Search for or filter rules.

5

Setting rule

Select or deselect rules.

6

Uploading/Exporting rule

Export the rule details to an XLSX file on the local PC. Upload the rule file in XLSX format prepared on the local PC.