Querying Code Metrics
Function
This API is used to query the code metrics based on a check task ID.
Calling Method
For details, see Calling APIs.
URI
GET /v2/{project_id}/tasks/{task_id}/metrics-summary
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
task_id |
Yes |
String |
Definition Task ID, returned by the API for creating a check task. Each CodeArts Check task, branch task, or incremental task generated through an API has a unique ID. Constraints N/A Range N/A Default Value N/A |
project_id |
Yes |
String |
Definition Unique 32-character UUID of a project. Obtain a UUID by calling the API forquerying projects. Constraints N/A Range 32-character project ID. Default Value N/A |
Request Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
X-Auth-Token |
Yes |
String |
Definition User token. Obtain a token by calling the IAM API forobtaining a user token. The value of X-Subject-Token in the response header is the user token. Constraints N/A Range 1–100,000 characters Default Value N/A |
Response Parameters
Status code: 200
Parameter |
Type |
Description |
---|---|---|
task_id |
String |
Definition Task ID, returned by the API for creating a check task. Each CodeArts Check task, branch task, or incremental task generated through an API has a unique ID. Range N/A |
task_name |
String |
Definition Task name. Range N/A |
creator_id |
String |
Definition User ID of the task creator. Range N/A |
git_url |
String |
Definition Code repository address. Range N/A |
git_branch |
String |
Definition Code repository branch. Range N/A |
last_check_time |
String |
Definition Last check time. Format: 2025-07-21T03:38:53Z. Range N/A |
last_exec_time |
String |
Definition Last execution time. Format: 2025-07-21T03:38:53Z. Range N/A |
last_check_finish_time |
String |
Definition End time of the last execution. Format: 2025-07-21T03:38:53Z. Range N/A |
check_type |
String |
Definition Check type. Range N/A |
created_at |
String |
Definition Task creation time. Format: 2025-07-21T03:38:53Z. Range N/A |
metric_info |
MetricInfo object |
Metrics. |
Parameter |
Type |
Description |
---|---|---|
code_size |
String |
Definition Valid code lines, excluding blank and comment lines. Range N/A |
raw_lines |
String |
Definition Original code lines, including blank and comment lines. Range N/A |
methods_total |
String |
Definition Total number of functions. Range N/A |
cyclomatic_complexity_total |
String |
Definition Total cyclomatic complexity. Range N/A |
cyclomatic_complexity_per_method |
String |
Definition Average cyclomatic complexity. Range N/A |
maximum_cyclomatic_complexity |
String |
Definition Maximum cyclomatic complexity. Range N/A |
huge_cyclomatic_complexity_total |
String |
Definition Total number of functions with huge cyclomatic complexity. Range N/A |
huge_cyclomatic_complexity_ratio |
String |
Definition Percentage of functions with huge cyclomatic complexity. Range N/A |
cca_cyclomatic_complexity_total |
String |
Definition Total cyclomatic complexity adequacy (CCA). Range N/A |
cca_cyclomatic_complexity_per_method |
String |
Definition Average CCA. Range N/A |
maximum_cca_cyclomatic_complexity |
String |
Definition Maximum CCA. Range N/A |
huge_cca_cyclomatic_complexity_total |
String |
Definition Total number of functions with huge CCA. Range N/A |
cyclomatic_complexity_adequacy |
String |
Definition Cyclomatic complexity adequacy (CCA). Range N/A |
maximum_depth |
String |
Definition Maximum depth. Range N/A |
huge_depth_total |
String |
Definition Number of functions with huge depth. Range N/A |
huge_depth_ratio |
String |
Definition Percentage of functions with huge depth. Range N/A |
method_lines |
String |
Definition Total number of function lines. Range N/A |
lines_per_method |
String |
Definition Average lines per function. Range N/A |
huge_method_total |
String |
Definition Number of functions with excessive lines. Range N/A |
huge_method_ratio |
String |
Definition Percentage of functions with excessive lines. Range N/A |
files_total |
String |
Definition Total number of files. Range N/A |
folders_total |
String |
Definition Total number of directories. Range N/A |
lines_per_file |
String |
Definition Average lines per file. Range N/A |
huge_headerfile_total |
String |
Definition Number of huge header files. Range N/A |
huge_headerfile_ratio |
String |
Definition Percentage of huge header files. Range N/A |
huge_non_headerfile_total |
String |
Definition Number of huge source files. Range N/A |
huge_non_headerfile_ratio |
String |
Definition Percentage of huge source files. Range N/A |
huge_folder_total |
String |
Definition Number of huge directories. Range N/A |
huge_folder_ratio |
String |
Definition Percentage of huge directories. Range N/A |
file_duplication_total |
String |
Definition Number of duplicate files. Range N/A |
file_duplication_ratio |
String |
Definition File duplication rate. Range N/A |
non_hfile_duplication_total |
String |
Definition Number of duplicate source files. Range N/A |
non_hfile_duplication_ratio |
String |
Definition Source file duplication rate. Range N/A |
code_duplication_total |
String |
Definition Number of duplicate code blocks. Range N/A |
code_duplication_ratio |
String |
Definition Duplication rate. Range N/A |
non_hfile_code_duplication_total |
String |
Definition Number of duplicate code blocks in source files. Range N/A |
non_hfile_code_duplication_ratio |
String |
Definition Source file code duplication rate. Range N/A |
unsafe_functions_total |
String |
Definition Total number of unsafe functions. Range N/A |
unsafe_functions_kloc |
String |
Definition Density of unsafe functions. Range N/A |
redundant_code_total |
String |
Definition Number of redundant code blocks. Range N/A |
redundant_code_kloc |
String |
Definition Density of redundant code blocks. Range N/A |
warning_suppression_total |
String |
Definition Number of suppressed alarms. Range N/A |
warning_suppression_kloc |
String |
Definition Density of suppressed alarms. Range N/A |
Status code: 400
Parameter |
Type |
Description |
---|---|---|
error_code |
String |
Error code. |
error_msg |
String |
Error message. |
Status code: 401
Parameter |
Type |
Description |
---|---|---|
error_code |
String |
Error code. |
error_msg |
String |
Error message. |
Example Requests
Query the code metrics of task ID 2b31ed520xxxxxxebedb6e57xxxxxxxx under project ID e04b357xxxxx5ed832xxxxxx.
GET https://{endpoint}/v2/e04b357xxxxx5ed832xxxxxx/tasks/2b31ed520xxxxxxebedb6e57xxxxxxxx/metrics-summary null
Example Responses
Status code: 200
Request succeeded!
{ "task_id" : "435b58ecf7f54c45907c1384d01c94a6", "task_name" : "CSharp_02201119", "creator_id" : "ecadebb5041146cc96f9780f3d905e20", "git_url" : "git@****_02201119.git", "git_branch" : "master", "last_check_time" : "2020-02-20 11:37:46", "last_exec_time" : "2020-02-20 11:37:46", "last_check_finish_time" : "2020-02-20 11:53:46", "check_type" : "source", "created_at" : "2020-02-20 11:21:11", "metric_info" : { "code_size" : "133426.00", "raw_lines" : "182082.00", "methods_total" : "6840.00", "cyclomatic_complexity_total" : "27435.00", "cyclomatic_complexity_per_method" : "7.43", "maximum_cyclomatic_complexity" : "346.00", "huge_cyclomatic_complexity_total" : "167.00", "huge_cyclomatic_complexity_ratio" : "4.13", "cca_cyclomatic_complexity_total" : "26693.00", "cca_cyclomatic_complexity_per_method" : "7.25", "maximum_cca_cyclomatic_complexity" : "342.00", "huge_cca_cyclomatic_complexity_total" : "148.00", "cyclomatic_complexity_adequacy" : "21.00", "maximum_depth" : "333.00", "huge_depth_total" : "8.85", "huge_depth_ratio" : "91546.00", "method_lines" : "24.91", "lines_per_method" : "8.04", "huge_method_total" : "12300", "huge_method_ratio" : "12300", "files_total" : "629.00", "folders_total" : "426.00", "lines_per_file" : "12300", "huge_headerfile_total" : "12300", "huge_headerfile_ratio" : "12300", "huge_non_headerfile_total" : "12300", "huge_non_headerfile_ratio" : "12300", "huge_folder_total" : "12300", "huge_folder_ratio" : "12300", "file_duplication_total" : "12300", "file_duplication_ratio" : "12300", "non_hfile_duplication_total" : "12300", "non_hfile_duplication_ratio" : "12300", "code_duplication_total" : "3.28", "code_duplication_ratio" : "11782.00", "non_hfile_code_duplication_total" : "8.59", "non_hfile_code_duplication_ratio" : "11782.00", "unsafe_functions_total" : "17.17", "unsafe_functions_kloc" : "0.00", "redundant_code_total" : "0.00", "redundant_code_kloc" : "674.00", "warning_suppression_total" : "17.00", "warning_suppression_kloc" : "0.45" } }
Status code: 400
Bad Request
{ "error_code" : "CC.00000000", "error_msg" : "Network busy. Try again later." }
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.
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