CN115827467A - Code detection method, medium, device and computing equipment - Google Patents

Code detection method, medium, device and computing equipment Download PDF

Info

Publication number
CN115827467A
CN115827467A CN202211585574.0A CN202211585574A CN115827467A CN 115827467 A CN115827467 A CN 115827467A CN 202211585574 A CN202211585574 A CN 202211585574A CN 115827467 A CN115827467 A CN 115827467A
Authority
CN
China
Prior art keywords
code
detected
node
detection
nodes
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.)
Pending
Application number
CN202211585574.0A
Other languages
Chinese (zh)
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.)
Hangzhou Netease Zaigu Technology Co Ltd
Original Assignee
Hangzhou Netease Zaigu 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 Hangzhou Netease Zaigu Technology Co Ltd filed Critical Hangzhou Netease Zaigu Technology Co Ltd
Priority to CN202211585574.0A priority Critical patent/CN115827467A/en
Publication of CN115827467A publication Critical patent/CN115827467A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Stored Programmes (AREA)

Abstract

The embodiment of the disclosure provides a code detection method, medium, device and computing equipment. The method comprises the following steps: in response to receiving a code text from a software development platform, acquiring an abstract syntax tree of the code text; determining nodes to be detected from the nodes in the abstract syntax tree; and carrying out standard detection on the code text of the node to be detected by using the code standard matched with the node to be detected to obtain a detection result. The code file is subjected to code specification inspection through the plug-in based on the compiler, so that the efficiency and the accuracy of the code specification inspection are remarkably improved.

Description

Code detection method, medium, device and computing equipment
Technical Field
Embodiments of the present disclosure relate to the field of computer technologies, and in particular, to a code detection method, medium, apparatus, and computing device.
Background
Developers develop according to the set code specification, so that the stability and the expansion capability of the source code can be improved. Currently, after a developer completes development, the code text is ensured to be in accordance with the code specification through manual inspection, but the mode is easy to make mistakes and is low in efficiency.
This section is intended to provide a background or context to the embodiments of the disclosure recited in the claims. The description herein is not admitted to be prior art by inclusion in this section.
Disclosure of Invention
In this context, embodiments of the present disclosure desirably provide a code detection method, medium, apparatus, and computing device in order to improve the efficiency and accuracy of code detection.
In a first aspect of the disclosed embodiments, a code detection method is provided, which is applied to a plug-in implemented based on a compiler, and includes:
in response to receiving code texts from a software development platform, acquiring abstract syntax trees of the code texts;
determining nodes to be detected from nodes in the abstract syntax tree;
and carrying out standard detection on the code text of the node to be detected by using the code standard matched with the node to be detected to obtain a detection result.
In an embodiment of the present disclosure, the determining nodes to be detected from the nodes in the abstract syntax tree includes:
and filtering the nodes in the abstract syntax tree, acquiring the nodes meeting the standard inspection requirement, and determining the nodes to be detected.
In an embodiment of the present disclosure, the node to be detected is provided with a detection condition for triggering detection;
the code specification matched with the node to be detected is used for carrying out specification detection on the code text corresponding to the node to be detected to obtain a detection result, and the method comprises the following steps:
and in response to the detection condition for triggering the node to be detected, carrying out standard detection on the code text corresponding to the node to be detected by using the code standard matched with the node to be detected to obtain a detection result.
In an embodiment of the present disclosure, the performing specification detection on the code text corresponding to the node to be detected by using the code specification matched with the node to be detected to obtain a detection result includes:
and if the code text corresponding to the node to be detected does not meet the requirement of the code specification, generating prompt information, and obtaining a detection result according to the prompt information and the code text corresponding to the node to be detected.
In one embodiment of the present disclosure, the method further comprises:
and acquiring a correction scheme of the code text corresponding to the node to be detected.
In one embodiment of the present disclosure, the method further comprises:
sending a detection result to the software development platform so that the software development platform generates a log file based on the received detection results of all or part of the nodes to be detected;
acquiring the log file, and acquiring a code to be corrected from the log file, wherein the code to be corrected comprises a code text corresponding to the node to be detected;
and sending the code to be corrected and the correction scheme of the code to be corrected to a client corresponding to the node to which the code to be corrected belongs.
In one embodiment of the present disclosure, the method further comprises:
and compiling the code file under the condition that the detection result indicates that the code texts of all the nodes to be detected conform to the corresponding code specifications.
In one embodiment of the disclosure, the plug-in is implemented based on a Clang compiler and the software development platform includes Xcode.
In a second aspect of the disclosed embodiments, there is provided a code detection apparatus applied to a plug-in implemented based on a compiler, including:
the software development platform comprises an acquisition unit, a processing unit and a processing unit, wherein the acquisition unit is used for acquiring an abstract syntax tree of a code text under the condition of receiving the code text from a software development platform;
the determining unit is used for determining the nodes to be detected from the nodes in the abstract syntax tree;
and the detection unit is used for carrying out standard detection on the code text of the node to be detected by using the code standard matched with the node to be detected to obtain a detection result.
In an embodiment of the present disclosure, the determining unit is specifically configured to filter nodes in the abstract syntax tree, obtain nodes that meet a specification check requirement, and determine the nodes as nodes to be detected.
In an embodiment of the present disclosure, the node to be detected is provided with a detection condition for triggering detection; the detection unit is specifically configured to:
and in response to the detection condition for triggering the node to be detected, carrying out standard detection on the code text corresponding to the node to be detected by using the code standard matched with the node to be detected to obtain a detection result.
In an embodiment of the present disclosure, the detection unit is specifically configured to: and if the code text corresponding to the node to be detected does not meet the requirement of the code specification, generating prompt information, and obtaining a detection result according to the prompt information and the code text corresponding to the node to be detected.
In an embodiment of the present disclosure, the detection unit is further configured to obtain a correction scheme of a code text corresponding to the node to be detected.
In an embodiment of the present disclosure, the apparatus further includes a notification unit, configured to send a detection result to the software development platform, so that the software development platform generates a log file based on the received detection result of all or part of the nodes to be detected;
acquiring the log file, and acquiring a code to be corrected from the log file, wherein the code to be corrected comprises a code text corresponding to the node to be detected;
and sending the code to be corrected and the correction scheme of the code to be corrected to a client corresponding to the node to which the code to be corrected belongs.
In one embodiment of the present disclosure, the apparatus further includes a compiling unit configured to: and compiling the code file under the condition that the detection result indicates that the code texts of all the nodes to be detected conform to the corresponding code specifications.
In some embodiments, the plug-in is implemented based on a Clang compiler and the software development platform includes Xcode.
In a third aspect of embodiments of the present disclosure, there is provided a computer-readable storage medium having stored thereon computer program instructions which, when executed by a processor, implement the method of any of the embodiments.
In a fourth aspect of embodiments of the present disclosure, there is provided a computing device comprising: a memory, a processor;
the memory is used for storing computer instructions executable on the processor, and the processor is used for realizing the method in any embodiment when executing the computer instructions.
According to the code detection method disclosed by the embodiment of the disclosure, the abstract syntax tree of the code text can be obtained, the node to be detected is determined from the nodes in the abstract syntax tree, the code specification matched with the node to be detected is utilized to carry out specification detection on the code text of the node to be detected, the detection result is obtained, and the manpower and time consumed by manual code specification inspection are saved, so that the code specification detection efficiency is remarkably improved, and the code quality is improved.
Drawings
The above and other objects, features and advantages of exemplary embodiments of the present disclosure will become readily apparent from the following detailed description read in conjunction with the accompanying drawings. Several embodiments of the present disclosure are illustrated by way of example, and not by way of limitation, in the figures of the accompanying drawings and in which:
FIG. 1 illustratively provides a flow chart of a method of code detection;
FIG. 2 is an exemplary interaction flow diagram of a code detection method;
FIG. 3 is a block diagram illustrating an exemplary code detection apparatus;
FIG. 4 is a schematic diagram of a computer-readable storage medium provided by the present disclosure;
fig. 5 is a schematic structural diagram of a computing device provided by the present disclosure.
In the drawings, the same or corresponding reference numerals indicate the same or corresponding parts.
Detailed Description
The principles and spirit of the present disclosure will be described with reference to a number of exemplary embodiments. It is understood that these embodiments are given solely for the purpose of enabling those skilled in the art to better understand and to practice the present disclosure, and are not intended to limit the scope of the present disclosure in any way. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
As will be appreciated by one skilled in the art, embodiments of the present disclosure may be embodied as a system, apparatus, device, method, or computer program product. Accordingly, the present disclosure may be embodied in the form of: entirely hardware, entirely software (including firmware, resident software, micro-code, etc.), or a combination of hardware and software.
According to the embodiment of the disclosure, a code detection method, a device, equipment and a storage medium are provided.
The principles and spirit of the present disclosure are explained in detail below with reference to several representative embodiments of the present disclosure.
The public people find that the code specification is the basic guarantee of engineering health, but members in a team generally have different code specifications and styles, and the members in the same team can be constrained to obey the formulated code specification in a manual inspection mode at present, but the mode is time-consuming, labor-consuming and prone to error.
In view of this, the present disclosure provides a code detection method, which utilizes a plug-in implemented based on a compiler to automatically trigger detection of a relevant code specification during compiling a project, thereby improving efficiency of code specification detection.
A code detection method according to an exemplary embodiment of the present disclosure is described below with reference to the accompanying drawings.
Fig. 1 exemplarily provides a flowchart of a code detection method, and as shown in fig. 1, the code detection method provided by the present disclosure includes the following steps S101 to S103.
In step S101, in response to receiving a code text from a software development platform, an abstract syntax tree of the code text is obtained.
Developers can write codes in the software development platform, run after writing is completed and check running results. That is to say, the software development platform may invoke a plug-in implemented based on a compiler to perform code specification detection on the code text when receiving the operation instruction, and compile the code text when the code text conforms to the code specification.
The plug-in can acquire an Abstract Syntax Tree (AST) of the code text under the condition that the plug-in receives the code text sent by a software development platform, for example, can perform lexical analysis on the code text to obtain a lexical analysis result; and carrying out syntactic analysis on the lexical analysis result to generate an abstract syntax tree.
Wherein the abstract syntax tree is an abstract representation of the source code syntax structure. It represents the syntactic structure of a programming language in the form of a tree, consisting of a collection of nodes, each representing a structure in the source code. Node types are generally used to distinguish different structures, and the common types are: identifier, binary expression, variable declaration, function declaration, etc., and the present disclosure does not limit the node type.
In step S102, nodes to be detected are determined from the nodes in the abstract syntax tree.
In some embodiments, the formulated code specification may be analyzed in advance to obtain the node type to be detected.
And determining the node with the node type matched with the node type to be detected in the abstract syntax tree as the node to be detected.
The code specifications established in the embodiments of the present disclosure may include the specification of writing codes and the checking of security risks. The specification of writing code may include, for example, specification detection of a listener contained in the code text.
In step S103, performing specification detection on the code text of the node to be detected by using the code specification matched with the node to be detected, so as to obtain a detection result.
In the embodiment of the present disclosure, a corresponding code specification may be set for each type of node, and a code specification matched with the type of the node to be detected is used to perform specification detection on the code text of the node to be detected, so as to obtain a detection result.
For example, corresponding code specifications may be set for different types of function nodes, and the code text of the function node to be detected is subjected to specification detection by using the code specification matched with the node type of the function node to be detected, so as to obtain a detection result.
According to the code detection method disclosed by the embodiment of the disclosure, the abstract syntax tree of the code text can be obtained, the node to be detected is determined from the nodes in the abstract syntax tree, the code specification matched with the node to be detected is utilized to carry out specification detection on the code text of the node to be detected, the detection result is obtained, and the manpower and time consumed by manual code specification inspection are saved, so that the code specification detection efficiency is remarkably improved, and the code quality is improved.
In some embodiments, the determining a node to be detected from the nodes in the abstract syntax tree includes: and filtering the nodes in the abstract syntax tree, acquiring the nodes meeting the standard inspection requirement, and determining the nodes to be detected.
By analyzing the code specification, the specification checking requirement, that is, the node which needs to be checked for the code specification can be obtained.
The specification checking requirements may include specification checking of nodes that conform to a specified node type and/or specification checking of nodes that conform to a locality of reference condition. It should be noted that, the present disclosure does not limit the content of the specification checking requirement, and the specification checking requirement may be obtained according to the code specification formulated by each development team.
Under the condition of obtaining the standard inspection requirement, the nodes in the abstract syntax tree can be filtered, the nodes meeting the standard inspection requirement are obtained, and the nodes are determined to be the nodes to be detected.
In one embodiment, assuming that the specification check requires detection of a node containing a variable name, in this case, all nodes in the abstract syntax tree may be traversed, the node containing the variable name is identified, and the node containing the variable name is determined as the node to be detected.
In another embodiment, it is assumed that the specification check requires detection of a node containing a function name, in which case all nodes in the abstract syntax tree may be traversed, the node containing the function name is identified, and the node containing the function name is determined as the node to be detected.
In some embodiments, a node to be detected may be configured with a detection condition for triggering detection, for example, a detection opportunity for triggering detection may be configured for the node to be detected.
Under the condition that a node to be detected is provided with a detection condition for triggering detection, performing standard detection on a code text corresponding to the node to be detected by using a code standard matched with the node to be detected to obtain a detection result, including: and in response to the detection condition for triggering the node to be detected, carrying out standard detection on the code text corresponding to the node to be detected by using the code standard matched with the node to be detected to obtain a detection result.
In the embodiment of the present disclosure, the detection time of the node to be detected may be configured as: and under the condition of acquiring the node to be detected, triggering to carry out standard detection on the code file corresponding to the node to be detected to obtain a detection result.
In the embodiment of the present disclosure, a detection condition for triggering detection may be configured for a node to be detected according to characteristics of the node to be detected. For example, in the case that the node to be detected is a listener, the detection timing of the listener may be configured as: and under the condition that the event triggering the monitor monitoring is detected, triggering the code file corresponding to the monitor to carry out standard detection to obtain a detection result.
It should be understood by those skilled in the art that other detection conditions for triggering detection may also be configured for the node to be detected, and the disclosure is not limited thereto.
In some embodiments, the performing, by using the code specification matched with the node to be detected, a specification detection on the code text corresponding to the node to be detected to obtain a detection result includes:
and if the code text corresponding to the node to be detected meets the requirement of the code specification, generating a detection result that the node to be detected meets the requirement of the corresponding code specification.
And if the code text corresponding to the node to be detected does not meet the requirement of the code specification, generating prompt information, and obtaining a detection result according to the prompt information and the code text corresponding to the node to be detected.
The code specification refers to a specification formulated according to an application scene, a precondition, a specification type, a general grammar rule and a judgment standard of the node to be detected. For example, whether the code type corresponding to the code text corresponding to the node to be detected conforms to the general grammar rule is detected.
Those skilled in the art will appreciate that the above code specifications may be specifically configured according to actual needs, and the present disclosure is not limited thereto.
In the embodiment of the present disclosure, corresponding prompt information may be generated for different situations that do not meet the code specification, for example, for a certain class of nodes to be detected, the types that do not meet the code specification requirement may be divided into several types according to the content that does not meet the code specification requirement, and corresponding prompt information may be generated for each situation.
If the code text corresponding to the node to be detected does not meet the requirement of the code specification, the prompt information corresponding to the type which does not meet the requirement of the code specification can be obtained according to the content which does not meet the requirement of the code specification.
In the embodiment of the disclosure, by dividing the condition that the code does not meet the code specification requirement, a direction can be provided for a developer to modify the code, so that the efficiency of the developer to repair the code is improved.
In some embodiments, a correction scheme of the code text corresponding to the node to be detected may be obtained. That is, a modification scheme matching the prompt information may be generated for different prompt information, and in the case of generating the prompt information, a modification scheme corresponding to the prompt information may be acquired according to the prompt information. It should be understood by those skilled in the art that the modification scheme of the code text corresponding to the node to be detected can also be obtained by other manners, which is not limited by the present disclosure.
According to the embodiment of the disclosure, when the abnormal code text which does not meet the code specification exists in the code text, the prompt information can be generated and the correction scheme can be provided, so that a developer can quickly modify the code according to the prompt information and the correction scheme, and the error positioning efficiency can be improved.
In some embodiments, in the case that the plug-in generates the detection result, the plug-in may send the detection result to a software development platform, so that the software development platform generates a log file based on the received detection result of all or part of the nodes to be detected; acquiring the log file, and acquiring a code to be corrected from the log file, wherein the code to be corrected comprises a code text corresponding to the node to be detected; and sending the code to be corrected and the correction scheme of the code to be corrected to a client corresponding to the node to which the code to be corrected belongs.
The plug-in can send all the detection results generated by the plug-in to the software development platform. In order to improve the processing efficiency of the software development platform, the plug-in can send a detection result to the software development platform when the code text corresponding to the node to be detected does not meet the requirement of the code specification.
For a software development platform, a log file can be generated based on the received detection results of all nodes to be detected; under the condition that the data size corresponding to the detection result is large, a plurality of log files can be generated based on the received detection result of part of the nodes to be detected, and therefore the efficiency of the plug-in for obtaining the log files subsequently is improved.
In the embodiment of the present disclosure, the code to be corrected and the correction scheme of the code to be corrected may be sent to the client corresponding to the node to which the code to be corrected belongs, where the client corresponding to the node may be obtained through the node to which the code to be corrected belongs, and the client may include an identifier of a development tool corresponding to a developer.
The operation of checking the code specification through manpower is not only easy to deviate, but also time and labor are wasted, the code specification detection is realized through the integrated plug-in the XCode, and the development efficiency can be improved. The embodiment can also provide a repair scheme for the code to be corrected, support one-key repair, and help developers to pay more attention to service development.
In the embodiment of the present disclosure, the code file is compiled when the detection result indicates that the code texts of all the nodes to be detected conform to the corresponding code specifications.
In one embodiment, the plug-in is implemented based on a Clang compiler and the software development platform includes Xcode.
In the following embodiments of the present disclosure, a code detection method provided by the present disclosure will be described with reference to fig. 2, by taking an example that a plug-in implemented based on a Clang compiler automatically triggers relevant code specifications and checks of potential safety hazards when compiling an iOS project.
FIG. 2 is an exemplary interaction flow diagram of a code detection method; as shown in FIG. 2, the process of implementing code specification detection through the interaction between a plug-in and a software development platform includes the following steps.
Because the default Clang compiler of the iOS system does not support the operation of the plug-in, the Clang version is compiled in a self-defined mode and registered, and the normal execution of the plug-in function is ensured.
In step 201, a plug-in is injected into the Xcode.
For example, a Clang version and path used by the plug-in to compile the resource file may be injected to process the resource file that needs to be compiled. And then, the path and the name of the plug-in are injected, so that Xcode calling and plug-in loading are facilitated.
In step 202, XCode sends the code text to be compiled to the plug-in.
And triggering callback by the XCode under the condition of receiving the code text to be compiled, calling the current code text back to the plug-in according to the path and the name of the plug-in, and finishing subsequent compiling processing by the plug-in.
In step 203, the plug-in obtains an abstract syntax tree of the code text.
And after the code text is called back into the plug-in, analyzing the code text to generate the AST data.
For example, a class implementing abstract syntax tree parsing may be registered to parse code text. The code text may be parsed, for example, using yxastation, to generate AST data.
In step 204, the nodes to be detected are determined from the nodes in the abstract syntax tree.
In this embodiment, node filtering may be performed on the AST data, a node to be detected is screened out, and a time for triggering checking on the node to be detected is configured.
In the previous example, after the yxastation parses the current code text to generate AST data, the AST data may be transmitted to the yxstprovider, and the yxstprovider performs node filtering on the received AST data to screen out node data to be detected, and configures a time for triggering checking on the current node data yxtatchhandler.
In step 205, the code specification matched with the node to be detected is used to perform specification detection on the code text of the node to be detected, so as to obtain a detection result, and the detection result is called back to the Xcode for processing.
And continuing the previous example, triggering YXMatchHandler to check the node data, performing data matching according to the standard of the code specification, and calling back the result of data analysis to Xcode for processing.
In step 206, the Xcode generates a log file for the detection result of the plug-in, and records the log file.
In step 207, the Xcode summarizes the detection results of all code texts.
In step 208, the plug-in obtains a log file, obtains a code to be corrected from the log file, and sends the code to be corrected and a correction scheme of the code to be corrected to a client corresponding to a node to which the code to be corrected belongs.
And the plug-in feeds back the file code to be corrected and the corrected scheme to the client of the corresponding developer for timely repair by processing and analyzing the log file summarized by the Xcode.
In subsequent iteration, code detection is realized through the integrated plug-in, the problem of scattering and matching of different documents or documents maintained by different projects is solved by maintaining the same plug-in, meanwhile, the consistency, readability and maintainability of the code are improved, and the maintenance cost is reduced comprehensively.
It should be noted that the above application scenarios are merely illustrated for the convenience of understanding the spirit and principles of the present disclosure, and the embodiments of the present disclosure are not limited in this respect. Rather, embodiments of the present disclosure may be applied to any scenario where applicable.
Fig. 3 is a block diagram of an exemplary code detection apparatus, and as shown in fig. 3, the present disclosure provides a code detection apparatus applied to a plug-in based on a compiler implementation, including:
an obtaining unit 301, configured to obtain an abstract syntax tree of a code text when the code text is received from a software development platform;
a determining unit 302, configured to determine a node to be detected from nodes in the abstract syntax tree;
the detecting unit 303 is configured to perform standard detection on the code text of the node to be detected by using the code standard matched with the node to be detected, so as to obtain a detection result.
In some embodiments, the determining unit 302 is specifically configured to filter nodes in the abstract syntax tree, obtain nodes meeting the specification check requirement, and determine the nodes as the nodes to be detected.
In some embodiments, the node to be detected is provided with a detection condition for triggering detection; the detecting unit 303 is specifically configured to:
and in response to the detection condition for triggering the node to be detected, carrying out standard detection on the code text corresponding to the node to be detected by using the code standard matched with the node to be detected to obtain a detection result.
In some embodiments, the detecting unit 303 is specifically configured to: and if the code text corresponding to the node to be detected does not meet the requirement of the code specification, generating prompt information, and obtaining a detection result according to the prompt information and the code text corresponding to the node to be detected.
In some embodiments, the detecting unit 303 is further configured to obtain a modification scheme of the code text corresponding to the node to be detected.
In some embodiments, the apparatus further includes a notification unit, configured to send the detection result to the software development platform, so that the software development platform generates a log file based on the received detection result of all or part of the nodes to be detected;
acquiring the log file, and acquiring a code to be corrected from the log file, wherein the code to be corrected comprises a code text corresponding to the node to be detected;
and sending the code to be corrected and the correction scheme of the code to be corrected to a client corresponding to the node to which the code to be corrected belongs.
In some embodiments, the apparatus further comprises a compiling unit to: and compiling the code file under the condition that the detection result indicates that the code texts of all the nodes to be detected conform to the corresponding code specifications.
In some embodiments, the plug-in is implemented based on a Clang compiler and the software development platform includes Xcode.
It should be noted that although in the above detailed description several units/modules or sub-units/modules of the apparatus are mentioned, such a division is merely exemplary and not mandatory. Indeed, the features and functionality of two or more of the units/modules described above may be embodied in one unit/module, in accordance with embodiments of the present disclosure. Conversely, the features and functions of one unit/module described above may be further divided into embodiments by a plurality of units/modules.
Fig. 4 is a schematic diagram of a computer-readable storage medium 400 provided by the present disclosure, the medium 400 having stored thereon a computer program that, when executed by a processor, implements the method of any of the embodiments of the present disclosure.
The present disclosure also provides a computing device comprising a memory, a processor; the memory is for storing computer instructions executable on the processor for implementing the method of any embodiment of the present disclosure when the computer instructions are executed.
Fig. 5 is a schematic structural diagram of a computing device provided by the present disclosure, where the computing device 500 may include, but is not limited to: a processor 501, a memory 502, and a bus 503 that connects the various system components (including the memory 502 and the processor 501).
Wherein the memory 502 stores computer instructions executable by the processor 501 to enable the processor 501 to perform the methods of any of the embodiments of the present disclosure. The memory 502 may include a random access memory unit RAM5021, a cache memory unit 5022, and/or a read-only memory unit ROM5023. The memory 502 may also include: a program tool 5025 having a set of program modules 5024, the program modules 5024 including but not limited to: an operating system, one or more application programs, other program modules, and program data, one or more combinations of which may comprise an implementation of a network environment.
The bus 503 may include, for example, a data bus, an address bus, a control bus, and the like. The computing device 500 may also communicate with external devices 505, such as a keyboard, a bluetooth device, etc., through the I/O interface 504. The computing device 500 may also communicate with one or more networks through a network adapter 506, such as a local area network, a wide area network, a public network, and so forth. The network adapter 506 may also communicate with other modules of the computing device 500 via the bus 503.
Further, while the operations of the disclosed methods are depicted in the drawings in a particular order, this does not require or imply that these operations must be performed in this particular order, or that all of the illustrated operations must be performed, to achieve desirable results. Additionally or alternatively, certain steps may be omitted, multiple steps combined into one step execution, and/or one step broken down into multiple step executions.
While the spirit and principles of the present disclosure have been described with reference to several particular embodiments, it is to be understood that the present disclosure is not limited to the particular embodiments disclosed, nor is the division of aspects, which is for convenience only as the features in such aspects may not be combined to benefit. The disclosure is intended to cover various modifications and equivalent arrangements included within the spirit and scope of the appended claims.

Claims (10)

1. A code detection method is applied to plug-in based on compiler realization and comprises the following steps:
in response to receiving a code text from a software development platform, acquiring an abstract syntax tree of the code text;
determining nodes to be detected from the nodes in the abstract syntax tree;
and carrying out standard detection on the code text of the node to be detected by using the code standard matched with the node to be detected to obtain a detection result.
2. The method according to claim 1, wherein determining nodes to be detected from the nodes in the abstract syntax tree comprises:
and filtering the nodes in the abstract syntax tree, acquiring the nodes meeting the standard inspection requirement, and determining the nodes to be detected.
3. The method according to claim 2, characterized in that the nodes to be detected are provided with detection conditions that trigger detection;
the code specification matched with the node to be detected is used for carrying out specification detection on the code text corresponding to the node to be detected to obtain a detection result, and the method comprises the following steps:
and in response to the detection condition for triggering the node to be detected, carrying out standard detection on the code text corresponding to the node to be detected by using the code standard matched with the node to be detected to obtain a detection result.
4. The method according to any one of claims 1 to 3, wherein the performing specification detection on the code text corresponding to the node to be detected by using the code specification matched with the node to be detected to obtain a detection result comprises:
and if the code text corresponding to the node to be detected does not meet the requirement of the code specification, generating prompt information, and obtaining a detection result according to the prompt information and the code text corresponding to the node to be detected.
5. The method of claim 4, further comprising:
and acquiring a correction scheme of the code text corresponding to the node to be detected.
6. The method of claim 5, further comprising:
sending a detection result to the software development platform so that the software development platform generates a log file based on the received detection results of all or part of the nodes to be detected;
acquiring the log file, and acquiring a code to be corrected from the log file, wherein the code to be corrected comprises a code text corresponding to the node to be detected;
and sending the code to be corrected and the correction scheme of the code to be corrected to a client corresponding to the node to which the code to be corrected belongs.
7. The method of claim 1, further comprising:
and compiling the code file under the condition that the detection result indicates that the code texts of all the nodes to be detected conform to the corresponding code specifications.
8. A code detection device applied to a plug-in based on compiler implementation comprises:
the software development platform comprises an acquisition unit, a judgment unit and a processing unit, wherein the acquisition unit is used for acquiring an abstract syntax tree of a code text under the condition of receiving the code text from the software development platform;
the determining unit is used for determining the nodes to be detected from the nodes in the abstract syntax tree;
and the detection unit is used for carrying out standard detection on the code text of the node to be detected by using the code standard matched with the node to be detected to obtain a detection result.
9. A computer readable storage medium having computer program instructions stored thereon, which when executed by a processor implement the method of any of claims 1 to 7.
10. A computing device, comprising: a memory, a processor;
the memory for storing computer instructions executable on the processor for implementing the method of any one of claims 1 to 7 when the computer instructions are executed.
CN202211585574.0A 2022-12-09 2022-12-09 Code detection method, medium, device and computing equipment Pending CN115827467A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211585574.0A CN115827467A (en) 2022-12-09 2022-12-09 Code detection method, medium, device and computing equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211585574.0A CN115827467A (en) 2022-12-09 2022-12-09 Code detection method, medium, device and computing equipment

Publications (1)

Publication Number Publication Date
CN115827467A true CN115827467A (en) 2023-03-21

Family

ID=85546329

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211585574.0A Pending CN115827467A (en) 2022-12-09 2022-12-09 Code detection method, medium, device and computing equipment

Country Status (1)

Country Link
CN (1) CN115827467A (en)

Similar Documents

Publication Publication Date Title
RU2668973C2 (en) Debugging native code by transitioning from execution in native mode to execution in interpreted mode
US7900198B2 (en) Method and system for parameter profile compiling
CA2704980C (en) Contract programming for code error reduction
US10990503B2 (en) Automated software code review
US8677316B2 (en) Enforcement of architectural design during software development
US8091066B2 (en) Automated multi-platform build and test environment for software application development
US8302087B2 (en) Quality assurance in software systems through autonomic reliability, availability and serviceability code generation
US20090313604A1 (en) Parsing of declarations in all branches of preprocessor conditionals
CN106325970A (en) Compiling method and compiling system
US20080120595A1 (en) System and method for hot code replace
US20110126179A1 (en) Method and System for Dynamic Patching Software Using Source Code
CN103577324A (en) Static detection method for privacy information disclosure in mobile applications
CN111382048B (en) Management method and device for mobile equipment on true machine test platform
US10809985B2 (en) Instrumenting program code
JP2010067188A (en) Information processor for supporting programming, information processing system, and programming support method and program
JP2015011372A (en) Debug support system, method, program, and recording medium
CN114021142A (en) Android application program vulnerability detection method
US20060041873A1 (en) Computer system and method for verifying functional equivalence
US20080127118A1 (en) Method and system for dynamic patching of software
US10642714B2 (en) Mapping dynamic analysis data to source code
CN113238739A (en) Plug-in development and data acquisition method, device, electronic equipment and medium
US8359579B2 (en) Monitoring dynamic aspect oriented applications at execution time
CN110472411B (en) Memory overflow processing method, device, equipment and readable storage medium
US9710360B2 (en) Optimizing error parsing in an integrated development environment
CN115827467A (en) Code detection method, medium, device and computing equipment

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