A code processing method, device, equipment and medium

By obtaining the code of the problem code in the code warehouse submitted the user ID, creating a quality inspection authorized user and distributing quality inspection results, the problem of automatic distribution of code quality inspection results in the code detection platform is solved, and distribution efficiency and user experience are improved.

CN112650663BActive Publication Date: 2025-02-18SHANGHAI BILIBILI TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN201910962474.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-10-11
Publication Date
2025-02-18
Estimated Expiration
2039-10-11

AI Technical Summary

Technical Problem

In the prior art, it is difficult for the code detection platform to automatically distribute the code quality detection results, resulting in inefficient distribution and affecting the user experience.

Method used

By obtaining the code of the problem code in the code warehouse, submit the user ID, create a quality inspection authorized user, and distribute the quality inspection results to the corresponding quality inspection authorized user, realizing automatic distribution.

Benefits of technology

It improves the distribution efficiency of code quality detection results, solves the problem that developers need to filter quality detection results one by one, and improves the user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112650663B_ABST
    Figure CN112650663B_ABST
Patent Text Reader

Abstract

The present application discloses a code processing method, device, equipment and medium, which are applied in the field of computer technology to realize the automatic distribution of quality inspection results and improve the distribution efficiency of quality inspection results. Specifically, the following steps are: obtaining the code repository to be inspected; performing quality inspection on the code repository to obtain the quality inspection results of each line of problem code in the code repository; creating quality inspection authorized users based on the code submission user identifier of each line of problem code; and distributing the quality inspection results of each line of problem code to the corresponding quality inspection authorized users. In this way, by obtaining the code submission user identifier of each line of problem code, and creating quality inspection authorized users based on the code submission user identifier of each line of problem code, the code inspection platform can distribute the quality inspection results of each line of problem code to the corresponding quality inspection authorized users, thereby realizing the automatic distribution of quality inspection results and improving the distribution efficiency of quality inspection results.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a code processing method, device, equipment and medium. Background Art

[0002] In recent years, with the continuous development of network technology and multimedia technology, various types of application software have emerged. Among them, the code quality of application software is closely related to user experience, usage safety, etc., and has gradually become an important factor in evaluating application software.

[0003] In order to detect the code quality of application software, a code detection platform is proposed in the prior art. The code detection platform can detect various code problems such as duplicate code, vulnerabilities, errors, etc. in the source code of the application software. Developers can modify the source code according to the code problems detected by the code detection platform to optimize the quality of the source code.

[0004] At present, how to realize the automatic distribution of code quality detection results by the code detection platform and improve the distribution efficiency of code quality detection results are the current problems that need to be solved. Summary of the invention

[0005] The embodiments of the present application provide a code processing method, apparatus, device and medium for realizing automatic distribution of code quality detection results by a code detection platform, thereby improving the distribution efficiency of code quality detection results.

[0006] The technical solutions provided by the embodiments of this application are as follows:

[0007] On the one hand, an embodiment of the present application provides a code processing method, including:

[0008] Get the code repository to be tested;

[0009] Perform quality inspection on the code repository to obtain quality inspection results for each line of problematic code in the code repository, where problematic code refers to code that fails the quality inspection;

[0010] Obtain the code submission user ID of each line of problem code, and create quality inspection authorized users based on the code submission user ID of each line of problem code;

[0011] The quality inspection results of each line of problematic code are distributed to the corresponding quality inspection authorized users.

[0012] In a possible implementation, after performing a quality inspection on the code repository and obtaining a quality inspection result of each line of problematic code in the code repository, the method further includes:

[0013] From each line of problem code, read the code submitting user ID of the corresponding problem code;

[0014] The quality inspection result of each line of problematic code is associated with the code submitting user ID of each line of problematic code and stored in a quality inspection result database.

[0015] In a possible implementation, obtaining the code submission user identifier of each line of problematic code includes:

[0016] From the quality inspection result database, read the code submission user ID of each line of problem code.

[0017] In a possible implementation, obtaining the code submission user identifier of each line of problematic code includes:

[0018] From each line of problem code, read the code submitting user ID of the corresponding problem code.

[0019] In a possible implementation, before creating a quality inspection authorized user based on the code submission user identification of each line of the problem code, the following is also included:

[0020] It is determined that there is no quality inspection authorized user ID matching the code submission user ID of each line of problem code in the currently saved quality inspection authorized user set.

[0021] In a possible implementation, before creating a quality inspection authorized user based on the code submission user identification of each line of the problem code, the following is also included:

[0022] De-duplicate the code submission user ID for each line of problematic code.

[0023] In a possible implementation, based on the code submission user identification of each line of problem code, a quality inspection authorized user is created respectively, including:

[0024] Call the user creation interface, submit the user ID of each line of problem code as the login user name, and create corresponding quality inspection authorized users.

[0025] In a possible implementation, when creating quality inspection authorized users based on the user identification submitted by the code of each line of problem code, the following is also included:

[0026] Determine each line of qualified code in the code repository, where qualified code is code that has passed quality inspection;

[0027] From each line of qualified code, the code submission user ID of the corresponding qualified code is read, and based on the code submission user ID of each line of qualified code, quality inspection authorized users are created respectively.

[0028] In a possible implementation manner, after creating the quality inspection authorized user, the method further includes:

[0029] Based on the quality inspection authorized user IDs of each created quality inspection authorized user, the quality inspection authorized user collection is updated.

[0030] In a possible implementation manner, after creating the quality inspection authorized user, the method further includes:

[0031] Based on the current timestamp, update the login time of each quality inspection authorized user created.

[0032] On the other hand, an embodiment of the present application provides a code processing device, including:

[0033] A code acquisition unit, used to acquire a code repository to be tested;

[0034] A code detection unit is used to perform quality detection on the code repository and obtain quality detection results of each line of problematic code in the code repository, wherein the problematic code is the code that fails the quality detection;

[0035] A user creation unit is used to obtain the code submission user ID of each line of problem code, and create quality inspection authorized users based on the code submission user ID of each line of problem code;

[0036] The result distribution unit is used to distribute the quality inspection results of each line of problem code to the corresponding quality inspection authorized users.

[0037] In a possible implementation manner, the code processing device provided in the embodiment of the present application further includes:

[0038] The associated storage unit is used to perform quality inspection on the code warehouse in the code inspection unit, and after obtaining the quality inspection results of each line of problem code in the code warehouse, read the code submission user identifier of the corresponding problem code from each line of problem code, and associate the quality inspection results of each line of problem code with the code submission user identifier of each line of problem code and store them in the quality inspection result database.

[0039] In a possible implementation manner, when obtaining the code submission user identifier of each line of problem code, the user creation unit is specifically used to:

[0040] From the quality inspection result database, read the code submission user ID of each line of problem code.

[0041] In a possible implementation manner, when obtaining the code submission user identifier of each line of problem code, the user creation unit is specifically used to:

[0042] From each line of problem code, read the code submitting user ID of the corresponding problem code.

[0043] In a possible implementation manner, before the user identification is submitted based on the code of each line of the problem code and the quality inspection authorized user is created respectively, the user creation unit is further used to:

[0044] It is determined that there is no quality inspection authorized user ID matching the code submission user ID of each line of problem code in the currently saved quality inspection authorized user set.

[0045] In a possible implementation manner, before the user identification is submitted based on the code of each line of the problem code and the quality inspection authorized user is created respectively, the user creation unit is further used to:

[0046] De-duplicate the code submission user ID for each line of problematic code.

[0047] In a possible implementation manner, when creating quality inspection authorized users based on the user identifications submitted by the codes of each line of problem code, the user creation unit is specifically used to:

[0048] Call the user creation interface, submit the user ID of each line of problem code as the login user name, and create corresponding quality inspection authorized users.

[0049] In a possible implementation manner, when creating quality inspection authorized users based on the user identification submitted by the code of each line of the problem code, the user creation unit is further used to:

[0050] Determine each line of qualified code in the code repository, where qualified code is code that has passed quality inspection;

[0051] From each line of qualified code, the code submission user ID of the corresponding qualified code is read, and based on the code submission user ID of each line of qualified code, quality inspection authorized users are created respectively.

[0052] In a possible implementation manner, the code processing device provided in the embodiment of the present application further includes:

[0053] The user updating unit is used to update the quality inspection authorized user set based on the quality inspection authorized user identifiers of each quality inspection authorized user created by the user creating unit after the quality inspection authorized user is created by the user creating unit.

[0054] In a possible implementation manner, the code processing device provided in the embodiment of the present application further includes:

[0055] The time updating unit is used to update the login time of each quality inspection authorized user created by the user creating unit based on the current timestamp after the quality inspection authorized user is created by the user creating unit.

[0056] On the other hand, an embodiment of the present application provides a code processing device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, and when the processor executes the computer program, the code processing method provided in the embodiment of the present application is implemented.

[0057] On the other hand, an embodiment of the present application further provides a computer-readable storage medium, which stores computer instructions. When the computer instructions are executed by a processor, the code processing method provided in the embodiment of the present application is implemented.

[0058] The beneficial effects of the embodiments of the present application are as follows:

[0059] In an embodiment of the present application, by obtaining the code submission user identifier of each line of problem code, and based on the code submission user identifier of each line of problem code, respectively, quality inspection authorized users are created, so that the code inspection platform can distribute the obtained quality inspection results of each line of problem code to the corresponding quality inspection authorized users, thereby realizing the automatic distribution of quality inspection results, and further improving the distribution efficiency of quality inspection results.

[0060] Other features and advantages of the present application will be described in the subsequent description, and in part, will become apparent from the description, or will be understood by practicing the present application. The purpose and other advantages of the present application can be realized and obtained by the structures specifically pointed out in the written description, claims, and drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0061] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0062] Figure 1 This is a schematic diagram of the system framework of the code processing system in the embodiment of the present application;

[0063] Figure 2 It is a schematic diagram of the code processing method in the embodiment of the present application;

[0064] Figure 3A This is a flowchart of a code processing method in an embodiment of the present application;

[0065] Figure 3B A schematic diagram of the distribution status change of the quality monitoring result in the embodiment of the present application;

[0066] Figure 3C This is a schematic diagram of the viewing interface of the quality inspection results in the embodiment of the present application;

[0067] Figure 4This is a schematic diagram of a specific flow chart of the code processing method in an embodiment of the present application;

[0068] Figure 5 This is a functional structure diagram of a code processing device in an embodiment of the present application;

[0069] Figure 6 Schematic diagram of the hardware structure of the code processing device in the embodiment of the present application. DETAILED DESCRIPTION

[0070] In order to enable those skilled in the art to better understand the present application, the technical terms mentioned in the present application are first explained.

[0071] 1. Code management platform, which is a platform for managing code, such as GitLab, etc. GitLab is an open source distributed version control system that can manage the code, version and other related data of various projects such as application software.

[0072] The code submission user is the user who submits code on the code management platform, which can be, but is not limited to, the logged-in user of the code management platform. For example, the code submission user can be the logged-in user of GitLab.

[0073] The code submission user ID is the user name of the user who logs in to the code management platform. For example, the code submission user ID can be, but is not limited to, the user name of the user who logs in to GitLab.

[0074] 2. Code detection platform, which is a platform for code quality detection, such as SonarQube. SonarQube is an open source code analysis platform that can detect duplicate code, obvious errors, potential vulnerabilities, coding standards and other quality issues in the source code of various projects such as application software, and can display them through the Web UI.

[0075] The quality inspection authorized user is the login user of the code inspection platform. For example, the quality inspection authorized user can be, but is not limited to, the login user of SonarQube;

[0076] The quality inspection authorized user ID is the user name of the user who logs in to the code inspection platform. For example, the quality inspection authorized user ID can be, but is not limited to, the user name of the user who logs in to SonarQube.

[0077] The quality inspection authorized user set is a set of user names of all logged-in users of the code inspection platform. The quality inspection authorized user set can also record the recent login time of each logged-in user and can be stored in the form of a list. For example, the quality inspection authorized user set can be but is not limited to: the SonarQube authorized user list, which records the user names of all logged-in users of SonarQube and the most recent login time.

[0078] 3. Code repository is a collection of all codes corresponding to various projects such as application software. In this application, the code repository is a collection of all codes corresponding to the project to be tested obtained from the code management platform, wherein each line of code contained in the code repository carries the code submission user ID of the line of code.

[0079] 4. Problem code refers to the code that fails the quality inspection in the code repository, such as code with obvious errors, code that does not comply with coding standards, code with potential vulnerabilities, etc.

[0080] 5. Qualified code refers to the code that has passed the quality inspection in the code repository.

[0081] 6. A quality inspection result database is a database for storing quality inspection results of the code inspection platform. In the present application, the quality inspection result database stores at least the quality inspection result of each line of problem code in the code repository, and also stores a code problem record table for retrieving the quality inspection result of each line of problem code in the code repository. The code problem record table records at least the following fields: the position index of the problem code in the code repository, the position index of the quality inspection result of the problem code in the quality inspection result database, the code submission user ID of the problem code, etc.

[0082] It should be noted that the "first", "second", etc. mentioned in this application are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that such terms can be interchanged where appropriate, so that the embodiments described herein can be implemented in an order other than that illustrated or described herein. In addition, the "and / or" mentioned in this application describes the association relationship of associated objects, indicating that three relationships may exist, for example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the objects associated before and after are in an "or" relationship.

[0083] In order to make the purpose, technical solution and beneficial effects of this application clearer, the technical solution in the embodiment of this application will be clearly and completely described below in conjunction with the drawings in the embodiment of this application. Obviously, the described embodiment is only a part of the embodiment of this application, not all the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.

[0084] At present, after the code detection platform performs quality detection on the code warehouse to be detected and obtains the quality detection results of each line of problem code in the code warehouse, if the developers corresponding to the code warehouse have not successfully logged in to the code detection platform, the code detection platform will display the quality detection results of each line of problem code in the code warehouse in the form of a quality monitoring result list. The developers corresponding to the code warehouse need to filter out the quality detection results of their own problem codes one by one from the quality monitoring result list before they can modify and optimize the corresponding problem codes according to the filtered quality detection results. Obviously, the current method of processing quality detection results is inefficient and has a poor user experience. How to achieve automatic distribution of quality detection results when the code detection platform has not been successfully logged in is a problem that needs to be solved.

[0085] To this end, the present application embodiment provides a code processing system, see Figure 1 As shown, the code processing system may include a code management platform 101 and a code detection platform 102, wherein the code management platform 101 and the code detection platform 102 are communicatively connected via a communication network 103. In actual applications, each developer in the same project may upload part of the code written by each developer for the project to the code management platform 101. The code management platform 101 stores part of the code uploaded by each developer in the same project in the same code repository for management based on the project. For example, the code management platform 101 may perform regular inspections on the code repository of the project, and when it is found that there are changes in the code in the code repository of the project, a code detection request is sent to the code detection platform 102. When the code detection platform 102 receives the code detection request sent by the code management platform 101, it may obtain the code repository corresponding to the project to be detected from the code management platform 101, and use the code processing method provided in the embodiment of the present application to perform quality inspection, quality inspection result distribution, and other processing on the code repository corresponding to the project. For details, refer to Figure 2As shown, before processing the code warehouse, the code detection platform 102 can be set in the configuration of the code detection platform 102 to allow reading of the code submission user identification. Then, when processing the code warehouse, the code detection platform 102 can perform quality inspection on the code warehouse, obtain the quality inspection results of each line of problem code in the code warehouse, and obtain the code submission user identification of each line of problem code, create quality inspection authorized users based on the code submission user identification of each line of problem code, and distribute the quality inspection results of each line of problem code to the corresponding quality inspection authorized users. In this way, even if the code detection platform 102 is not successfully logged in, the code submission user identification of each line of problem code can be obtained, and the code submission user identification of each line of problem code can be created respectively, so that the code detection platform 102 can distribute the quality inspection results of each line of problem code obtained to the corresponding quality inspection authorized users, thereby realizing the automatic distribution of quality inspection results, improving the distribution efficiency of quality inspection results, and effectively solving the problem that when the code detection platform 102 is not successfully logged in, the developer needs to screen the quality inspection results of each problem code one by one from the quality monitoring result list, thereby affecting the user experience.

[0086] It should be understood that Figure 1 The number of code management platforms 101, code detection platforms 102 and communication networks 103 is only illustrative. According to actual needs, there can be any number of code management platforms 101, code detection platforms 102 and communication networks 103, and this application does not limit this.

[0087] After introducing the application scenarios and design concepts of the embodiments of the present application, the technical solutions provided by the embodiments of the present application are described below.

[0088] In the embodiment of the present application, before using the code detection platform 102 to perform quality detection on the code repository and distribute the quality detection results, it is necessary to pre-configure the code detection platform 102 to allow reading of the code submission user identifier from the code repository in the configuration of the code detection platform 102. In this way, the code detection platform 102 can read the code submission user identifier of the corresponding code from each line of code contained in the code repository during the process of performing quality detection on the code repository and distributing the quality detection results.

[0089] Further, after the code detection platform 102 is preconfigured, the code detection platform 102 can be used to perform quality detection on the code repository of the project to be detected and distribute the quality detection results. For details, see Figure 3A As shown, the process of the code processing method provided in the embodiment of the present application is as follows:

[0090] Step 301: Obtain the code repository to be tested.

[0091] In actual applications, the code management platform 101 can regularly check the code repositories of the managed projects. When it is found that the code in the code repository of a project has changed, the code detection platform 102 can be triggered to perform quality detection on the code repository of the project. More specifically, the code management platform 101 can carry information such as the project name and / or the storage address of the code repository of the project in the code detection request and send it to the code detection platform 102 to trigger the code detection platform 102 to perform quality detection on the code repository of the project. Furthermore, the code management platform 101 can also associate the project name and / or the storage address of the code repository of the project with the platform identifier of the code detection platform 102 for storage.

[0092] In specific implementation, when the code detection platform 102 receives the code detection request sent by the code management platform 101 , it can obtain the code repository to be detected from the code management platform 101 by calling the access interface of the code management platform 101 and carrying a token. More specifically, the code detection platform 102 can generate a first Token based on the project name and / or storage address carried in the code detection request, using a Token generation algorithm pre-agreed with the code management platform 101, and transmit the first Token and the platform identifier to the code management platform 101 by calling the access interface of the code management platform 101. After the code management platform 101 receives the first Token and the platform identifier transmitted by the code detection platform 102, it obtains the project name and / or storage address associated with the platform identifier according to the platform identifier, and generates a second Token based on the obtained project name and / or storage address, using the Token generation algorithm pre-agreed with the code management platform 101. When it is determined that the first Token and the second Token are the same, the corresponding code repository is obtained based on the obtained project name and / or storage address, and the code repository is returned to the code detection platform 102. In this way, the code detection platform 102 obtains the code repository to be detected.

[0093] Step 302: Perform a quality test on the code repository to obtain quality test results for each line of problematic code in the code repository.

[0094] In specific implementation, the code detection platform 102 can perform quality detection on each line of code in the code repository from aspects such as duplicate code, obvious errors, potential vulnerabilities, and coding standards, thereby obtaining quality detection results for each line of problematic code in the code repository that fails the quality detection.

[0095] In actual applications, in order to be able to quickly and accurately retrieve the quality inspection results of each line of problem code in the code warehouse in the future, the code inspection platform 102 can also read the code submission user identification of the corresponding problem code from each line of problem code in the code warehouse after performing quality inspection on the code warehouse and obtaining the quality inspection results of each line of problem code in the code warehouse, and associate the quality inspection results of each line of problem code with the code submission user identification of each line of problem code and store them in the quality inspection result database. Further, the code inspection platform 102 can also create a code problem record table for the code warehouse in the quality inspection result database, and write the position index of the problem code in the code warehouse, the position index of the quality inspection result of the problem code in the quality inspection result database, the code submission user identification of the problem code and other information into the corresponding fields of the code problem record table for each line of problem code in the code warehouse, so that the quality inspection results of each line of problem code in the code warehouse stored in the quality inspection result database can be retrieved according to the code problem record table in the future.

[0096] Step 303: Obtain the code submission user ID of each line of problem code, and create quality inspection authorized users based on the code submission user ID of each line of problem code.

[0097] In specific implementation, the code detection platform 102 may adopt, but is not limited to, the following methods when obtaining the code submission user identifier of each line of problematic code:

[0098] The first method: the code detection platform 102 reads the code submission user ID of each line of problematic code from the quality detection result database. More specifically, the code detection platform 102 can retrieve the code submission user ID field from the code problem record table stored in the quality detection result database, and read all the code submission user IDs recorded under the code submission user ID field, so as to obtain the code submission user ID of each line of problematic code.

[0099] The second way: the code checking platform 102 reads the code submission user identifier of the corresponding problem code from each line of problem code, thereby obtaining the code submission user identifier of each line of problem code.

[0100] In actual applications, in order to reduce unnecessary waste of resources and improve code processing efficiency, the code inspection platform 102 can, after obtaining the code submission user identifier of each line of problem code, first check whether there is a quality inspection authorized user identifier matching the code submission user identifier of each line of problem code in the quality inspection authorized user set. When it is determined that there is a quality inspection authorized user identifier matching the code submission user identifier of each line of problem code in the quality inspection authorized user set, the quality inspection results of each line of problem code in the code warehouse can be directly distributed to the corresponding quality inspection authorized users based on the quality inspection authorized user identifier matching the code submission user identifier of each line of problem code in the quality inspection authorized user set; conversely, when it is determined that there is no quality inspection authorized user identifier matching the code submission user identifier of each line of problem code in the quality inspection authorized user set, quality inspection authorized users are created separately based on the code submission user identifier of each line of problem code.

[0101] In actual applications, the code submission user IDs corresponding to each line of problem code may be repeated. Therefore, in order to avoid repeated creation of quality inspection authorized users, the code detection platform 102 can first deduplicate the code submission user IDs of each line of problem code after obtaining the code submission user IDs of each line of problem code, and then create quality inspection authorized users based on each code submission user ID obtained after deduplication. More specifically, the code detection platform 102 can call the user creation interface and use each code submission user ID as the login user name to create corresponding quality inspection authorized users.

[0102] It is worth mentioning that, in the embodiment of the present application, when creating a quality inspection authorized user, the code detection platform 102 can also obtain each line of qualified code in the code warehouse, and read the code submission user identification of the corresponding qualified code from each line of qualified code, and create quality inspection authorized users based on the code submission user identification of each line of qualified code. More specifically, after the code detection platform 102 reads the code submission user identification of the corresponding qualified code from each line of qualified code, it can also first check whether there is a quality inspection authorized user identification that matches the code submission user identification of each line of qualified code in the quality inspection authorized user set. When it is determined that there is a quality inspection authorized user identification that matches the code submission user identification of each line of qualified code in the quality inspection authorized user set, the code submission user identification of each line of qualified code can be not processed; on the contrary, when it is determined that there is no quality inspection authorized user identification that matches the code submission user identification of each line of qualified code in the quality inspection authorized user set, the code submission user identification of each line of qualified code can be de-duplicated, and the user creation interface is called, and each code submission user identification obtained after de-duplication is used as the login user name to create the corresponding quality inspection authorized user. In this way, when the subsequent code detection platform 102 detects that the code submitted again by the code submitting user with qualified code has quality problems, the quality detection result of the code can be automatically distributed to the quality inspection authorized user corresponding to the code submitting user, thereby further improving the code processing efficiency.

[0103] Furthermore, in order to ensure the accuracy and timeliness of each quality inspection authorized user identification recorded in the quality inspection authorized user set, after creating the quality inspection authorized user, the code detection platform 102 can also update the quality inspection authorized user set based on the quality inspection authorized user identification of each created quality inspection authorized user.

[0104] In actual applications, for the quality inspection authorized users who have not successfully logged into the code inspection platform 102 recently, that is, for inactive users, the code inspection platform 102 may not be able to automatically distribute the quality monitoring results. Based on this, in order to ensure the smooth distribution of quality inspection results, the code inspection platform 102 can also update the login time of each created quality inspection authorized user based on the current timestamp after creating the quality inspection authorized user. More specifically, the code inspection platform 102 can retrieve the login time field in the quality inspection authorized user set, and update the login time of each created quality inspection authorized user under the login time field according to the current timestamp, so that each created quality inspection authorized user becomes an active user, thereby ensuring the smooth distribution of quality inspection results.

[0105] Step 304: Distribute the quality inspection results of each line of problematic code to the corresponding quality inspection authorized users.

[0106] In actual applications, the code detection platform 102 distributes the quality detection results of each line of problematic code to the corresponding quality inspection authorized users. Figure 3B As shown in the figure, the quality inspection results of each line of problematic code are switched from the undistributed state to the state of having been distributed to the quality inspection authorized user. Furthermore, since the code inspection platform 102 uses the code submission user ID in the code management platform 101 when creating the quality inspection authorized user, the user name of the code inspection platform 102 is the same as the user name of the code management platform 101. Based on this, the developer can determine the user name in the code management platform 101 as the user name in the code inspection platform 102 and log in, thereby, referring to Figure 3C As shown, the developer can view the quality inspection results of all problem codes distributed to the authorized quality inspection user by the code inspection platform 102 in "My Problems", thereby effectively solving the problem that when the code inspection platform 102 is not successfully logged in, the developer needs to screen the quality inspection results of their own problem codes one by one from the quality monitoring result list, thus affecting the user experience.

[0107] The following takes "the code management platform 101 is GitLab, and the code detection platform 102 is SonarQube" as a specific application scenario to further describe the code processing method provided in the embodiment of the present application.

[0108] In actual applications, before using SonarQube to perform quality inspection on the code repository and distribute the quality inspection results, you can set the setting "sonar.scm.disabled" that indicates whether to allow retrieval of blame information from the source code control manager to "false" in the SonarQube configuration, thereby setting SonarQube to allow retrieval of blame information from the source code control manager. In this way, SonarQube can read the code submission user ID of the corresponding code from each line of code contained in the code repository during the process of performing quality inspection on the code repository and distributing the quality inspection results.

[0109] Furthermore, after pre-configuring SonarQube, you can use SonarQube to perform quality checks on the code repository to be tested in GitLab and distribute the quality test results. For details, see Figure 4 As shown, the process of the code processing method provided in the embodiment of the present application is as follows:

[0110] Step 401: GitLab regularly checks the code repositories of each Git project it manages.

[0111] Step 402: When GitLab detects that the code in the code repository of a Git project has changed, it carries information such as the project name of the Git project and / or the storage address of the code repository in the code detection request and sends it to SonarQube.

[0112] Step 403: GitLab associates and stores the project name and / or code repository storage address of the Git project with the platform identifier Sonar of SonarQube.

[0113] Step 404: SonarQube generates a first Token based on the project name and / or storage address carried in the code detection request and using a Token generation algorithm pre-agreed with GitLab.

[0114] Step 405: SonarQube transmits the first Token and the platform identifier Sonar to GitLab by calling the access interface of GitLab.

[0115] Step 406: GitLab obtains the project name and / or storage address associated with the platform identifier Sonar transmitted by SonarQube from the stored association relationship.

[0116] Step 407: GitLab generates a second Token based on the obtained project name and / or storage address using a Token generation algorithm pre-agreed with GitLab.

[0117] Step 408: When GitLab determines that the first Token and the second Token are the same, it obtains the corresponding code repository based on the obtained project name and / or storage address.

[0118] Step 409: GitLab returns the obtained code repository to SonarQube.

[0119] Step 410: SonarQube performs quality inspection on the code repository to obtain quality inspection results for each line of problematic code in the code repository.

[0120] Step 411: SonarQube reads the code submission user ID of the corresponding problem code from each line of problem code in the code repository, and associates the quality inspection result of each line of problem code with the code submission user ID of each line of problem code and stores it in the Sonar inspection result database.

[0121] Step 412: SonarQube creates a code problem record table (hereinafter referred to as the issue table) for the code repository in the Sonar detection result database. For each line of problem code in the code repository, the position index of the problem code in the code repository, the position index of the quality detection result of the problem code in the Sonar detection result database, the code submission user ID of the problem code and other information are written into the corresponding fields of the issue table.

[0122] Step 413: SonarQube retrieves the code submission user identification field (hereinafter referred to as the author_login field) from the issue table, and reads all code submission user identifications recorded under the author_login field.

[0123] Step 414: SonarQube performs deduplication processing on all the read code submission user IDs to obtain individual code submission user IDs.

[0124] Step 415: SonarQube detects whether there is a quality inspection authorized user ID (hereinafter referred to as Sonar user ID) matching each code submission user ID in the quality inspection authorized user set (hereinafter referred to as Sonar user list); if so, execute step 416; if not, execute step 417.

[0125] Step 416: SonarQube distributes the quality inspection results of each line of problematic code in the code repository to the corresponding quality inspection authorized users based on the Sonar user IDs in the Sonar user list that match the user IDs of each code submission.

[0126] Step 417: SonarQube calls the user creation interface (for example, the user creation interface is / api / users / create interface), and uses the user ID submitted by each code as the login user name to create corresponding quality inspection authorized users (hereinafter referred to as Sonar users).

[0127] It is worth mentioning that when SonarQube creates a Sonar user, it can also create corresponding Sonar users based on the code submission user ID of each line of qualified code in the code repository. The specific creation method is the same as the creation method described above, and the repetition will not be repeated.

[0128] Step 418: SonarQube updates the Sonar user list based on the Sonar user ID of each created Sonar user.

[0129] Step 419: SonarQube retrieves the login time field (for example, the login time field is the last_connection_date field) in the Sonar user list, and updates the login time of each created Sonar user under the last_connection_date field according to the current timestamp.

[0130] Step 420: SonarQube distributes the quality inspection results of each line of problematic code in the code repository to the corresponding Sonar users based on the most recently created Sonar users recorded in the Sonar user list.

[0131] Based on the above embodiments, the present application provides a code processing device. Figure 5 As shown, the code processing device 500 provided in the embodiment of the present application at least includes:

[0132] A code acquisition unit 501 is used to acquire a code repository to be detected;

[0133] The code detection unit 502 is used to perform quality detection on the code repository to obtain quality detection results of each line of problematic code in the code repository, wherein the problematic code is the code that fails the quality detection;

[0134] The user creation unit 503 is used to obtain the code submission user identification of each line of problem code, and create a quality inspection authorized user based on the code submission user identification of each line of problem code;

[0135] The result distribution unit 504 is used to distribute the quality inspection result of each line of problem code to the corresponding quality inspection authorized users.

[0136] In a possible implementation manner, the code processing device provided in the embodiment of the present application further includes:

[0137] The associated storage unit 505 is used to perform quality inspection on the code warehouse in the code inspection unit 502, and after obtaining the quality inspection results of each line of problem code in the code warehouse, read the code submission user identifier of the corresponding problem code from each line of problem code, and associate the quality inspection results of each line of problem code with the code submission user identifier of each line of problem code and store them in the quality inspection result database.

[0138] In a possible implementation manner, when obtaining the code submission user identifier of each line of problem code, the user creation unit 503 is specifically used to:

[0139] From the quality inspection result database, read the code submission user ID of each line of problem code.

[0140] In a possible implementation manner, when obtaining the code submission user identifier of each line of problem code, the user creation unit 503 is specifically used to:

[0141] From each line of problem code, read the code submitting user ID of the corresponding problem code.

[0142] In a possible implementation manner, before the user identification is submitted based on the code of each line of the problem code and the quality inspection authorized user is created respectively, the user creation unit 503 is further used to:

[0143] It is determined that there is no quality inspection authorized user ID matching the code submission user ID of each line of problem code in the currently saved quality inspection authorized user set.

[0144] In a possible implementation manner, before the user identification is submitted based on the code of each line of the problem code and the quality inspection authorized user is created respectively, the user creation unit 503 is further used to:

[0145] De-duplicate the code submission user ID for each line of problematic code.

[0146] In a possible implementation manner, when creating quality inspection authorized users based on the code submission user identifiers of each line of problem code, the user creation unit 503 is specifically used to:

[0147] Call the user creation interface, submit the user ID of each line of problem code as the login user name, and create corresponding quality inspection authorized users.

[0148] In a possible implementation manner, when creating quality inspection authorized users based on the user identifications submitted by the codes of each line of problem code, the user creation unit 503 is further used to:

[0149] Determine each line of qualified code in the code repository, where qualified code is code that has passed quality inspection;

[0150] From each line of qualified code, the code submission user ID of the corresponding qualified code is read, and based on the code submission user ID of each line of qualified code, quality inspection authorized users are created respectively.

[0151] In a possible implementation manner, the code processing device provided in the embodiment of the present application further includes:

[0152] The user updating unit 506 is used to update the set of quality inspection authorized users based on the quality inspection authorized user identifiers of the respective quality inspection authorized users created by the user creating unit 503 after the quality inspection authorized users are created by the user creating unit 503 .

[0153] In a possible implementation manner, the code processing device provided in the embodiment of the present application further includes:

[0154] The time updating unit 507 is used to update the login time of each quality inspection authorized user created by the user creating unit 503 based on the current timestamp after the quality inspection authorized user is created by the user creating unit 503.

[0155] It should be noted that the principle of solving the technical problem by the code processing device 500 provided in the embodiment of the present application is similar to the code processing method provided in the embodiment of the present application. Therefore, the implementation of the code processing device 500 provided in the embodiment of the present application can refer to the implementation of the code processing method provided in the embodiment of the present application, and the repeated parts will not be repeated.

[0156] After introducing the code processing method and apparatus provided in the embodiments of the present application, the code processing device provided in the embodiments of the present application is briefly introduced next.

[0157] The code processing device provided in the embodiment of the present application may be a server corresponding to the code quality detection platform, see Figure 6 As shown, the code processing device 600 provided in the embodiment of the present application includes at least: a processor 601, a memory 602, and a computer program stored in the memory 602 and executable on the processor 601. When the processor 601 executes the computer program, the code processing method provided in the embodiment of the present application is implemented.

[0158] It should be noted that Figure 6 The code processing device 600 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0159] The code processing device 600 provided in the embodiment of the present application may also include a bus 603 connecting different components (including the processor 601 and the memory 602). The bus 603 represents one or more of several types of bus structures, including a memory bus, a peripheral bus, a local bus, and the like.

[0160] The memory 602 may include a readable medium in the form of a volatile memory, such as a random access memory (RAM) 6021 and / or a cache memory 6022 , and may further include a read-only memory (ROM) 6023 .

[0161] The memory 602 may also include a program tool 6025 having a set (at least one) of program modules 6024, including but not limited to: an operating subsystem, one or more applications, other program modules and program data, each of which or some combination may include the implementation of a network environment.

[0162] The code processing device 600 may also communicate with one or more external devices 604 (e.g., keyboards, remote controls, etc.), and may also communicate with one or more devices that enable a user to interact with the code processing device 600 (e.g., mobile phones, computers, etc.), and / or communicate with any device that enables the code processing device 600 to communicate with one or more other code processing devices 600 (e.g., routers, modems, etc.). Such communication may be performed through an input / output (I / O) interface 605. Furthermore, the code processing device 600 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) through a network adapter 606. Figure 6 As shown, the network adapter 606 communicates with other modules of the code processing device 600 via the bus 603. It should be understood that although Figure 6 Not shown, other hardware and / or software modules may be used in conjunction with the code processing device 600, including but not limited to: microcode, device drivers, redundant processors, external disk drive arrays, disk arrays (Redundant Arrays of Independent Disks, RAID) subsystems, tape drives, and data backup storage subsystems.

[0163] The computer-readable storage medium provided in the embodiment of the present application is introduced below. The embodiment of the present application provides a computer-readable storage medium, which stores computer instructions, and when the computer instructions are executed by the processor, the code processing method provided in the embodiment of the present application is implemented. Specifically, the executable program can be built-in or installed in the code processing device 600, so that the code processing device 600 can implement the code processing method provided in the embodiment of the present application by executing the built-in or installed executable program.

[0164] In addition, the code processing method provided in the embodiment of the present application can also be implemented as a program product, which includes a program code. When the program product can be run on the code processing device 600, the program code is used to enable the code processing device 600 to execute the code processing method provided in the embodiment of the present application.

[0165] The program product provided in the embodiments of the present application may adopt any combination of one or more readable media, wherein the readable medium may be a readable signal medium or a readable storage medium, and the readable storage medium may be but is not limited to an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus or device, or any combination of the above. Specifically, more specific examples of readable storage media (a non-exhaustive list) include: an electrical connection with one or more wires, a portable disk, a hard disk, RAM, ROM, Erasable Programmable Read Only Memory (EPROM), optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.

[0166] The program product provided in the embodiment of the present application may adopt a CD-ROM and include program code, and may also be run on a computing device. However, the program product provided in the embodiment of the present application is not limited thereto. In the embodiment of the present application, the readable storage medium may be any tangible medium containing or storing a program, and the program may be used by or in combination with an instruction execution system, apparatus, or device.

[0167] It should be noted that, although several units or subunits of the device are mentioned in the above detailed description, this division is merely exemplary and not mandatory. In fact, according to the embodiments of the present application, the features and functions of two or more units described above can be embodied in one unit. Conversely, the features and functions of one unit described above can be further divided into multiple units to be embodied.

[0168] In addition, although the operations of the method of the present application are described in a specific order in the drawings, this does not require or imply that the operations must be performed in this specific order, or that all the operations shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps.

[0169] Although the preferred embodiments of the present application have been described, those skilled in the art may make other changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications falling within the scope of the present application.

[0170] Obviously, those skilled in the art can make various changes and modifications to the embodiments of the present application without departing from the spirit and scope of the embodiments of the present application. Thus, if these modifications and variations of the embodiments of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.

Claims

1. A code processing method, characterized in that: include: Get the code repository to be tested; Performing a quality inspection on the code repository to obtain a quality inspection result of each line of problematic code in the code repository, wherein the problematic code is code that fails the quality inspection; Obtain the code submission user ID of each line of the problem code, and create a quality inspection authorized user based on the code submission user ID of each line of the problem code; Distribute the quality inspection results of each line of problem code to the corresponding quality inspection authorized users respectively; Wherein, after performing quality inspection on the code repository and obtaining quality inspection results of each line of problematic code in the code repository, the method further includes: Reading the code submission user identification of the corresponding problem code from each line of problem code; The quality inspection results of the problem codes in each row are associated with the code submission user identifiers of the problem codes in each row and stored in a quality inspection result database; Wherein, based on the code submission user identification of each line of the problem code, a quality inspection authorized user is created respectively, including: Call the user creation interface, and submit the user ID with the code of each line of problem code as the login user name, and create the corresponding quality inspection authorized user respectively; After creating a quality inspection authorized user, it also includes: Based on the current timestamp, update the login time of each quality inspection authorized user created.

2. The code processing method according to claim 1, characterized in that: Obtaining the code submission user ID of each line of problem code, including: The code submitting user identifier of each row of the problem code is read from the quality inspection result database.

3. The code processing method according to claim 1, characterized in that: Obtaining the code submission user ID of each line of problem code, including: From the lines of question codes, read the code submitting user identifier of the corresponding question code.

4. The code processing method according to claim 1, characterized in that: Based on the code submission user ID of each line of the problem code, before creating the quality inspection authorized user respectively, it also includes: It is determined that in the currently saved set of quality inspection authorized users, there is no quality inspection authorized user identifier that matches the code submission user identifier of each line of problem code.

5. The code processing method according to claim 1, characterized in that: Based on the code submission user ID of each line of the problem code, before creating the quality inspection authorized user respectively, it also includes: The code submission user ID of each line of problematic code is deduplicated.

6. The code processing method according to any one of claims 1 to 5, characterized in that: When creating a quality inspection authorized user based on the code submission user ID of each line of the problem code, it also includes: Determine each line of qualified code in the code repository, wherein the qualified code is code that has passed quality inspection; From the rows of qualified codes, the code submission user identification of the corresponding qualified code is read, and based on the code submission user identification of the rows of qualified codes, the quality inspection authorized users are respectively created.

7. The code processing method according to claim 1, characterized in that: After creating a quality inspection authorized user, it also includes: Based on the quality inspection authorized user IDs of each created quality inspection authorized user, the quality inspection authorized user collection is updated.

8. A code processing device, characterized in that: include: A code acquisition unit, used to acquire a code repository to be tested; A code detection unit, configured to perform a quality detection on the code repository to obtain a quality detection result of each line of problematic code in the code repository, wherein the problematic code is code that fails the quality detection; A user creation unit, used to obtain the code submission user identification of each line of problem code, and create quality inspection authorized users based on the code submission user identification of each line of problem code; A result distribution unit, used to distribute the quality inspection results of each line of problem code to corresponding quality inspection authorized users; Wherein, the code detection unit is also used for: Reading the code submission user identification of the corresponding problem code from each line of problem code; The quality inspection results of the problem codes in each row are associated with the code submission user identifiers of the problem codes in each row and stored in a quality inspection result database; Wherein, based on the code submission user identification of each line of the problem code, a quality inspection authorized user is created respectively, including: Call the user creation interface, and submit the user ID with the code of each line of problem code as the login user name, and create the corresponding quality inspection authorized user respectively; After creating a quality inspection authorized user, it also includes: Based on the current timestamp, update the login time of each quality inspection authorized user created.

9. A code processing device, characterized in that: include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the code processing method according to any one of claims 1 to 7 when executing the computer program.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and when the computer instructions are executed by a processor, the code processing method according to any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Script defect scanning method and device, computer equipment and storage medium

    CN110231937A