Updated on 2026-02-03 GMT+08:00

Obtaining Rules

Function

This API is used to query the rule list. You can filter rules by language and issue severity.

Calling Method

For details, see Calling APIs.

Authorization Information

Each account root user has all the permissions required to call all APIs, but IAM users must be assigned the following required identity policy-based permissions. For details about the required permissions, see Permissions Policies and Supported Actions.

Action

Access Level

Resource Type (*: required)

Condition Key

Alias

Dependencies

codeartscheck::listRules

List

-

-

-

-

URI

GET /v2/rules

Table 1 Query Parameters

Parameter

Mandatory

Type

Description

rule_languages

No

String

Definition:

Rule language.

Constraints:

Must be a language supported by the current environment.

Value range:

Only one language can be passed. The following languages are supported:

  • ArkTS

  • C#

  • Cangjie

  • C++

  • CSS

  • Go

  • HTML

  • Java

  • JavaScript

  • Kotlin

  • Lua

  • PHP

  • Python

  • Rust

  • Scala

  • Shell

  • SQL

  • Terraform

  • TypeScript

Default value:

N/A

rule_severity

No

String

Definition:

Issue severity.

Constraints:

N/A

Value range:

  • 0: critical

  • 1: major

  • 2: minor

  • 3: suggestion

Default value:

0,1,2,3 By default, issues of all severity levels are queried.

offset

No

Integer

Definition

Offset for pagination.

Constraints

N/A

Range

0–999

Default Value

0

limit

No

Integer

Definition

Number of records displayed on each page.

Constraints

N/A

Range

0–200

Default Value

100

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

Definition :

User token. Obtain one by calling the IAM API Obtaining a User Token. The value of X-Subject-Token in the response header is a token.

Constraints:

N/A

Value range:

1–100,000 characters.

Default value:

N/A

X-Language

No

String

Definition:

Language of the response.

Constraints:

N/A

Value range:

  • zh-cn: Chinese.

  • en-us: English.

Default value:

zh-cn

Response Parameters

Status code: 200

Table 3 Response body parameters

Parameter

Type

Description

info

Array of RuleListItem objects

Definition

Rule information.

Range

N/A

total

Integer

Definition

Total number.

Range

N/A

Table 4 RuleListItem

Parameter

Type

Description

rule_set

String

Definition:

Service type.

Value range:

  • common: general.

  • common_standard_recommend: general recommendation.

  • common_standard_rule: general rule.

  • security: security.

  • security_standard_recommend: security recommendation.

  • security_standard_rule: security rule.

rule_id

String

Definition:

Rule ID.

Value range:

32-character UUID.

rule_language

String

Definition:

Rule language.

Value range:

The following languages are supported:

  • ArkTS

  • C#

  • Cangjie

  • C++

  • CSS

  • Go

  • HTML

  • Java

  • JavaScript

  • Kotlin

  • Lua

  • PHP

  • Python

  • Rust

  • Scala

  • Shell

  • SQL

  • Terraform

  • TypeScript

rule_name

String

Definition

Rule name.

Range

N/A

rule_severity

String

Definition:

Issue severity.

Value range:

  • 0: critical

  • 1: major

  • 2: minor

  • 3: suggestion

rule_tages

String

Definition:

Rule tag.

Value range:

  • huawei

  • iso5055

  • cert

  • cwe

  • top10

  • top25

  • misra

  • GJB

  • autosar

  • PCI DSS

right_example

String

Definition

Compliant example.

Range

Code block or text example.

error_example

String

Definition

Noncompliant example.

Range

Code block or text example.

revise_opinion

String

Definition

Fix suggestion.

Range

Code block or text example.

rule_desc

String

Definition

Rule description.

Range

N/A

Status code: 400

Table 5 Response body parameters

Parameter

Type

Description

error_code

String

Definition:

Error code.

Value range:

N/A

error_msg

String

Definition:

Error message.

Value range:

N/A

Status code: 401

Table 6 Response body parameters

Parameter

Type

Description

error_code

String

Definition:

Error code.

Value range:

N/A

error_msg

String

Definition:

Error message.

Value range:

N/A

Example Requests

GET https://{endpoint}/v2/rules

Example Responses

Status code: 200

Request succeeded!

{
  "info" : [ {
    "rule_id" : "2561",
    "rule_language" : "Java",
    "rule_name" : "\"=+\" cannot be replaced by \"+=\".",
    "rule_severity" : "1",
    "rule_tages" : "bug",
    "rule_desc" : "<p>Use strict equality operator (<code>===</code>) to compare different types. The result is always <code>false</code>. </p>",
    "right_example" : "<pre>\nvar a = 8;\nvar b = \"8\";\n\nif (a == b) {\n  // ...\n}\n</pre>\n<p>or</p>\n<pre>\nvar a = 8;\nvar b = \"8\";\n\nif (a === Number(b)) {\n  // ...\n}\n</pre>",
    "error_example" : "<pre>\nvar a = 8;\nvar b = \"8\";\n\nif (a === b) {  //Noncompliant, always false\n  // ...\n}\n</pre>",
    "revise_opinion" : "None",
    "rule_set" : "common"
  }, {
    "rule_id" : "8048",
    "rule_language" : "Java",
    "rule_name" : "\"Arrays.stream\" should be used for primitive arrays",
    "rule_severity" : "1",
    "rule_tages" : "performance",
    "rule_desc" : "<p>Use strict equality operator (<code>===</code>) to compare different types. The result is always <code>false</code>. </p>",
    "right_example" : "<pre>\nvar a = 8;\nvar b = \"8\";\n\nif (a == b) {\n  // ...\n}\n</pre>\n<p>or</p>\n<pre>\nvar a = 8;\nvar b = \"8\";\n\nif (a === Number(b)) {\n  // ...\n}\n</pre>",
    "error_example" : "<pre>\nvar a = 8;\nvar b = \"8\";\n\nif (a === b) {  //Noncompliant, always false\n  // ...\n}\n</pre>",
    "revise_opinion" : "None",
    "rule_set" : "common"
  } ],
  "total" : 2
}

Status code: 400

Bad Request

{
  "error_code" : "CC.xxxxxxxx.400",
  "error_msg" : "Verify request parameter failed. Check whether the request parameters are correct."
}

Status code: 401

Unauthorized

{
  "error_code" : "CC.00000003",
  "error_msg" : "Authentication information expired."
}

Status Codes

Status Code

Description

200

Request succeeded!

400

Bad Request

401

Unauthorized

Error Codes

See Error Codes.