CN111274127B - Code jumping method, device, equipment and medium in code evaluation - Google Patents

Code jumping method, device, equipment and medium in code evaluation Download PDF

Info

Publication number
CN111274127B
CN111274127B CN202010038881.1A CN202010038881A CN111274127B CN 111274127 B CN111274127 B CN 111274127B CN 202010038881 A CN202010038881 A CN 202010038881A CN 111274127 B CN111274127 B CN 111274127B
Authority
CN
China
Prior art keywords
code
code element
review
information
file
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202010038881.1A
Other languages
Chinese (zh)
Other versions
CN111274127A (en
Inventor
施展
刘志伟
白伟
李涛
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Baidu Netcom Science and Technology Co Ltd
Original Assignee
Beijing Baidu Netcom Science and Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Baidu Netcom Science and Technology Co Ltd filed Critical Beijing Baidu Netcom Science and Technology Co Ltd
Priority to CN202010038881.1A priority Critical patent/CN111274127B/en
Publication of CN111274127A publication Critical patent/CN111274127A/en
Application granted granted Critical
Publication of CN111274127B publication Critical patent/CN111274127B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/362Software debugging
    • G06F11/3636Software debugging by tracing the execution of the program
    • G06F11/364Software debugging by tracing the execution of the program tracing values on a bus
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3604Software analysis for verifying properties of programs

Abstract

The application discloses a code skipping method, a device, equipment and a medium in code review, and relates to a code review technology. The specific implementation scheme is as follows: analyzing a change code file of a code to be evaluated, acquiring code element information of at least one skipped code element, and storing the code element information in a database, wherein the code element information at least comprises position information, syntax information and signature information of the code element; displaying the change code file and marking the at least one code element; responding to a jump request aiming at any target code element in the marked code elements, and inquiring jump code elements corresponding to the target code elements and position information of the jump code elements in a changed code file from a database according to signature information of the target code elements; and skipping according to the position information of the skipping code elements, and displaying the page where the skipping code elements are located. The embodiment of the application provides a code skipping function in code review and improves development efficiency.

Description

Code jumping method, device, equipment and medium in code evaluation
Technical Field
The present application relates to the field of computer technologies, and in particular, to a code review technology, and more particularly, to a code skipping method, apparatus, device, and medium in code review.
Background
Code review (Code review) is one of the important methods for ensuring software quality in the development process of modern programs. Through code review, the code quality can be improved, technical debt is avoided, team members can know knowledge outside the self-emphasised business and the field, and the team standard execution can be guaranteed.
The code jump is one of the most commonly used functions in the software development process, and refers to a process of jumping from one code segment (such as a function, a class, a variable, a method, and the like) to another code segment. In the code evaluation process, the code skipping function can facilitate a developer to better understand codes and accelerate development efficiency.
The existing source code hosting platforms such as Github and Microsoft Azure can provide the code review function, can display the code change part in the code submission process once, and is convenient for reviewers to review modified codes. However, in these code review tools, only the changed part of the code can be displayed, and the function of code jump, which is essential in the process of code development and review, cannot be realized. The lack of these code skipping functions can cause that the reviewer can hardly understand the changed codes, so that the code review is time-consuming and labor-consuming, and the expected effect of ensuring the code quality can not be achieved.
Disclosure of Invention
The embodiment of the application provides a code jumping method, a device, equipment and a medium in code review, so that the code jumping capability is provided in the code review process, developers can understand codes better, and the development efficiency is accelerated.
In a first aspect, an embodiment of the present application provides a code skipping method in code review, including:
analyzing a change code file of a code to be evaluated, acquiring code element information of at least one code element with jump, and storing the code element information in a database, wherein the code element information at least comprises position information, syntax information and signature information of the code element;
displaying the change code file and marking the at least one code element;
responding to a jump request aiming at any target code element in the labeled code elements, and inquiring a jump code element corresponding to the target code element and position information of the jump code element in the change code file from the database according to the signature information of the target code element;
and skipping according to the position information of the skipping code elements, and displaying the page where the skipping code elements are located.
One embodiment in the above application has the following advantages or benefits: on the basis of the review function provided by the source code hosting platform, the skip function is added, the changed code file is analyzed to obtain at least one code element with skip and the code element information thereof, the code element with skip is stored in the database, when the changed code file is displayed, the code element with skip is marked out so as to be convenient for a reviewer to click, when a skip request aiming at any target code element in the mark is obtained, the skip code element corresponding to the target code element and the position information thereof can be inquired and obtained from the database, so that skip is realized, manual inquiry of the reviewer is avoided, the review time is shortened, the review efficiency is improved, the code quality is effectively ensured, the method is not limited by the language type, and the method can be applied to any language.
Optionally, before analyzing the change code file of the code to be evaluated, the method further includes:
creating a current code review directory according to review identification information in a current code review request, downloading a code to be reviewed from a code library to the current code review directory, and acquiring a change code file of the code to be reviewed;
correspondingly, the analyzing the change code file of the code to be evaluated comprises the following steps:
and analyzing the change code file of the code to be evaluated under the current code evaluation directory.
Optionally, under the current code review directory, the change code file acquired for the first time is used as a reference code;
correspondingly, the method further comprises the following steps:
and if the current code review request has review requests of different versions, creating review catalogues of different versions under the current code review catalog, wherein the changed code files in the review catalog of each version are obtained by copying the reference code, and the number of the review catalogues of different versions does not exceed a preset threshold value.
One embodiment in the above application has the following advantages or benefits: different directories are created for different reviews, and code analysis is performed under each directory respectively without influencing each other. Similarly, for the reviews of different versions in one review, respective directories are also created, and codes in the directories created later are obtained by copying the reference codes, that is, only one code needs to be downloaded, so that the time for downloading the codes is saved, and the review efficiency is improved.
Optionally, the analyzing the changed code file of the code to be reviewed to obtain the code element information of the at least one skipped code element, including:
analyzing a change code file of a code to be evaluated by using a code analyzer to obtain an abstract syntax tree of the change code file;
analyzing the abstract syntax tree to obtain code element information of each code element;
and acquiring at least one code element with jump and code element information thereof from each code element according to a preset jump rule and the grammatical information of each code element.
Optionally, before the analyzing the change code file of the code to be evaluated, the method further includes:
obtaining an external dependency class used by the change code file, and downloading a dependency package;
traversing the change code file, and filtering the change code file according to a preset filtering rule;
and analyzing according to the dependency package and the filtered change code file.
One embodiment in the above application has the following advantages or benefits: the incremental index is realized by analyzing the dependency package and the filtered change code file, the whole code library is not required to be analyzed, only the change file and the associated file are analyzed, and the change of other files cannot influence the currently reviewed code file and the analysis result, so that the analysis efficiency is improved, and the accuracy of the analysis result can be ensured.
Optionally, the syntax information at least includes a code element type, and the code element type includes a reference and a definition.
Optionally, the jump request is generated based on a trigger operation of a view reference button or a view definition button;
wherein the view reference button and the view definition button are generated according to a code element type of the object code element.
One embodiment in the above application has the following advantages or benefits: and realizing the query for referencing or defining the two jump situations, providing a view reference button for the code element with the reference, and providing a view definition button for the code element with the definition so that the reviewer can send out the request by clicking the button as required.
Optionally, the obtaining, from the database according to the signature information of the target code element, the jump code element corresponding to the target code element and the location information of the jump code element in the change code file includes:
according to the code element information in the database, inquiring code elements which are the same as the signature information of the target code element and are quoted or defined in code element types as jump code elements corresponding to the target code element;
and acquiring the position information of the jump code element in the change code file.
One embodiment in the above application has the following advantages or benefits: on the basis of the review function provided by the source code hosting platform, the skip function is added, at least one code element with skip and code element information thereof are obtained by analyzing the changed code file and are stored in the database, when the changed code file is displayed, the at least one code element with skip is marked so as to be convenient for a reviewer to click, when a skip request aiming at any target code element in the mark is obtained, the skip code element corresponding to the target code element and the position information thereof can be inquired and obtained from the database, so that skip is realized, and inquiry on code element definition or citation is realized, so that the manual inquiry of the reviewer is avoided, the review time is shortened, the review efficiency is improved, and the review efficiency is further improved.
In a second aspect, an embodiment of the present application further provides a code jumping device in code review, including:
the analysis module is used for analyzing a change code file of the code to be evaluated, acquiring code element information of at least one code element with jump, and storing the code element information in a database, wherein the code element information at least comprises position information, syntax information and signature information of the code element;
the marking module is used for displaying the change code file and marking the at least one code element;
the query module is used for responding to a jump request aiming at any target code element in the labeled code elements, and querying a jump code element corresponding to the target code element and position information of the jump code element in the change code file from the database according to the signature information of the target code element;
and the skipping module is used for skipping according to the position information of the skipping code element and displaying the page where the skipping code element is located.
In a third aspect, an embodiment of the present application further provides an electronic device, including:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform a code hopping method in a code review as described in any embodiment of the application.
In a fourth aspect, the present application further provides a non-transitory computer-readable storage medium storing computer instructions for causing a computer to execute the code skipping method in the code review according to any embodiment of the present application.
Other effects of the above alternatives will be described below with reference to specific embodiments.
Drawings
The drawings are included to provide a better understanding of the present solution and are not intended to limit the present application. Wherein:
FIG. 1a is a flowchart illustrating a code jumping method in code review according to a first embodiment of the present application;
FIG. 1b is another schematic flowchart of a code skipping method in code review according to the first embodiment of the present application;
FIG. 2 is a flowchart illustrating a code jumping method in code review according to a second embodiment of the present application;
FIG. 3 is a flowchart illustrating a code skipping method in code review according to a third embodiment of the present application;
FIG. 4 is a schematic structural diagram of a code jumping device in a code review according to a fourth embodiment of the present application;
FIG. 5 is a block diagram of an electronic device for implementing a code hopping method in code review according to an embodiment of the present application.
Detailed Description
The following description of the exemplary embodiments of the present application, taken in conjunction with the accompanying drawings, includes various details of the embodiments of the application to assist in understanding, which are to be considered exemplary only. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the present application. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
Fig. 1a is a schematic flowchart of a code skipping method in code review according to a first embodiment of the present application, which is applicable to providing a code skipping function during the code review process of a reviewer, so that the reviewer can conveniently view the definition of a current code element or view the condition of a code element referencing the current code element. The method can be executed by a code jumping apparatus in code review, which is implemented in software and/or hardware, and is preferably configured in an electronic device, such as a server or a computer device. As shown in fig. 1a, the method specifically includes the following steps:
s101, analyzing a change code file of a code to be evaluated, acquiring code element information of at least one skipped code element, and storing the code element information in a database, wherein the code element information at least comprises position information, syntax information and signature information of the code element.
The change code file may be a change code file of the code to be evaluated, which is obtained by using a diff function provided by a Git tool. The code to be reviewed may be a code downloaded from the Git repository according to information such as a library name, a branch, and a Commit ID (code review number) carried in the review message.
Some code elements in the code have jumps, which refer to the process of jumping from one code segment to another, including at least references and definitions. Therefore, if the code jumping function is provided, the definition or the reference of the code element can be conveniently checked by the reviewer. The method and the device for obtaining the code element information of the code element have the jump by analyzing the changed code file by using a code analysis technology, and storing the code element information in a database. Thus, when there is a need to view a definition or reference of a code element, the jump can be implemented by directly querying the database to determine the location of the definition or reference of the code element in the code.
Optionally, the analyzing the change code file of the code to be reviewed to obtain the code element information of at least one code element in which the jump exists includes:
analyzing a change code file of a code to be evaluated by using a code analyzer to obtain an abstract syntax tree of the change code file;
analyzing the abstract syntax tree to obtain code element information of each code element;
and acquiring at least one code element with jump and code element information thereof from each code element according to a preset jump rule and the grammatical information of each code element.
The abstract syntax tree can describe the relationship of each code element in the code file, so that after the abstract syntax tree is obtained, the code element information can be obtained by carrying out secondary analysis on the abstract syntax tree. The code element information includes at least position information, syntax information, and signature information of the code element. The position information, namely the position of the code element in the change code file, such as a start-stop row, a column, an offset in the file, a located file name, a branch name, a library name and the like; the syntax information at least comprises a code element type, a name and the like, and the code element type comprises a reference and a definition; the signature information is used to uniquely identify a code element, and may be set to, for example, a hash value of a character string formed by combining a file name and a start address of the code element.
After the code element information of each code element is acquired, at least one code element with jump and the code element information thereof can be acquired from each code element according to a preset jump rule and the syntax information of each code element. Specifically, the skip rule refers to a skip rule of a code writing language, and taking Java language as an example, types such as class, function, symbol, enumeration and the like can be regarded as definitions, other element types are regarded as references, and other code writing languages are similar. Therefore, according to the type of the code element, i.e. the syntax information in the code element information, in combination with the jump rule, it can be inferred whether the code element is a definition or a reference.
In addition, the analyzed code element information can be formatted into an object with a standard format and stored in a database, so that subsequent query is facilitated.
And S102, displaying the change code file, and labeling the at least one code element.
When the change code file is displayed, not only the changed part in the code is displayed, but also at least one code element with a jump is marked, for example, the code element is marked in an underline mode, so that a reviewer is informed that the code element has a jump, and if the reviewer needs to view reference or definition, the request can be triggered in a click mode or the like. The labeling mode of the code elements is not limited in any way in the embodiment of the application.
S103, responding to a jump request aiming at any target code element in the marked code elements, and inquiring a jump code element corresponding to the target code element and position information of the jump code element in the change code file from the database according to the signature information of the target code element.
S104, skipping is carried out according to the position information of the skipping code elements, and the page where the skipping code elements are located is displayed.
Optionally, the jump request is generated based on a trigger operation on a view reference button or a view definition button; wherein the view reference button and the view definition button are generated according to a code element type of the object code element.
Specifically, since the code element information of at least one code element having a jump is acquired, it is also known whether the jump type of the target code element to be viewed by the current reviewer is defined or referenced, and then a view reference button and a view definition button may be generated. For example, the button may appear when the reviewer moves the cursor around the annotated object code element, or after a right mouse click. And when the reviewer clicks the view reference button or the view definition button, triggering the jump request. The embodiment of the present application does not set any limit to the triggering manner of the skip request.
Furthermore, in response to the jump request, according to the signature information of the target code element, the jump code element corresponding to the target code element and the position information of the jump code element in the change code file can be queried from the database. The signature information can uniquely identify one code element, and the defined or quoted code of the target code element also has the same signature information, so that the jump code element corresponding to the target code element, namely the defined or quoted code element, can be inquired from the database according to the signature information, and jump can be realized according to the position of the jump code element.
Therefore, optionally, the obtaining, from the database according to the signature information of the target code element, the jump code element corresponding to the target code element and the location information of the jump code element in the change code file includes:
inquiring a code element which is the same as the signature information of the target code element and has a code element type of reference or definition as a jump code element corresponding to the target code element according to the code element information in the database;
and acquiring the position information of the jump code element in the change code file.
Fig. 1b is another schematic flow chart of a code jumping method in code review according to the first embodiment of the present application. As shown, the present embodiment includes two parts, the first part is an index end, and the second part is an on-line end. The index end and the online end can be on one electronic device or different electronic devices. The index end is used for downloading the code files from the Git warehouse, acquiring the changed files by using the Git parser, acquiring the code element information by using the code parser and storing the code element information in the database cluster. And when a reviewer sends a request for viewing the definition or reference, the index end can inquire the defined or referenced jump code element through the database and returns the defined or referenced jump code element as a result to the online end to realize jump.
According to the technical scheme, the skip function is added on the basis of the review function provided by the source code hosting platform, the at least one code element with skip is obtained by analyzing the changed code file and the code element information of the code element, the code element with skip is stored in the database, the code element with skip is marked when the changed code file is displayed so as to be convenient for a reviewer to click, when a skip request for any target code element in the mark is obtained, the skip code element corresponding to the target code element and the position information of the skip code element can be obtained by inquiring from the database, and therefore skip is achieved. However, in the prior art, if the definition or the reference is to be checked, only the keyword of the code element is searched in each changed file page by using a text search function carried by a browser, and whether a desired result exists or not is checked, which is time-consuming and labor-consuming. Therefore, the embodiment of the application avoids manual query of the reviewer, shortens the review time, improves the review efficiency, effectively ensures the code quality, is not limited by the language type, and can be applied to any language.
Fig. 2 is a schematic flowchart of a code jumping method in code review according to a second embodiment of the present application, and this embodiment is further optimized based on the above embodiments. As shown in fig. 2, the method specifically includes the following steps:
s201, creating a current code review directory according to review identification information in a current code review request, downloading a code to be reviewed to the current code review directory from a code library, and acquiring a change code file of the code to be reviewed.
The review identification information may be, for example, information such as a number uniquely identifying a primary review, and the directory name of the created current code review directory may be the review identification information. Thus, when there are multiple reviews, each review may correspond to a review catalog under which the downloaded code and the code's change code file are stored. The directory may be created, for example, on a hard disk at the index end.
S202, under the current code review directory, analyzing the change code file of the code to be reviewed, acquiring code element information of at least one code element with jump, and storing the code element information in the database, wherein the code element information at least comprises position information, syntax information and signature information of the code element.
The created directory stores the change code file and the analyzed code element information, namely, each evaluation is performed under the respective directory to show the distinction without mutual influence.
When there are multiple versions under one review, a new catalog can be created under the catalog of this review with the review identifier of each version as the name, and the code is downloaded to the catalog for the process of review of different versions. In order to save time for downloading code, review of multiple versions in the same review can be processed simultaneously within a single catalog.
Therefore, optionally, under the current code review directory, the change code file acquired for the first time is used as a reference code; correspondingly, the method further comprises the following steps: and if the current code review request has review requests of different versions, creating review catalogues of different versions under the current code review catalog, wherein the changed code files in the review catalog of each version are obtained by copying the reference code, and the number of the review catalogues of different versions does not exceed a preset threshold value.
Specifically, if the code is downloaded from the code library for each review of different versions, the code downloading time is inevitably increased, and the review efficiency is affected. Meanwhile, the problem that the analysis fails due to the fact that the files being analyzed are changed when the multiple versions are simultaneously reviewed can be avoided.
In addition, for the purpose of saving the storage space, an upper limit value of the number of copies of the reference code may be set, that is, the number of review catalogues of different versions does not exceed a preset threshold value, for example, n, and then the number of review catalogues of different versions processed at the same time does not exceed n. And when the version review requests arriving in a short time are more than n, concurrency can be guaranteed by setting semaphore, the first n versions are reviewed and processed at the same time, the rest are kept waiting, and when one of the n versions is reviewed and analyzed, the resource of the n versions is released, so that each version review can be analyzed after the released resource is obtained.
S203, displaying the change code file, and labeling the at least one code element.
S204, responding to a jump request aiming at any target code element in the labeled code elements, and inquiring a jump code element corresponding to the target code element and position information of the jump code element in the change code file from the database according to the signature information of the target code element.
S205, skipping is carried out according to the position information of the skipping code element, and the page where the skipping code element is located is displayed.
According to the technical scheme, the skip function is added on the basis of the review function provided by the source code hosting platform, the at least one code element with skip is obtained by analyzing the change code file and the code element information of the code element, the code element with skip is stored in the database, when the change code file is displayed, the at least one code element with skip is marked so as to be convenient for a reviewer to click, when a skip request for any target code element in the mark is obtained, the skip code element corresponding to the target code element and the position information of the code element can be inquired and obtained from the database, so that skip is realized, manual inquiry of the reviewer is avoided, the review time is shortened, the review efficiency is improved, the code quality is effectively guaranteed, the method is not limited by language types, and the method can be applied to any language.
Meanwhile, different catalogs are created for different reviews, and code analysis is carried out under each catalog respectively without influencing each other. Similarly, for the review of different versions in one review, respective directories are also created, and codes in the directories created later are obtained by copying the reference codes, that is, only one code needs to be downloaded, so that the time for downloading the codes is saved, and the review efficiency is improved.
Fig. 3 is a schematic flowchart of a code jump method in code review according to a third embodiment of the present application, and this embodiment further performs optimization based on the foregoing embodiments. As shown in fig. 3, the method specifically includes the following steps:
s301, obtaining an external dependency class used by the code file change, and downloading the dependency package.
S302, traversing the change code file, and filtering the change code file according to a preset filtering rule.
Wherein the filtering rules may be determined according to different code writing languages. For example, in some code writing languages, the test file may be used as an unnecessary file, and then the filtering test file may be used as the filtering rule.
S303, analyzing according to the dependency package and the filtered change code file, acquiring code element information of at least one code element with jump, and storing the code element information in a database, wherein the code element information at least comprises position information, syntax information and signature information of the code element.
During specific implementation, the download path of the dependency package and the path of the filtered source code file can be sent to a code analyzer, and the code analyzer analyzes the dependency package and the filtered change code file, so that independent analysis of part of files is achieved.
The time for analyzing all code files in one code library is related to the number of files in the library and the amount of code. For a code library containing tens of thousands of files, a complete parsing time often takes hours or more, whereas a code review from submission to completion of the review by the reviewer is likely to be completed in the order of minutes. Thus, to support code hopping in code review, the entire code library cannot be re-parsed, but only the changed files and their associated files are parsed. Therefore, the embodiment of the application only analyzes the filtered change code file and the dependency package related to the change code file, so that incremental indexing is realized, the result is the same as the result of analyzing the complete code library, but the indexing time can be greatly saved, and for the evaluation of changing several to dozens of files, code jump query can be carried out within the time of submitting the evaluation minute level by adopting the incremental indexing technology, so that the evaluation efficiency is improved.
S304, displaying the change code file, and labeling the at least one code element.
S305, responding to a jump request aiming at any target code element in the labeled code elements, and inquiring a jump code element corresponding to the target code element and position information of the jump code element in the change code file from the database according to the signature information of the target code element.
S306, skipping is carried out according to the position information of the skipping code elements, and the page where the skipping code elements are located is displayed.
According to the technical scheme, the skip function is added on the basis of the review function provided by the source code hosting platform, the at least one code element with skip is obtained by analyzing the change code file and the code element information of the code element, the code element with skip is stored in the database, when the change code file is displayed, the at least one code element with skip is marked so as to be convenient for a reviewer to click, when a skip request for any target code element in the mark is obtained, the skip code element corresponding to the target code element and the position information of the code element can be inquired and obtained from the database, so that skip is realized, manual inquiry of the reviewer is avoided, the review time is shortened, the review efficiency is improved, the code quality is effectively guaranteed, the method is not limited by language types, and the method can be applied to any language.
Meanwhile, the incremental index is realized by analyzing the dependency package and the filtered change code file, the whole code library is not required to be analyzed, only the change file and the related file thereof are analyzed, the change of other files cannot influence the currently reviewed code file and the analysis result, the analysis efficiency is improved, and the accuracy of the analysis result can be ensured.
Fig. 4 is a schematic structural diagram of a code jumping device in code review according to a fourth embodiment of the present application, which is applicable to providing a code jumping function during a code review process performed by a reviewer, so that the reviewer can conveniently view the definition of a current code element or view the condition of a code element referencing the current code element. The device can realize the code skipping method in the code review in any embodiment of the application. As shown in fig. 4, the apparatus 400 specifically includes:
the analysis module 401 is configured to analyze a changed code file of a code to be evaluated, acquire code element information of at least one code element in which a jump exists, and store the code element information in a database, where the code element information at least includes position information, syntax information, and signature information of the code element.
A labeling module 402, configured to display the change code file, and label the at least one code element.
And the query module 403 is configured to, in response to a jump request for any target code element in the labeled code elements, query, according to signature information of the target code element, a jump code element corresponding to the target code element and location information of the jump code element in the change code file from the database.
And the skipping module 404 is configured to skip according to the position information of the skipping code element, and display a page where the skipping code element is located.
Optionally, the apparatus further comprises:
the directory creation module is used for creating a current code review directory according to review identification information in a current code review request before the analysis module analyzes the change code file of the code to be reviewed, downloading the code to be reviewed from a code library to the current code review directory, and acquiring the change code file of the code to be reviewed;
correspondingly, the analysis module is specifically configured to analyze the change code file of the code to be reviewed under the current code review directory.
Optionally, under the current code review directory, the change code file acquired for the first time is used as a reference code;
correspondingly, the catalog creation module is further configured to:
and if the current code review request has review requests of different versions, creating review catalogues of different versions under the current code review catalog, wherein the changed code files in the review catalogues of each version are obtained by copying the reference code, and the number of the review catalogues of different versions does not exceed a preset threshold value.
Optionally, the parsing module includes:
the abstract syntax tree obtaining unit is used for analyzing the change code file of the code to be evaluated by using the code analyzer and obtaining the abstract syntax tree of the change code file;
a code element information obtaining unit, configured to analyze the abstract syntax tree to obtain code element information of each code element;
and the jump element acquisition unit is used for acquiring at least one code element with jump and code element information thereof from each code element according to a preset jump rule and the syntax information of each code element.
Optionally, the apparatus further comprises:
the filtering module is used for acquiring an external dependency class used by a change code file before the analysis module analyzes the change code file of the code to be evaluated, and downloading a dependency package; traversing the change code file, and filtering the change code file according to a preset filtering rule; and analyzing according to the dependency package and the filtered change code file.
Optionally, the syntax information at least includes a code element type, and the code element type includes a reference and a definition.
Optionally, the jump request is generated based on a trigger operation on a view reference button or a view definition button;
wherein the view reference button and the view definition button are generated according to a code element type of the object code element.
Optionally, the query module includes:
the query unit is used for querying the code element which is the same as the signature information of the target code element and has a code element type of reference or definition according to the code element information in the database, and the code element type is used as a jump code element corresponding to the target code element;
and the position acquisition unit is used for acquiring the position information of the jump code element in the change code file.
The code skipping device 400 in the code review provided by the embodiment of the application can execute the code skipping method in the code review provided by any embodiment of the application, and has corresponding functional modules and beneficial effects of the execution method. Reference may be made to the description of any method embodiment of the present application for a matter not explicitly described in this embodiment.
According to an embodiment of the present application, an electronic device and a readable storage medium are also provided.
As shown in fig. 5, it is a block diagram of an electronic device according to a code skipping method in code review in the embodiment of the present application. Electronic devices are intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. Electronic devices may also represent various forms of mobile devices, such as personal digital processors, cellular telephones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be examples only, and are not meant to limit implementations of the present application that are described and/or claimed herein.
As shown in fig. 5, the electronic apparatus includes: one or more processors 501, memory 502, and interfaces for connecting the various components, including high-speed interfaces and low-speed interfaces. The various components are interconnected using different buses and may be mounted on a common motherboard or in other manners as desired. The processor may process instructions for execution within the electronic device, including instructions stored in or on the memory to display graphical information of a GUI on an external input/output apparatus (such as a display device coupled to the interface). In other embodiments, multiple processors and/or multiple buses may be used, along with multiple memories and multiple memories, as desired. Also, multiple electronic devices may be connected, with each device providing portions of the necessary operations (e.g., as a server array, a group of blade servers, or a multi-processor system). In fig. 5, one processor 501 is taken as an example.
Memory 502 is a non-transitory computer readable storage medium as provided herein. Wherein the memory stores instructions executable by at least one processor to cause the at least one processor to perform the code hopping methods of the code review provided herein. The non-transitory computer-readable storage medium of the present application stores computer instructions for causing a computer to perform the code hopping method in the code review provided herein.
The memory 502, which is a non-transitory computer readable storage medium, may be used to store non-transitory software programs, non-transitory computer executable programs, and modules, such as program instructions/modules (e.g., the parsing module 401, the labeling module 402, the query module 403, and the skip module 404 shown in fig. 4) corresponding to the code skip method in the code review in the embodiments of the present application. The processor 501 executes various functional applications of the server and data processing, i.e., implementing the code hopping method in the code review in the above-described method embodiments, by running non-transitory software programs, instructions, and modules stored in the memory 502.
The memory 502 may include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function; the storage data area may store data and the like created according to use of an electronic device implementing the code hopping method in the code review of the embodiment of the present application. Further, the memory 502 may include high speed random access memory, and may also include non-transitory memory, such as at least one magnetic disk storage device, flash memory device, or other non-transitory solid state storage device. In some embodiments, the memory 502 may optionally include a memory remotely located from the processor 501, and these remote memories may be connected via a network to an electronic device implementing the code hopping method of the code review of the embodiments of the present application. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The electronic device for implementing the code skipping method in the code review of the embodiment of the application may further include: an input device 503 and an output device 504. The processor 501, the memory 502, the input device 503 and the output device 504 may be connected by a bus or other means, and fig. 5 illustrates the connection by a bus as an example.
The input device 503 may receive input numeric or character information and generate key signal input related to user setting and function control of an electronic device implementing the code hopping method in the code review according to the embodiment of the present application, for example, an input device such as a touch screen, a keypad, a mouse, a track pad, a touch pad, a pointing stick, one or more mouse buttons, a track ball, a joystick, or the like. The output devices 504 may include a display device, auxiliary lighting devices (e.g., LEDs), and haptic feedback devices (e.g., vibrating motors), among others. The display device may include, but is not limited to, a Liquid Crystal Display (LCD), a Light Emitting Diode (LED) display, and a plasma display. In some implementations, the display device can be a touch screen.
Various implementations of the systems and techniques described here can be realized in digital electronic circuitry, integrated circuitry, application specific ASICs (application specific integrated circuits), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs that are executable and/or interpretable on a programmable system including at least one programmable processor, which may be special or general purpose, receiving data and instructions from, and transmitting data and instructions to, a storage system, at least one input device, and at least one output device.
These computer programs (also known as programs, software applications, or code) include machine instructions for a programmable processor, and may be implemented using high-level procedural and/or object-oriented programming languages, and/or assembly/machine languages. As used herein, the terms "machine-readable medium" and "computer-readable medium" refer to any computer program product, apparatus, and/or device (e.g., magnetic discs, optical disks, memory, programmable Logic Devices (PLDs)) used to provide machine instructions and/or data to a programmable processor, including a machine-readable medium that receives machine instructions as a machine-readable signal. The term "machine-readable signal" refers to any signal used to provide machine instructions and/or data to a programmable processor.
To provide for interaction with a user, the systems and techniques described here can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and a pointing device (e.g., a mouse or a trackball) by which a user can provide input to the computer. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic, speech, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a back-end component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such back-end, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), wide Area Networks (WANs), the internet, and blockchain networks.
The computer system may include clients and servers. A client and server are generally remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other.
According to the technical scheme of the embodiment of the application, on the basis of the review function provided by the source code hosting platform, the skip function is added, at least one code element with skip and code element information thereof are obtained by analyzing the changed code file and are stored in the database, when the changed code file is displayed, the at least one code element with skip is marked so as to be convenient for a reviewer to click, when a skip request for any target code element in the mark is obtained, the skip code element corresponding to the target code element and the position information thereof can be inquired and obtained from the database, so that skip is realized, and inquiry on code element definition or citation is realized, therefore, manual inquiry of the reviewer is avoided, review time is shortened, review efficiency is improved, and further, review efficiency can be improved through a plurality of review processing mechanisms and incremental indexes, code quality is effectively guaranteed, and the method is not limited by language types, and can be applied to any language.
It should be understood that various forms of the flows shown above may be used, with steps reordered, added, or deleted. For example, the steps described in the present application may be executed in parallel, sequentially, or in different orders, and the present invention is not limited thereto as long as the desired results of the technical solutions disclosed in the present application can be achieved.
The above-described embodiments should not be construed as limiting the scope of the present application. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may be made in accordance with design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims (18)

1. A code jumping method in code review is characterized by comprising the following steps:
analyzing a change code file of a code to be evaluated, acquiring code element information of at least one code element with jump, and storing the code element information in a database, wherein the code element information at least comprises position information, syntax information and signature information of the code element;
displaying the change code file and marking the at least one code element;
responding to a jump request aiming at any target code element in the labeled code elements, and inquiring a jump code element corresponding to the target code element and position information of the jump code element in the change code file from the database according to the signature information of the target code element;
and skipping according to the position information of the skipping code elements, and displaying the page where the skipping code elements are located.
2. The method of claim 1, wherein prior to said parsing the change code file for code to be reviewed, the method further comprises:
creating a current code review directory according to review identification information in a current code review request, downloading a code to be reviewed to the current code review directory from a code library, and acquiring a change code file of the code to be reviewed;
correspondingly, the analyzing the change code file of the code to be evaluated comprises the following steps:
and analyzing the change code file of the code to be reviewed under the current code review directory.
3. The method according to claim 2, characterized in that under the current code review directory, a change code file acquired for the first time is used as a reference code;
correspondingly, the method further comprises the following steps:
and if the current code review request has review requests of different versions, creating review catalogues of different versions under the current code review catalog, wherein the changed code files in the review catalogues of each version are obtained by copying the reference code, and the number of the review catalogues of different versions does not exceed a preset threshold value.
4. The method of claim 1, wherein the parsing the change code file of the code to be reviewed to obtain the code element information of the at least one code element in which the jump exists comprises:
analyzing a change code file of a code to be evaluated by using a code analyzer to obtain an abstract syntax tree of the change code file;
analyzing the abstract syntax tree to obtain code element information of each code element;
and acquiring at least one code element with jump and code element information thereof from each code element according to a preset jump rule and the grammatical information of each code element.
5. The method of claim 1, wherein prior to said parsing the change code file for code to be reviewed, the method further comprises:
obtaining an external dependency class used by the change code file, and downloading a dependency package;
traversing the change code file, and filtering the change code file according to a preset filtering rule;
and analyzing according to the dependency package and the filtered change code file.
6. The method of claim 1, wherein the syntax information comprises at least a code element type, and wherein the code element type comprises a reference and a definition.
7. The method of claim 6, wherein the jump request is generated based on a trigger operation to a view reference button or a view definition button;
wherein the view reference button and the view definition button are generated according to a code element type of the object code element.
8. The method according to claim 6, wherein the obtaining, from the database according to the signature information of the target code element, the jump code element corresponding to the target code element and the location information of the jump code element in the change code file includes:
according to the code element information in the database, inquiring code elements which are the same as the signature information of the target code element and are quoted or defined in code element types as jump code elements corresponding to the target code element;
and acquiring the position information of the jump code element in the change code file.
9. A code hopping apparatus in a code review, comprising:
the analysis module is used for analyzing a change code file of the code to be evaluated, acquiring code element information of at least one code element with jump, and storing the code element information in a database, wherein the code element information at least comprises position information, syntax information and signature information of the code element;
the marking module is used for displaying the change code file and marking the at least one code element;
the query module is used for responding to a jump request aiming at any target code element in the marked code elements, and querying the jump code element corresponding to the target code element and the position information of the jump code element in the change code file from the database according to the signature information of the target code element;
and the skipping module is used for skipping according to the position information of the skipping code element and displaying the page where the skipping code element is located.
10. The apparatus of claim 9, further comprising:
the directory creation module is used for creating a current code review directory according to review identification information in a current code review request before the analysis module analyzes the change code file of the code to be reviewed, downloading the code to be reviewed from a code library to the current code review directory, and acquiring the change code file of the code to be reviewed;
correspondingly, the analysis module is specifically configured to analyze the change code file of the code to be reviewed under the current code review directory.
11. The apparatus according to claim 10, wherein a change code file obtained for the first time is used as a reference code under the current code review directory;
correspondingly, the catalog creation module is further configured to:
and if the current code review request has review requests of different versions, creating review catalogues of different versions under the current code review catalog, wherein the changed code files in the review catalogues of each version are obtained by copying the reference code, and the number of the review catalogues of different versions does not exceed a preset threshold value.
12. The apparatus of claim 9, wherein the parsing module comprises:
the abstract syntax tree acquisition unit is used for analyzing the change code file of the code to be evaluated by using the code analyzer and acquiring the abstract syntax tree of the change code file;
a code element information obtaining unit, configured to analyze the abstract syntax tree to obtain code element information of each code element;
and the jump element acquisition unit is used for acquiring at least one code element with jump and code element information thereof from each code element according to a preset jump rule and the syntax information of each code element.
13. The apparatus of claim 9, further comprising:
the filtering module is used for acquiring an external dependency class used by a change code file before the analysis module analyzes the change code file of the code to be evaluated, and downloading a dependency package; traversing the change code file, and filtering the change code file according to a preset filtering rule; and analyzing according to the dependency package and the filtered change code file.
14. The apparatus of claim 9, wherein the syntax information comprises at least a code element type, and wherein the code element type comprises a reference and a definition.
15. The apparatus of claim 14, wherein the jump request is generated based on a trigger operation to a view reference button or a view definition button;
wherein the view reference button and the view definition button are generated according to a code element type of the object code element.
16. The apparatus of claim 14, wherein the query module comprises:
the query unit is used for querying the code elements which are the same as the signature information of the target code elements and have the code element types of reference or definition according to the code element information in the database, and the code elements are taken as the jump code elements corresponding to the target code elements;
and the position acquisition unit is used for acquiring the position information of the jump code element in the change code file.
17. An electronic device, comprising:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the code hopping method in the code review as recited in any one of claims 1-8.
18. A non-transitory computer-readable storage medium storing computer instructions for causing a computer to perform the code hopping method in the code review according to any one of claims 1 to 8.
CN202010038881.1A 2020-01-14 2020-01-14 Code jumping method, device, equipment and medium in code evaluation Active CN111274127B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010038881.1A CN111274127B (en) 2020-01-14 2020-01-14 Code jumping method, device, equipment and medium in code evaluation

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010038881.1A CN111274127B (en) 2020-01-14 2020-01-14 Code jumping method, device, equipment and medium in code evaluation

Publications (2)

Publication Number Publication Date
CN111274127A CN111274127A (en) 2020-06-12
CN111274127B true CN111274127B (en) 2023-04-07

Family

ID=70998712

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010038881.1A Active CN111274127B (en) 2020-01-14 2020-01-14 Code jumping method, device, equipment and medium in code evaluation

Country Status (1)

Country Link
CN (1) CN111274127B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112860565A (en) * 2021-02-24 2021-05-28 北京皮尔布莱尼软件有限公司 Code evaluation method, system, computing device and storage medium
CN113282282B (en) * 2021-05-31 2022-05-06 深圳赛安特技术服务有限公司 Business requirement form publishing method and device, electronic equipment and storage medium

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107015911A (en) * 2017-04-07 2017-08-04 广东亿迅科技有限公司 The code review method and device of continuous integrating
CN107092475A (en) * 2016-12-21 2017-08-25 阿里巴巴集团控股有限公司 The call method and device of a kind of interactive controls
CN108536577A (en) * 2017-03-02 2018-09-14 北京嘀嘀无限科技发展有限公司 program code information processing method and device
WO2019005351A1 (en) * 2017-06-29 2019-01-03 Microsoft Technology Licensing, Llc Code review rebase diffing
CN109976793A (en) * 2019-03-15 2019-07-05 北京字节跳动网络技术有限公司 A kind of operation method of application program, device, equipment and medium
CN109992519A (en) * 2019-04-11 2019-07-09 睿驰达新能源汽车科技(北京)有限公司 A kind of methods, devices and systems that information is shown
CN110286938A (en) * 2019-07-03 2019-09-27 北京百度网讯科技有限公司 For exporting the method and apparatus for being directed to the evaluation information of user

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8739150B2 (en) * 2010-05-28 2014-05-27 Smartshift Gmbh Systems and methods for dynamically replacing code objects via conditional pattern templates
US9721615B2 (en) * 2014-10-27 2017-08-01 Cisco Technology, Inc. Non-linear video review buffer navigation

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107092475A (en) * 2016-12-21 2017-08-25 阿里巴巴集团控股有限公司 The call method and device of a kind of interactive controls
CN108536577A (en) * 2017-03-02 2018-09-14 北京嘀嘀无限科技发展有限公司 program code information processing method and device
CN107015911A (en) * 2017-04-07 2017-08-04 广东亿迅科技有限公司 The code review method and device of continuous integrating
WO2019005351A1 (en) * 2017-06-29 2019-01-03 Microsoft Technology Licensing, Llc Code review rebase diffing
CN109976793A (en) * 2019-03-15 2019-07-05 北京字节跳动网络技术有限公司 A kind of operation method of application program, device, equipment and medium
CN109992519A (en) * 2019-04-11 2019-07-09 睿驰达新能源汽车科技(北京)有限公司 A kind of methods, devices and systems that information is shown
CN110286938A (en) * 2019-07-03 2019-09-27 北京百度网讯科技有限公司 For exporting the method and apparatus for being directed to the evaluation information of user

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
傅仰耿 等.基于证据推理面向生命周期的可信软件评估.《南京师大学报(自然科学版)》.2013,第36卷(第01期),第133-141页. *
张迅珍 等.RV32I控制单元设计与实现.《微电子学与计算机》.2018,第35卷(第03期),第74-78页. *

Also Published As

Publication number Publication date
CN111274127A (en) 2020-06-12

Similar Documents

Publication Publication Date Title
US11461111B2 (en) Method for running applets, and electronic device
CN111666206B (en) Method, device, equipment and storage medium for acquiring influence range of change code
US8667456B1 (en) Cloud-based indexing for integrated development environments
US20140173574A1 (en) Compilation dependency resolution from a diverse group of candidate resources
CN101286119A (en) Method for determining function point changing through code analysis
US9563421B2 (en) Refining data understanding through impact analysis
US20210209526A1 (en) Landing page processing method, device and medium
US9311077B2 (en) Identification of code changes using language syntax and changeset data
CN111274127B (en) Code jumping method, device, equipment and medium in code evaluation
US11860838B2 (en) Data labeling method, apparatus and system, and computer-readable storage medium
US9760349B1 (en) Managing different software dependencies associated with source code
CN111654495A (en) Method, apparatus, device and storage medium for determining traffic generation source
US11775290B2 (en) Detection of API backward compatibility across software versions
CN111666372A (en) Method and device for analyzing query term query, electronic equipment and readable storage medium
EP3320430B1 (en) Automatic imports and dependencies in large-scale source code repositories
CN111831320A (en) Plug-in management method and device, electronic equipment and storage medium
CN111796851A (en) Client base library updating method and device, electronic equipment and storage medium
CN113220279A (en) Code index management method, device, equipment and medium
CN115421831A (en) Method, device, equipment and storage medium for generating calling relation of activity component
CN111880778B (en) Method and device for generating interface document, electronic equipment and storage medium
CN111931524B (en) Method, apparatus, device and storage medium for outputting information
CN114217798A (en) Code generation method and device for database form interface
CN112181429A (en) Information processing method and device and electronic equipment
US10866993B2 (en) Managing online help information in a data center
CN111831317A (en) Method and device for acquiring dependency relationship between services, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant