CN116841883A - Method, device, electronic equipment and storage medium for code annotation detection - Google Patents

Method, device, electronic equipment and storage medium for code annotation detection Download PDF

Info

Publication number
CN116841883A
CN116841883A CN202310799621.XA CN202310799621A CN116841883A CN 116841883 A CN116841883 A CN 116841883A CN 202310799621 A CN202310799621 A CN 202310799621A CN 116841883 A CN116841883 A CN 116841883A
Authority
CN
China
Prior art keywords
annotation
code
plug
target code
detection
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
CN202310799621.XA
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.)
Ping An Bank Co Ltd
Original Assignee
Ping An Bank 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 Ping An Bank Co Ltd filed Critical Ping An Bank Co Ltd
Priority to CN202310799621.XA priority Critical patent/CN116841883A/en
Publication of CN116841883A publication Critical patent/CN116841883A/en
Pending legal-status Critical Current

Links

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/3604Software analysis for verifying properties of programs
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44521Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading
    • G06F9/44526Plug-ins; Add-ons

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Stored Programmes (AREA)

Abstract

The application provides a method, a device, electronic equipment and a storage medium for code annotation detection, wherein the method comprises the following steps: acquiring an object code of an analysis item to be compiled; modifying the target code in response to plug-in operation, and inserting an annotation detection compiling plug-in into the modified target code; responding to code compiling operation, and detecting the annotation of the modified target code by using the annotation detection compiling plug-in the compiling process of the modified target code to obtain a detection result of whether the annotation is added to the target code; if the target code is not added with the annotation, generating prompt information to remind a user to add the corresponding annotation to the target code. According to the application, in a full-automatic mode, the labor cost is greatly reduced, and the project development efficiency is improved while the code quality is improved.

Description

Method, device, electronic equipment and storage medium for code annotation detection
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method, an apparatus, an electronic device, and a storage medium for code annotation detection.
Background
In the process of developing software, in order to facilitate the maintenance and understanding of codes and the tracking and checking of subsequent problems, collaborative development is generally required to write notes corresponding to self-created methods in the process of developing team codes. However, in the actual project development process, due to coding habits of developers, emergency project development progress and other reasons, many methods in project codes do not add corresponding notes, so that maintenance of subsequent projects is more challenging. In particular, the financial software has high quality requirement and low fault tolerance, and if the annotation is added in the financial software, a great deal of time is consumed when the financial software is maintained. For financial software, time-based implementation would be a significant economic penalty, so detection of annotations by financial software would be necessary.
In the conventional construction mode, no annotation is added to the method and normal compiling of the item is not caused, so that omission is difficult to find, and the problem that the method is always not annotated by the checking code only in a manual code review mode is usually solved, but the following problems exist in the mode:
1. a lot of manpower time is required, and in case of emergency, development progress of the project is delayed.
2. The manual code review mode is easy to cause missing of problems, and some methods without adding notes are not checked out, so that subsequent project maintenance is challenged.
Disclosure of Invention
Accordingly, the present application is directed to a method, an apparatus, an electronic device, and a storage medium for detecting code annotation, which greatly reduce labor cost, and improve code quality and project development efficiency.
In a first aspect, an embodiment of the present application provides a method for code annotation detection, the method including:
acquiring an object code of an analysis item to be compiled;
modifying the target code in response to plug-in operation, and inserting an annotation detection compiling plug-in into the modified target code;
responding to code compiling operation, and detecting the annotation of the modified target code by using the annotation detection compiling plug-in the compiling process of the modified target code to obtain a detection result of whether the annotation is added to the target code;
if the target code is not added with the annotation, generating prompt information to remind a user to add the corresponding annotation to the target code.
In some embodiments of the present application, the detecting, by using the annotation detection compiling plug-in, the annotation of the modified object code to obtain a detection result of whether the object code has an annotation added, includes:
acquiring a target file list in the target code;
carrying out abstract syntax tree analysis on abstract syntax trees corresponding to all files in the target file list to obtain analysis results of all the files;
and determining whether the annotation is added to each method according to the description attribute value of the method statement node in the analysis result of each file, and further determining whether the annotation is added to the target code.
In some embodiments of the present application, the method determines whether each method adds an annotation by:
if the method declares that the description attribute value of the node is null, the method adds no annotation;
if the method declares that the descriptive attribute value of the node is not null, the method adds an annotation.
In some aspects of the application, the method determines whether the target code has added an annotation by:
if all the files in the target file list are added with annotations, the target code is added with annotations;
and if any file in the target file list is not annotated, the target code is not annotated.
In some embodiments of the present application, the method obtains the target file list by:
and acquiring the address of the folder in which the target code is located, detecting files under the address, and combining files containing a preset ending mark together to obtain the target file list.
In some embodiments of the present application, the method further includes:
in response to the add completion operation, the post-added annotated object code is again detected.
In some embodiments of the present application, the above method constructs the plug-in by:
selecting a target project template in the development tool in response to the project template selection operation;
responding to plug-in engineering creation operation, and creating annotation detection compiling plug-in engineering according to the target item template; the project object model in the annotation detection compiling plug-in project can be automatically introduced into a plug-in interface dependency library;
responding to project object model modification operation, adding dependency configuration in the project object model in the annotation detection compiling plug-in project, and adding a software development kit in the dependency configuration;
responding to an inheritance class creation operation, creating a corresponding inheritance class in the annotation detection compiling plug-in engineering, and realizing an execution method in the inheritance class;
and compiling the annotation detection compiling plug-in engineering to obtain the annotation detection compiling plug-in the target format.
In a second aspect, an embodiment of the present application provides an apparatus for code annotation detection, the apparatus including:
the acquisition module is used for acquiring the target code of the analysis item to be compiled;
the first response module is used for responding to the plug-in introduction operation, modifying the target code and inserting an annotation detection compiling plug-in into the modified target code;
the second response module is used for responding to code compiling operation, and detecting the annotation of the modified target code by using the annotation detection compiling plug-in the compiling process of the modified target code to obtain a detection result of whether the annotation is added to the target code;
and the prompt module is used for generating prompt information to remind a user to add the corresponding annotation to the target code if the annotation is not added to the target code.
In a third aspect, an embodiment of the present application provides an electronic device, including a memory, a processor, and a computer program stored in the memory and capable of running on the processor, where the processor implements the steps of the method for code annotation detection described above when the processor executes the computer program.
In a fourth aspect, embodiments of the present application provide a computer readable storage medium having stored thereon a computer program which, when executed by a processor, performs the steps of the method of code annotation detection described above.
The technical scheme provided by the embodiment of the application can comprise the following beneficial effects:
the method comprises the steps of obtaining target codes of analysis items to be compiled; modifying the target code in response to plug-in operation, and inserting an annotation detection compiling plug-in into the modified target code; responding to code compiling operation, and detecting the annotation of the modified target code by using the annotation detection compiling plug-in the compiling process of the modified target code to obtain a detection result of whether the annotation is added to the target code; if the target code is not added with the annotation, generating prompt information to remind a user to add the corresponding annotation to the target code. According to the application, in a full-automatic mode, the labor cost is greatly reduced, and the project development efficiency is improved while the code quality is improved.
In order to make the above objects, features and advantages of the present application more comprehensible, preferred embodiments accompanied with figures are described in detail below.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are needed in the embodiments will be briefly described below, it being understood that the following drawings only illustrate some embodiments of the present application and therefore should not be considered as limiting the scope, and other related drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flow chart of a method for code annotation detection according to an embodiment of the present application;
FIG. 2 shows a schematic diagram of one embodiment of the present application;
FIG. 3 is a schematic diagram of an apparatus for code annotation detection according to an embodiment of the present application;
fig. 4 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present application more apparent, the technical solutions of the embodiments of the present application will be clearly and completely described with reference to the accompanying drawings in the embodiments of the present application, and it should be understood that the drawings in the present application are for the purpose of illustration and description only and are not intended to limit the scope of the present application. In addition, it should be understood that the schematic drawings are not drawn to scale. A flowchart, as used in this disclosure, illustrates operations implemented according to some embodiments of the present application. It should be understood that the operations of the flow diagrams may be implemented out of order and that steps without logical context may be performed in reverse order or concurrently. Moreover, one or more other operations may be added to or removed from the flow diagrams by those skilled in the art under the direction of the present disclosure.
In addition, the described embodiments are only some, but not all, embodiments of the application. The components of the embodiments of the present application generally described and illustrated in the figures herein may be arranged and designed in a wide variety of different configurations. Thus, the following detailed description of the embodiments of the application, as presented in the figures, is not intended to limit the scope of the application, as claimed, but is merely representative of selected embodiments of the application. All other embodiments, which can be made by a person skilled in the art without making any inventive effort, are intended to be within the scope of the present application.
It should be noted that the term "comprising" will be used in embodiments of the application to indicate the presence of the features stated hereafter, but not to exclude the addition of other features.
In the process of developing software, in order to facilitate the maintenance and understanding of codes and the tracking and checking of subsequent problems, collaborative development is generally required to write notes corresponding to self-created methods in the process of developing team codes. However, in the actual project development process, due to coding habits of developers, emergency project development progress and other reasons, many methods in project codes do not add corresponding notes, so that maintenance of subsequent projects is more challenging. In particular, the financial software has high quality requirement and low fault tolerance, and if the annotation is added in the financial software, a great deal of time is consumed when the financial software is maintained. For financial software, time-based implementation would be a significant economic penalty, so detection of annotations by financial software would be necessary.
In the conventional construction mode, no annotation is added to the method and normal compiling of the item is not caused, so that omission is difficult to find, and the problem that the method is always not annotated by the checking code only in a manual code review mode is usually solved, but the following problems exist in the mode:
1. a lot of manpower time is required, and in case of emergency, development progress of the project is delayed.
2. The manual code review mode is easy to cause missing of problems, and some methods without adding notes are not checked out, so that subsequent project maintenance is challenged.
Based on the above, the embodiment of the application provides a method, a device, an electronic device and a storage medium for code annotation detection, and the description is given below through the embodiment.
FIG. 1 is a flow chart of a method for code annotation detection according to an embodiment of the present application, wherein the method includes steps S101-S104; specific:
s101, acquiring an object code of an analysis item to be compiled;
s102, responding to plug-in introduction operation, modifying the target code, and inserting an annotation detection compiling plug-in into the modified target code;
s103, responding to code compiling operation, and detecting the annotation of the modified target code by using the annotation detection compiling plug-in the compiling process of the modified target code to obtain a detection result of whether the annotation is added to the target code;
and S104, if the target code is not added with the annotation, generating prompt information to remind a user to add the corresponding annotation to the target code.
According to the application, in a full-automatic mode, the labor cost is greatly reduced, and the project development efficiency is improved while the code quality is improved.
Some embodiments of the application are described in detail below. The following embodiments and features of the embodiments may be combined with each other without conflict.
During the code development process, annotations need to be added to the code. Annotations are metadata of the source code. A simple understanding is that the specific flags in the code can be read at compile, class load, run-time and perform the corresponding processing to facilitate other tool supplementing information or deployment. Annotations can be read by other programs (e.g., compilers, etc.), and developers can embed supplemental information in the source code without changing the original code and logic.
In the process of code development, the writing of notes is a very bad working habit, even if the code written by a developer is forgotten, the subsequent reconstruction is troublesome. While codes are one of the most important assets for a company, if no comments are written, they can result in high maintenance costs (especially after personnel replacement). Especially in financial companies such as banks, the timeliness of the financial software is very high, the development efficiency requirement is high, and if the subsequent development period is influenced by the fact that notes are not added in the development process of the financial software, great economic loss can be caused. To avoid this, annotations in the code need to be detected during or after the development of the software.
Most of detection modes for notes in the prior art are manual detection, and research and development personnel are required to check the notes by themselves or each other, so that a large amount of manpower is consumed, development progress can be influenced, and problems are easy to miss due to the fact that uncertainty factors are checked manually.
Aiming at the problems in the prior art, the embodiment of the application provides a method for detecting the code annotation, which introduces an annotation detection compiling plug-in into the original code on the basis of not changing the original code logic, and detects whether the annotation is added to the code by using the annotation detection compiling plug-in the process of compiling the code. Greatly reduces the labor capacity of developers and omits problems on the surface.
Specifically, the embodiment of the application acquires the target code of the analysis item to be compiled. The analysis item to be compiled can be a client of a certain bank, and in order to time-effect the operation of the bank client in subsequent structure reorganization, etc., whether the source code of the bank client is added with notes or not needs to be detected. The method and the device for detecting the source code of the program design language are mainly used for generating target codes, namely codes which can be identified by a computer, and describing software, namely writing the software, namely the target codes.
After the target code of the analysis item to be compiled is obtained, the embodiment of the application adopts a mode of introducing a plug-in into the target code to detect whether the annotation is added to the target code. The plug-in introduced in the embodiment of the application is an annotation detection compiling plug-in.
The annotation detection compilation plug-in is obtained by:
selecting a target project template in the development tool in response to the project template selection operation;
responding to plug-in engineering creation operation, and creating annotation detection compiling plug-in engineering according to the target item template; the project object model in the annotation detection compiling plug-in project can be automatically introduced into a plug-in interface dependency library;
responding to project object model modification operation, adding dependency configuration in the project object model in the annotation detection compiling plug-in project, and adding a software development kit in the dependency configuration;
responding to an inheritance class creation operation, creating a corresponding inheritance class in the annotation detection compiling plug-in engineering, and realizing an execution method in the inheritance class;
and compiling the annotation detection compiling plug-in engineering to obtain the annotation detection compiling plug-in the target format.
In specific implementation, a developer needs to select a project template, the selected project template can be selected in a Java development tool, and the selected template can be org.apache.maven.archetypes: maven-archetype-movo, namely org.apache.maven.archetypes: maven-archetype-movo is used as a project template new method annotation examination compiling plug-in method-completions-check-maven-plug in.
After the template is selected, creating annotation detection compilation plug-in engineering according to the target item template. In the plug-in engineering after creation, a project object model (pon. Xml file) can be automatically introduced into a maven-plug in-api dependency library, the pon. Xml file in the engineering is modified, the dependencydependency configuration is increased, and the java server. Sdk (mainly performing abstract syntax tree analysis on the java file) is added into the dependencyconfiguration.
In the plug-in engineering after the creation is successful, a completscheck class inheriting the abstract mojo class is created, and the execution method is implemented in the completscheck class (here, the specification requirement of the Maven plug-in, the Maven plug-in has to inherit the abstract execution method of the abstract mojo).
The method annotation code checking logic is implemented in the execution method, and the implementation mode is as follows:
and obtaining the file price address of the source code of the current item to be compiled by using a getProjectDirctory method of a maven-plug-api.
And obtaining all the java files under the project folder, and adding the java files to a java file list.
Traversing and analyzing a java file list, and analyzing an abstract syntax tree of the java file by a java server method in java server.
And acquiring all the method declusion nodes from the parsed abstract syntax tree, and traversing and analyzing each method declusion node.
The description attribute of the method Declarization node is acquired, if the acquired attribute value is null, the method is indicated to have no added annotation, and the execution fails.
If the obtained description attribute value is not null, the method is indicated to have annotation. The next methoddeschartion node is analyzed continuously.
When all the method description nodes in all the java files are traversed, the obtained description attribute values are not null, and the fact that the project code methods are added with notes accords with code specifications is indicated, and the execution is successful.
The plug-in item is compiled by mvn clean package into a method-components-check-maven-plug in. Jar package.
After the annotation detection compilation plug-in is built, the annotation detection compilation plug-in is inserted into the object code. When a developer compiles the target code, the annotation detection compiling plug-in can detect the target code and determine whether an annotation detection result is added in the target code.
The process of detecting the target code by the annotation detection compiling plug-in according to the execution process of the execution method comprises the following steps: acquiring a target file list in the target code;
carrying out abstract syntax tree analysis on abstract syntax trees corresponding to all files in the target file list to obtain analysis results of all the files;
and determining whether the annotation is added to each method according to the description attribute value of the method statement node in the analysis result of each file, and further determining whether the annotation is added to the target code.
The method determines whether each method adds an annotation by:
if the method declares that the description attribute value of the node is null, the method adds no annotation;
if the method declares that the descriptive attribute value of the node is not null, the method adds an annotation.
The method determines whether the object code has added an annotation by:
if all the files in the target file list are added with annotations, the target code is added with annotations;
and if any file in the target file list is not annotated, the target code is not annotated.
The method obtains the target file list by the following steps:
and acquiring the address of the folder in which the target code is located, detecting files under the address, and combining files containing a preset ending mark together to obtain the target file list.
In the specific implementation, a method-components-check-maven-plug in compiling plug-in is introduced by adding plug in the building node of the modified pore in the java item needing code checking. The method for carrying out the source code and whether annotating is added or not while compiling the item to be checked is continuously checked through mvn clean package.
After the target code is detected, if no annotation is added in the target code, the embodiment of the application also generates prompt information to remind a user to timely add the annotation to the target code.
In an alternative implementation manner, when each method in the object code detection is detected, if no annotation is added to the method, the embodiment of the application also records the specific position of the method. When the prompt information is generated, the prompt information contains the specific position of the method, so that an developer can quickly find the position without adding the annotation.
In an alternative embodiment, the developer, after receiving the hint information, adds an annotation to the object code according to the hint information. And specifically, directly positioning the position of the method according to the position of the method without adding the annotation contained in the prompt information. In a specific implementation, a positioning plug-in may be provided, and the annotation detection compilation plug-in sends the detection result to the positioning plug-in. And the positioning plug-in responds to the positioning operation and sequentially performs positioning display according to the positions of each non-added annotation method. After the presentation, the developer adds annotations to it.
In an optional implementation manner, after the developer completes annotation addition, the embodiment of the present application detects the target code after the developer adds the annotation again, and the re-detection process is the same as the first detection process, which is not described herein again.
In an alternative implementation, the embodiment of the present application may operate in the manner shown in fig. 2 when implemented: analyzing the project source code to be compiled, adding a compiling plug-in to the pore file, compiling the project source code, and executing whether annotation checking is added in the code executing method. Wherein the compilation plug-in is obtained by: based on → maven-archetype-mojo to create java compilation plug-in item → dynamic introduction of maven-plug-in-api → modification of configuration introduction of java template. The implementation logic of the execution method is as follows: obtaining a java file list of an item to be compiled, constructing an abstract syntax tree, analyzing a method description node, and enabling an annotation not to be added to an empty method by an operation attribute.
According to the method, after the compiling plug-in configuration is added in project codes, the problem that notes are not added in the method in the project compiling process is solved, and the codes with the problem are compiled and intercepted, so that code submission and code merging which are not in accordance with specifications are prevented, and the method has the following advantages:
1. the automatic interception and mail notification at the compiling stage can accurately block the compiling and online of the problem codes.
2. The full-automatic mode greatly reduces labor cost, improves code quality and improves project development efficiency.
Fig. 3 is a schematic structural diagram of an apparatus for code annotation detection according to an embodiment of the present application, where the apparatus includes:
the acquisition module is used for acquiring the target code of the analysis item to be compiled;
the first response module is used for responding to the plug-in introduction operation, modifying the target code and inserting an annotation detection compiling plug-in into the modified target code;
the second response module is used for responding to code compiling operation, and detecting the annotation of the modified target code by using the annotation detection compiling plug-in the compiling process of the modified target code to obtain a detection result of whether the annotation is added to the target code;
and the prompt module is used for generating prompt information to remind a user to add the corresponding annotation to the target code if the annotation is not added to the target code.
The annotation detection compiling plug-in is used for detecting the modified annotation of the target code to obtain a detection result of whether the target code is added with the annotation, and the method comprises the following steps:
acquiring a target file list in the target code;
carrying out abstract syntax tree analysis on abstract syntax trees corresponding to all files in the target file list to obtain analysis results of all the files;
and determining whether the annotation is added to each method according to the description attribute value of the method statement node in the analysis result of each file, and further determining whether the annotation is added to the target code.
Determining whether each method adds an annotation by:
if the method declares that the description attribute value of the node is null, the method adds no annotation;
if the method declares that the descriptive attribute value of the node is not null, the method adds an annotation.
Determining whether the target code has added an annotation by:
if all the files in the target file list are added with annotations, the target code is added with annotations;
and if any file in the target file list is not annotated, the target code is not annotated.
The list of target files is obtained by:
and acquiring the address of the folder in which the target code is located, detecting files under the address, and combining files containing a preset ending mark together to obtain the target file list.
The apparatus further includes a third response module for detecting again the post-addition annotated object code in response to the addition completion operation.
The plug-in is constructed by:
selecting a target project template in the development tool in response to the project template selection operation;
responding to plug-in engineering creation operation, and creating annotation detection compiling plug-in engineering according to the target item template; the project object model in the annotation detection compiling plug-in project can be automatically introduced into a plug-in interface dependency library;
responding to project object model modification operation, adding dependency configuration in the project object model in the annotation detection compiling plug-in project, and adding a software development kit in the dependency configuration;
responding to an inheritance class creation operation, creating a corresponding inheritance class in the annotation detection compiling plug-in engineering, and realizing an execution method in the inheritance class;
and compiling the annotation detection compiling plug-in engineering to obtain the annotation detection compiling plug-in the target format.
As shown in fig. 4, an embodiment of the present application provides an electronic device for performing the method for detecting code annotation in the present application, where the device includes a memory, a processor, a bus, and a computer program stored in the memory and capable of running on the processor, where the processor implements the steps of the method for detecting code annotation when executing the computer program.
In particular, the above-mentioned memory and processor may be general-purpose memory and processor, and are not limited herein, and the above-mentioned method for code annotation detection can be performed when the processor runs a computer program stored in the memory.
Corresponding to the method of code annotation detection in the present application, an embodiment of the present application further provides a computer readable storage medium having stored thereon a computer program which, when executed by a processor, performs the steps of the method of code annotation detection described above.
In particular, the storage medium can be a general-purpose storage medium, such as a removable disk, a hard disk, etc., on which a computer program is executed, capable of performing the above-described method of code annotation detection.
In the embodiments provided in the present application, it should be understood that the disclosed system and method may be implemented in other manners. The system embodiments described above are merely illustrative, e.g., the division of the elements is merely a logical functional division, and there may be additional divisions in actual implementation, and e.g., multiple elements or components may be combined or integrated into another system, or some features may be omitted, or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be through some communication interface, system or unit indirect coupling or communication connection, which may be in electrical, mechanical or other form.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed over a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in the embodiments provided in the present application may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application may be embodied essentially or in a part contributing to the prior art or in a part of the technical solution, in the form of a software product stored in a storage medium, comprising several instructions for causing a computer device (which may be a personal computer, a server, a network device, etc.) to perform all or part of the steps of the method according to the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
It should be noted that: like reference numerals and letters in the following figures denote like items, and thus once an item is defined in one figure, no further definition or explanation of it is required in the following figures, and furthermore, the terms "first," "second," "third," etc. are used merely to distinguish one description from another and are not to be construed as indicating or implying relative importance.
Finally, it should be noted that: the above examples are only specific embodiments of the present application, and are not intended to limit the scope of the present application, but it should be understood by those skilled in the art that the present application is not limited thereto, and that the present application is described in detail with reference to the foregoing examples: any person skilled in the art may modify or easily conceive of the technical solution described in the foregoing embodiments, or perform equivalent substitution of some of the technical features, while remaining within the technical scope of the present disclosure; such modifications, changes or substitutions do not depart from the spirit and scope of the corresponding technical solutions. Are intended to be encompassed within the scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (10)

1. A method of code annotation detection, the method comprising:
acquiring an object code of an analysis item to be compiled;
modifying the target code in response to plug-in operation, and inserting an annotation detection compiling plug-in into the modified target code;
responding to code compiling operation, and detecting the annotation of the modified target code by using the annotation detection compiling plug-in the compiling process of the modified target code to obtain a detection result of whether the annotation is added to the target code;
if the target code is not added with the annotation, generating prompt information to remind a user to add the corresponding annotation to the target code.
2. The method according to claim 1, wherein the detecting, using the annotation detection compilation plug-in, the annotation of the object code after modification to obtain a detection result of whether the object code has added an annotation, comprises:
acquiring a target file list in the target code;
carrying out abstract syntax tree analysis on abstract syntax trees corresponding to all files in the target file list to obtain analysis results of all the files;
and determining whether the annotation is added to each method according to the description attribute value of the method statement node in the analysis result of each file, and further determining whether the annotation is added to the target code.
3. The method of claim 2, wherein the method determines whether each method adds an annotation by:
if the method declares that the description attribute value of the node is null, the method adds no annotation;
if the method declares that the descriptive attribute value of the node is not null, the method adds an annotation.
4. The method of claim 2, wherein the method determines whether the target code has added an annotation by:
if all the files in the target file list are added with annotations, the target code is added with annotations;
and if any file in the target file list is not annotated, the target code is not annotated.
5. The method of claim 2, wherein the method obtains the list of target files by:
and acquiring the address of the folder in which the target code is located, detecting files under the address, and combining files containing a preset ending mark together to obtain the target file list.
6. The method according to claim 1, wherein the method further comprises:
in response to the add completion operation, the post-added annotated object code is again detected.
7. The method of claim 1, wherein the method constructs the plug-in by:
selecting a target project template in the development tool in response to the project template selection operation;
responding to plug-in engineering creation operation, and creating annotation detection compiling plug-in engineering according to the target item template; the project object model in the annotation detection compiling plug-in project can be automatically introduced into a plug-in interface dependency library;
responding to project object model modification operation, adding dependency configuration in the project object model in the annotation detection compiling plug-in project, and adding a software development kit in the dependency configuration;
responding to an inheritance class creation operation, creating a corresponding inheritance class in the annotation detection compiling plug-in engineering, and realizing an execution method in the inheritance class;
and compiling the annotation detection compiling plug-in engineering to obtain the annotation detection compiling plug-in the target format.
8. An apparatus for code annotation detection, the apparatus comprising:
the acquisition module is used for acquiring the target code of the analysis item to be compiled;
the first response module is used for responding to the plug-in introduction operation, modifying the target code and inserting an annotation detection compiling plug-in into the modified target code;
the second response module is used for responding to code compiling operation, and detecting the annotation of the modified target code by using the annotation detection compiling plug-in the compiling process of the modified target code to obtain a detection result of whether the annotation is added to the target code;
and the prompt module is used for generating prompt information to remind a user to add the corresponding annotation to the target code if the annotation is not added to the target code.
9. An electronic device, comprising: a processor, a memory and a bus, said memory storing machine readable instructions executable by said processor, said processor and said memory communicating over the bus when the electronic device is running, said machine readable instructions when executed by said processor performing the steps of the method of code annotation detection according to any of claims 1 to 7.
10. A computer readable storage medium, characterized in that the computer readable storage medium has stored thereon a computer program which, when executed by a processor, performs the steps of the method of code annotation detection according to any of the claims 1 to 7.
CN202310799621.XA 2023-06-30 2023-06-30 Method, device, electronic equipment and storage medium for code annotation detection Pending CN116841883A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310799621.XA CN116841883A (en) 2023-06-30 2023-06-30 Method, device, electronic equipment and storage medium for code annotation detection

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310799621.XA CN116841883A (en) 2023-06-30 2023-06-30 Method, device, electronic equipment and storage medium for code annotation detection

Publications (1)

Publication Number Publication Date
CN116841883A true CN116841883A (en) 2023-10-03

Family

ID=88172074

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310799621.XA Pending CN116841883A (en) 2023-06-30 2023-06-30 Method, device, electronic equipment and storage medium for code annotation detection

Country Status (1)

Country Link
CN (1) CN116841883A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117591436A (en) * 2024-01-18 2024-02-23 南京研利科技有限公司 Observability data acquisition method and device for Go source codes

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117591436A (en) * 2024-01-18 2024-02-23 南京研利科技有限公司 Observability data acquisition method and device for Go source codes

Similar Documents

Publication Publication Date Title
CN110998516B (en) Automated dependency analyzer for heterogeneous programming data processing systems
CN106919434B (en) Code generation method and device
Linsbauer et al. A classification of variation control systems
US9535664B1 (en) Computerized software development process and management environment
Yu et al. A comprehensive approach to the recovery of design pattern instances based on sub-patterns and method signatures
EP3623948B1 (en) Method and system for code analysis to identify causes of code smells
US20110214108A1 (en) Architecture, system and method for generating visualizations from running executable code
Herrmannsdoerfer et al. Towards a generic operation recorder for model evolution
CN104969144A (en) Recording program execution
US8117610B2 (en) System and method for integrated artifact management
Islam et al. Coherent clusters in source code
US11294665B1 (en) Computerized software version control with a software database and a human database
CN116841883A (en) Method, device, electronic equipment and storage medium for code annotation detection
Ball et al. Beyond open source: the touch develop cloud-based integrated development environment
Bian et al. SPAPE: A semantic-preserving amorphous procedure extraction method for near-miss clones
Linsbauer et al. Systematic software reuse with automated extraction and composition for clone-and-own
Arya et al. Information correspondence between types of documentation for APIs
CN116991751B (en) Code testing method and device, electronic equipment and storage medium
Frick Understanding software changes: Extracting, classifying, and presenting fine-grained source code changes
Carvalho et al. DMOSS: Open source software documentation assessment
CN108845799B (en) Visual program verification method and device and computer readable storage medium
Gómez Supporting integration activities in object-oriented applications
Barmpis et al. Monitoring model analytics over large repositories with Hawk and MEASURE
Ben Charrada et al. An automated hint generation approach for supporting the evolution of requirements specifications
US20170168786A1 (en) Source Code Generation From Prototype Source

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