Interface for Obtaining the Rule List
Function
This API queries the rule list based on conditions such as the language and problem level.
URI
GET /v2/rules
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
rule_languages |
No |
String |
Language corresponding to the rule. |
rule_severity |
No |
String |
Defect level. The options are as follows: 0: critical; 1: major; 2: minor; 3: warning. |
offset |
No |
Integer |
Pagination index, offset Minimum: 0 Default: 0 |
limit |
No |
Integer |
Number of records displayed on each page. Minimum: 1 Maximum: 1000 Default: 100 |
Request Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
X-Auth-Token |
Yes |
String |
User token. It can be obtained by calling an IAM API. The value of X-Subject-Token in the response header is the user token. Minimum: 1 Maximum: 100000 |
Response Parameters
Status code: 200
Parameter |
Type |
Description |
---|---|---|
info |
Array of RuleListItem objects |
Parameter description |
total |
Integer |
Total |
Parameter |
Type |
Description |
---|---|---|
rule_set |
String |
Rule Set Specification Classification |
rule_id |
String |
Rule ID. |
rule_language |
String |
Rule Language |
rule_name |
String |
Rule Name |
rule_severity |
String |
Rule Problem Severity |
rule_tages |
String |
Rule Tag |
right_example |
String |
Correct Example |
error_example |
String |
Negative example |
revise_opinion |
String |
Resolution suggestions |
rule_desc |
String |
Description |
Status code: 400
Parameter |
Type |
Description |
---|---|---|
error_code |
String |
Error Codes |
error_msg |
String |
Description |
Status code: 401
Parameter |
Type |
Description |
---|---|---|
error_code |
String |
Error Codes |
error_msg |
String |
Description |
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> uses the constant 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) {//The comparison result is always false.\n // ...\n}\n</pre>",
"revise_opinion" : "None",
"rule_set" : "HuaWeiJava"
}, {
"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> uses the constant 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) {//The comparison result is always false.\n // ...\n}\n</pre>",
"revise_opinion" : "None",
"rule_set" : "HuaWeiJava"
} ],
"total" : 2
}
Status code: 400
Bad Request
{
"error_code" : "CC.00000000",
"error_msg" : "The network is busy. Please try again later."
}
Status code: 401
Unauthorized
{
"error_code" : "CC.00000003",
"error_msg" : "The authentication information has expired."
}
Status Codes
Status Code |
Description |
---|---|
200 |
Request succeeded! |
400 |
Bad Request |
401 |
Unauthorized |
Error Codes
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.