CN116383053A - Software code defect detection method, device, medium and equipment - Google Patents

Software code defect detection method, device, medium and equipment Download PDF

Info

Publication number
CN116383053A
CN116383053A CN202310323743.1A CN202310323743A CN116383053A CN 116383053 A CN116383053 A CN 116383053A CN 202310323743 A CN202310323743 A CN 202310323743A CN 116383053 A CN116383053 A CN 116383053A
Authority
CN
China
Prior art keywords
code
detected
text
preset
defect 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
CN202310323743.1A
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 CN202310323743.1A priority Critical patent/CN116383053A/en
Publication of CN116383053A publication Critical patent/CN116383053A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/362Software debugging
    • G06F11/3628Software debugging of optimised code
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/362Software debugging
    • G06F11/3644Software debugging by instrumenting at runtime
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The embodiment of the application provides a software code defect detection method, a device, a medium and equipment, wherein the method comprises the following steps: acquiring a code text to be detected, and judging whether the code text to be detected is built according to a preset writing frame or not according to a preset code construction rule; when the code text to be detected meets the code construction rule, determining respective corresponding preset inspection rules according to various code character strings forming the code text to be detected; and performing defect detection operation on various code character strings in the code text to be detected according to the preset detection rules to obtain detection results corresponding to different preset detection rules. By using the software code defect detection method provided by the embodiment of the application, the characters which do not affect the code operation and the integrity in the code to be detected are identified, and then the identified characters are deleted, so that the code is simplified, the code inspection workload can be reduced, and the code operation efficiency can be improved.

Description

Software code defect detection method, device, medium and equipment
Technical Field
The present disclosure relates to the field of electronic communications technologies, and in particular, to a method, an apparatus, a medium, and a device for detecting a software code defect.
Background
The bytecode in the code text follows the ClassFile structure in Java Virtual Machine Specificationd, including class information (access_ flag, interfaces, super _class, etc.), field attributes (field_info), and method information (method_info), etc. The execution of each of the bytecode instructions can consume time and, if not reasonably optimized, can severely impact performance in high concurrency situations. With the development of software systems, the requirements of enterprises on system performance are also increasing. The development team usually checks the defects or potential risks of the code through the code review and the code static scanning tool Sonar, so that the repair cost is reduced, the code quality is improved, meanwhile, the internal knowledge sharing of the team is promoted, and more people are helped to better understand the system. However, the CodeReview and static scanning are not universal, firstly, the CodeReview depends on the Review on the one hand, experienced people can more rapidly and effectively perform the CodeReview, and in addition, the code quantity of the walk-through is too large to achieve detailed walk-through, so that the efficiency is affected. Incomplete walkthrough may have information security problems.
Disclosure of Invention
The embodiment of the application provides a software code defect detection method, a device, a medium and equipment, and by utilizing the software code defect detection method provided by the embodiment of the application, characters which do not affect the code operation and the integrity in a code to be detected are identified, and then the identified characters are deleted, so that the code is simplified, the code inspection workload can be reduced, and the code operation efficiency is improved.
In one aspect, an embodiment of the present application provides a method for detecting a software code defect, where the method for detecting a software code defect includes:
acquiring a code text to be detected, and judging whether the code text to be detected is built according to a preset writing frame or not according to a preset code construction rule;
when the code text to be detected meets the code construction rule, determining respective corresponding preset inspection rules according to various code character strings forming the code text to be detected;
and performing defect detection operation on various code character strings in the code text to be detected according to the preset detection rules to obtain detection results corresponding to different preset detection rules.
In the software code defect detection method of the embodiment of the present application, the determining, according to a preset code construction rule, whether the code text to be detected is constructed according to a set composition frame includes:
and traversing the code text to be detected according to a plurality of preset keywords, judging whether the code text to be detected comprises code character strings corresponding to the plurality of keywords or not, and judging whether the code text to be detected is built according to a set writing frame or not.
In the software code defect detection method of the embodiment of the present application, the determining whether the code text to be detected includes code strings corresponding to the plurality of keywords to determine whether the code text to be detected is built according to a set writing frame includes:
judging whether the code text to be detected comprises code character strings corresponding to the keywords, wherein the occurrence sequence of the code character strings in the code text to be detected corresponds to the preset ordering sequence of the keywords so as to judge whether the code text to be detected is built according to a set writing frame.
In the software code defect detection method according to the embodiment of the present application, the keywords include one or more of a class information keyword, a field attribute keyword and a method information keyword.
In the software code defect detection method according to the embodiment of the present application, the test result includes:
whether the naming standards of the class information accord with preset naming rules or not; or (b)
Whether the reference relation of the byte codes in the field attributes accords with a preset reference rule or not; or (b)
Whether the byte code instruction in the method information accords with the debugging printing rule or not.
In the method for detecting a software code defect according to the embodiment of the present application, after obtaining the test results corresponding to different preset test rules, the method further includes a code defect processing operation:
marking abnormal class information with nonstandard naming in the class information; or (b)
Deleting the abnormal field attribute with the byte code reference relation error in the field attribute; or (b)
And deleting the abnormal method information of which the byte code instruction does not accord with the debugging printing rule in the method information.
In the software code defect detection method according to the embodiment of the present application, the method further includes:
and generating notification information comprising optimized code text after the code defect processing operation.
Correspondingly, another aspect of the embodiments of the present application further provides a device for detecting a software code defect, where the device for detecting a software code defect includes:
the text acquisition module is used for acquiring a code text to be detected, and judging whether the code text to be detected is built according to a preset writing frame or not according to preset code construction rules;
the rule determining module is used for determining respective corresponding preset checking rules according to various code character strings forming the code text to be detected when the code text to be detected meets the code construction rules;
and the result checking module is used for respectively carrying out defect detection operation on various code character strings in the code text to be detected according to the preset checking rules to obtain checking results corresponding to different preset checking rules.
Accordingly, another aspect of the embodiments of the present application provides a storage medium storing a plurality of instructions adapted to be loaded by a processor to perform the software code defect detection method as described above.
Accordingly, another aspect of the embodiments of the present application further provides a terminal device, including a processor and a memory, where the memory stores a plurality of instructions, and the processor loads the instructions to perform the software code defect detection method as described above.
The embodiment of the application provides a method, a device, a medium and equipment for detecting software code defects, wherein the method judges whether a code text to be detected is built according to a set writing frame or not according to a preset code construction rule by acquiring the code text to be detected; when the code text to be detected meets the code construction rule, determining respective corresponding preset inspection rules according to various code character strings forming the code text to be detected; and performing defect detection operation on various code character strings in the code text to be detected according to the preset detection rules to obtain detection results corresponding to different preset detection rules. By using the software code defect detection method provided by the embodiment of the application, the characters which do not affect the code operation and the integrity in the code to be detected are identified, and then the identified characters are deleted, so that the code is simplified, the code inspection workload can be reduced, and the code operation efficiency can be improved.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings that are required to be used in the description of the embodiments will be briefly described below. It is obvious that the drawings in the following description are only some embodiments of the present application, and that other drawings may be obtained from these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a flow chart of a software code defect detection method according to an embodiment of the present application.
Fig. 2 is a schematic structural diagram of a software code defect detection device according to an embodiment of the present application.
Fig. 3 is another schematic structural diagram of a software code defect detecting device according to an embodiment of the present application.
Fig. 4 is a schematic structural diagram of a terminal device according to an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. It will be apparent that the described embodiments are only some, but not all, of the embodiments of the present application. All other embodiments, which can be made by a person skilled in the art without any inventive effort, are intended to be within the scope of the present application based on the embodiments herein.
It should be noted that the following is a simple description of the background of the present solution:
the scheme is mainly developed around the technical problem of how to reduce the workload of code inspection and improve the running efficiency of codes. It will be appreciated that the bytecode in the code text follows the ClassFile structure in Java Virtual Machine Specificationd, including class information (access flag, interfaces, super _class, etc.), field attributes (field info), and method information (method info), etc. The execution of each of the bytecode instructions can consume time and, if not reasonably optimized, can severely impact performance in high concurrency situations. With the development of software systems, the requirements of enterprises on system performance are also increasing. The development team usually checks the defects or potential risks of the code through the code review and the code static scanning tool Sonar, so that the repair cost is reduced, the code quality is improved, meanwhile, the internal knowledge sharing of the team is promoted, and more people are helped to better understand the system. However, the CodeReview and static scanning are not universal, firstly, the CodeReview depends on the Review on the one hand, experienced people can more rapidly and effectively perform the CodeReview, and in addition, the code quantity of the walk-through is too large to achieve detailed walk-through, so that the efficiency is affected. Incomplete walkthrough may have information security problems.
In order to solve the above technical problems, an embodiment of the present application provides a software code defect detection method. By using the software code defect detection method provided by the embodiment of the application, firstly, a byte code optimization rule base System byte code System is established, and byte code (byte code) data optimization is realized by using an ASM class base. By identifying the characters in the code to be detected, which do not affect the code operation and the integrity, and deleting the identified characters, the code is simplified, so that the code checking workload can be reduced and the code operation efficiency can be improved.
Referring to fig. 1, fig. 1 is a flowchart illustrating a software code defect detection method according to an embodiment of the present application. The software code defect detection method is applied to terminal equipment. Optionally, the terminal device is a terminal or a server. Optionally, the server is an independent physical server, or a server cluster or a distributed system formed by a plurality of physical servers, or a cloud server providing cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDNs (Content Delivery Network, content delivery networks), basic cloud computing services such as big data and artificial intelligence platforms, and the like. Optionally, the terminal is a smart phone, a tablet computer, a notebook computer, a desktop computer, a smart speaker, a smart watch, a smart voice interaction device, a smart home appliance, a vehicle-mounted terminal, and the like, but is not limited thereto.
In an embodiment, the method may comprise the steps of:
step 101, acquiring a code text to be detected, and judging whether the code text to be detected is built according to a preset writing frame according to preset code building rules.
The example codes of the code text to be detected are as follows:
public class MethodRulesTest{
public int val;
public void test(int a,int b){
int c=a+b;
this.val=this.val;
int d=c+0;
System.out.println(c);
}
it should be noted that, when the code text corresponds to different user demands, the code text needs to be built by selecting a matched writing frame to be recognized by the code running system and run smoothly, so in this embodiment, whether the code text to be detected is built according to the set writing frame is mainly determined by a preset code construction rule. The method is realized by the following steps:
performing traversal search on the code text to be detected according to a plurality of preset keywords, and judging whether the code text to be detected comprises code character strings corresponding to the plurality of keywords or not, so as to judge whether the code text to be detected is built according to a set writing frame or not.
It should be noted that, in practical application, since the code can normally run, it is necessary to consider whether the code character strings corresponding to a plurality of preset keywords can be matched, and whether the appearance sequence of the code character strings is accurate. Therefore, in some embodiments, when determining whether the code text to be detected includes the code strings corresponding to the plurality of keywords, it is further required to consider that the appearance sequence of the code strings in the code text to be detected corresponds to the preset ordering sequence of the plurality of keywords, so as to determine whether the code text to be detected is built according to the set writing frame.
It should be explained that the keywords mentioned in the present embodiment include one or more of a class information keyword (e.g., access_ flag, interfaces, super _class, etc.), a field attribute keyword (e.g., field_info), and a method information keyword (e.g., method_info).
And 102, determining respective corresponding preset inspection rules according to various code character strings forming the code text to be detected when the code text to be detected meets the code construction rules.
The code strings forming the code text to be detected are preset with corresponding preset check rules, and problems can be found in a targeted and efficient mode according to the corresponding preset check rules called by the code strings of different types.
And 103, performing defect detection operation on various code character strings in the code text to be detected according to the preset detection rules to obtain detection results corresponding to different preset detection rules.
In this embodiment, by identifying code strings that do not match rules, the human impact is reduced, the cost of CodeReview is reduced, and efficiency is improved. Wherein the test result comprises:
whether the naming standards of the class information accord with preset naming rules or not; or (b)
Whether the reference relation of the byte codes in the field attributes accords with a preset reference rule or not; or (b)
Whether the byte code instruction in the method information accords with the debugging printing rule or not.
It should be noted that, the preset naming rule, the preset reference rule and the debug print rule all belong to manually formulated rules according to actual situations, and are not limited herein.
In some embodiments, after obtaining the inspection results corresponding to the different preset inspection rules, the method further includes a code defect handling operation, and is performed based on the ASM class library.
It should be explained that the ASM class library is a class library of Java bytecodes, and the object operated by the ASM is ByteCode (ByteCode) data, which provides services such as a file system, a logical volume manager, and a software RAID (disk array) in a platform-independent manner. ASMs can stripe and mirror disks, enabling the addition or removal of disks and auto-balancing I/O to remove "hot spots" in the event that a database is loaded. It also supports direct and asynchronous I/O and uses the Oracle data manager API (simplified I/O System call interface) introduced in Oracle 9I.
The code defect processing operation specifically includes:
marking abnormal class information with nonstandard naming in the class information; or (b)
Deleting the abnormal field attribute with the byte code reference relation error in the field attribute; or (b)
The method information is deleted by abnormal method information that the byte code instructions in the method information do not accord with the debugging printing rule, each byte code instruction runs with time consumption, and if the reasonable optimization is not carried out, the performance can be seriously influenced under the condition of high concurrency. And the method also comprises the steps of removing instructions which do not carry out actual assignment, adding zeros, directly carrying out calculation and storage on sum constants and the like. Based on the scheme, the defect of static scanning can be overcome, the running of program instructions is reduced, the system performance is improved, and the concurrency resistance is enhanced.
In some embodiments, the method further comprises:
notification information including optimized code text after the code defect processing operation is generated.
Specifically, the optimized code text is notified to related responsible personnel through mail and the like, so that the benign circulation of the program is facilitated. And after the optimization of the byte codes in the code text is completed, deploying the optimized program on line.
In some embodiments, the notification information may further include a location where a defect exists in the text of the code to be detected, so that a technician can conveniently and timely troubleshoot the reason for the above problem.
Any combination of the above optional solutions may be adopted to form an optional embodiment of the present application, which is not described herein in detail.
In particular, the present application is not limited by the order of execution of the steps described, and certain steps may be performed in other orders or concurrently without conflict.
As can be seen from the above, the software code defect detection method provided by the embodiment of the present application determines whether the code text to be detected is built according to a set writing frame according to a preset code construction rule by acquiring the code text to be detected; when the code text to be detected meets the code construction rule, determining respective corresponding preset inspection rules according to various code character strings forming the code text to be detected; and performing defect detection operation on various code character strings in the code text to be detected according to the preset detection rules to obtain detection results corresponding to different preset detection rules. By using the software code defect detection method provided by the embodiment of the application, the characters which do not affect the code operation and the integrity in the code to be detected are identified, and then the identified characters are deleted, so that the code is simplified, the code inspection workload can be reduced, and the code operation efficiency can be improved.
The embodiment of the application also provides a software code defect detection device which can be integrated in the terminal equipment.
Referring to fig. 2, fig. 2 is a schematic structural diagram of a software code defect detection device according to an embodiment of the present application. The software code defect detection means 30 may include:
the text obtaining module 31 is configured to obtain a code text to be detected, and determine whether the code text to be detected is built according to a preset composition frame according to a preset code construction rule;
the rule determining module 32 is configured to determine, when the code text to be detected meets the code construction rule, a preset inspection rule corresponding to each code string that forms the code text to be detected;
and the result checking module 33 is configured to perform defect detection operation on each type of code character string in the code text to be detected according to the preset checking rules, so as to obtain checking results corresponding to different preset checking rules.
In some embodiments, the text obtaining module 32 is configured to perform a traversal search on the code text to be detected according to a preset number of keywords, and determine whether the code text to be detected includes code strings corresponding to the number of keywords, so as to determine whether the code text to be detected is built according to a set composition frame.
In some embodiments, the text obtaining module 32 is configured to determine whether the code text to be detected includes code strings corresponding to the plurality of keywords, and an appearance sequence of the code strings in the code text to be detected corresponds to a preset ordering sequence of the plurality of keywords, so as to determine whether the code text to be detected is built according to a set writing frame.
In some embodiments, the keywords include one or more of class information keywords, field attribute keywords, and method information keywords.
In some embodiments, the test results include: whether the naming standards of the class information accord with preset naming rules or not; or whether the reference relation of the byte codes in the field attributes accords with a preset reference rule; or whether the byte code instruction in the method information accords with the debugging printing rule.
In some embodiments, the apparatus further includes a defect processing module configured to mark abnormal class information with a non-canonical naming in the class information; or deleting the abnormal field attribute with the byte code reference relation error in the field attribute; or deleting the abnormal method information of which the byte code instruction does not accord with the debugging printing rule in the method information.
In some embodiments, the apparatus further comprises a notification module for generating notification information comprising optimized code text after the code defect processing operation.
In specific implementation, each module may be implemented as a separate entity, or may be combined arbitrarily and implemented as the same entity or several entities.
As can be seen from the above, the software code defect detection device 30 provided in the embodiments of the present application, wherein the text obtaining module 31 is configured to obtain a code text to be detected, and determine whether the code text to be detected is built according to a preset code construction rule; the rule determining module 32 is configured to determine, when the code text to be detected meets the code construction rule, a preset inspection rule corresponding to each code string that forms the code text to be detected; the result inspection module 33 is configured to perform defect detection operation on each type of code string in the code text to be detected according to the preset inspection rules, so as to obtain inspection results corresponding to different preset inspection rules.
Referring to fig. 3, fig. 3 is another schematic diagram of a software code defect detecting apparatus according to an embodiment of the present application, where the software code defect detecting apparatus 30 includes a memory 120, one or more processors 180, and one or more application programs, where the one or more application programs are stored in the memory 120 and configured to be executed by the processors 180; the processor 180 may include a text acquisition module 31, a rule determination module 32, and a result verification module 33. For example, the structures and connection relationships of the above respective components may be as follows:
memory 120 may be used to store applications and data. The memory 120 stores application programs including executable code. Applications may constitute various functional modules. The processor 180 executes various functional applications and software code defect detection by running application programs stored in the memory 120. In addition, memory 120 may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid-state storage device. Accordingly, the memory 120 may also include a memory controller to provide access to the memory 120 by the processor 180.
The processor 180 is a control center of the device, connects various parts of the entire terminal using various interfaces and lines, and performs various functions of the device and processes data by running or executing application programs stored in the memory 120 and calling data stored in the memory 120, thereby performing overall monitoring of the device. Optionally, the processor 180 may include one or more processing cores; preferably, the processor 180 may integrate an application processor and a modem processor, wherein the application processor primarily processes an operating system, user interfaces, application programs, and the like.
In particular, in this embodiment, the processor 180 loads executable codes corresponding to the processes of one or more application programs into the memory 120 according to the following instructions, and the processor 180 executes the application programs stored in the memory 120, so as to implement various functions:
a text acquisition instruction, which is used for acquiring a code text to be detected, and judging whether the code text to be detected is built according to a preset writing frame according to a preset code construction rule;
a rule determining instruction, configured to determine, when the code text to be detected meets the code construction rule, a preset inspection rule corresponding to each code string that forms the code text to be detected;
and the result checking instruction is used for respectively carrying out defect detection operation on various code character strings in the code text to be detected according to the preset checking rules to obtain checking results corresponding to different preset checking rules.
In some embodiments, the text obtaining instruction is configured to perform traversal search on the code text to be detected according to a preset number of keywords, and determine whether the code text to be detected includes code strings corresponding to the number of keywords, so as to determine whether the code text to be detected is built according to a set composition frame.
In some embodiments, the text obtaining instruction is configured to determine whether the code text to be detected includes code strings corresponding to the plurality of keywords, and an appearance sequence of the code strings in the code text to be detected corresponds to a preset ordering sequence of the plurality of keywords, so as to determine whether the code text to be detected is built according to a set writing frame.
In some embodiments, the keywords include one or more of class information keywords, field attribute keywords, and method information keywords.
In some embodiments, the test results include: whether the naming standards of the class information accord with preset naming rules or not; or whether the reference relation of the byte codes in the field attributes accords with a preset reference rule; or whether the byte code instruction in the method information accords with the debugging printing rule.
In some embodiments, the program further includes defect handling instructions for marking abnormal class information of the class information that is not denominated; or deleting the abnormal field attribute with the byte code reference relation error in the field attribute; or deleting the abnormal method information of which the byte code instruction does not accord with the debugging printing rule in the method information.
In some embodiments, the program further comprises notification instructions for generating notification information comprising optimized code text after the code defect handling operation.
The embodiment of the application also provides terminal equipment. The terminal equipment can be a server, a smart phone, a computer, a tablet personal computer and the like.
Referring to fig. 4, fig. 4 shows a schematic structural diagram of a terminal device provided in an embodiment of the present application, where the terminal device may be used to implement the software code defect detection method provided in the foregoing embodiment. The terminal device 1200 may be a smart phone or a tablet computer.
As shown in fig. 4, the terminal device 1200 may include an RF (Radio Frequency) circuit 110, a memory 120 including one or more (only one is shown in the figure) computer readable storage mediums, an input unit 130, a display unit 140, a sensor 150, an audio circuit 160, a transmission module 170, a processor 180 including one or more (only one is shown in the figure) processing cores, and a power supply 190. It will be appreciated by those skilled in the art that the configuration of the terminal device 1200 shown in fig. 4 does not constitute a limitation of the terminal device 1200, and may include more or fewer components than shown, or may combine certain components, or may have a different arrangement of components. Wherein:
the RF circuit 110 is configured to receive and transmit electromagnetic waves, and to perform mutual conversion between the electromagnetic waves and the electrical signals, so as to communicate with a communication network or other devices. RF circuitry 110 may include various existing circuit elements for performing these functions, such as an antenna, a radio frequency transceiver, a digital signal processor, an encryption/decryption chip, a Subscriber Identity Module (SIM) card, memory, and the like. The RF circuitry 110 may communicate with various networks such as the internet, intranets, wireless networks, or other devices via wireless networks.
The memory 120 may be used to store software programs and modules, such as program instructions/modules corresponding to the software code defect detection method in the above embodiment, and the processor 180 executes various functional applications and software code defect detection by running the software programs and modules stored in the memory 120, so that the vibration reminding mode can be automatically selected to update data according to the current scene where the terminal device is located, thereby not only ensuring that the scenes such as a conference are not disturbed, but also ensuring that the user can perceive an incoming call, and improving the intelligence of the terminal device. Memory 120 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, memory 120 may further include memory remotely located relative to processor 180, which may be connected to terminal device 1200 via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The input unit 130 may be used to receive input numeric or character information and to generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control. In particular, the input unit 130 may comprise a touch sensitive surface 131 and other input devices 132. The touch sensitive surface 131, also referred to as a touch display screen or touch pad, may collect touch operations thereon or thereabout by a user (e.g., operations of the user on the touch sensitive surface 131 or thereabout by any suitable object or accessory such as a finger, stylus, etc.), and actuate the corresponding connection means according to a pre-set program. Alternatively, the touch sensitive surface 131 may comprise two parts, a touch detection device and a touch controller. The touch control detection device detects the touch control direction of a user, detects signals brought by touch control operation and transmits the signals to the touch control controller; the touch controller receives touch information from the touch detection device, converts the touch information into touch coordinates, sends the touch coordinates to the processor 180, and can receive and execute commands sent by the processor 180. In addition, the touch-sensitive surface 131 may be implemented in various types of resistive, capacitive, infrared, surface acoustic wave, and the like. In addition to the touch-sensitive surface 131, the input unit 130 may also comprise other input devices 132. In particular, other input devices 132 may include, but are not limited to, one or more of a physical keyboard, function keys (e.g., volume control keys, switch keys, etc.), a trackball, mouse, joystick, etc.
The display unit 140 may be used to display information input by a user or information provided to the user and various graphical user interfaces of the terminal device 1200, which may be composed of graphics, text, icons, video, and any combination thereof. The display unit 140 may include a display panel 141, and alternatively, the display panel 141 may be configured in the form of an LCD (Liquid Crystal Display ), an OLED (Organic Light-Emitting Diode), or the like. Further, the touch-sensitive surface 131 may cover the display panel 141, and after the touch-sensitive surface 131 detects a touch operation thereon or thereabout, the touch-sensitive surface is transferred to the processor 180 to determine a type of touch event, and then the processor 180 provides a corresponding visual output on the display panel 141 according to the type of touch event. Although in fig. 4 the touch-sensitive surface 131 and the display panel 141 are implemented as two separate components for input and output functions, in some embodiments the touch-sensitive surface 131 may be integrated with the display panel 141 to implement the input and output functions.
The terminal device 1200 may also include at least one sensor 150, such as a light sensor, a motion sensor, and other sensors. Specifically, the light sensor may include an ambient light sensor that may adjust the brightness of the display panel 141 according to the brightness of ambient light, and a proximity sensor that may turn off the display panel 141 and/or the backlight when the terminal device 1200 moves to the ear. As one of the motion sensors, the gravity acceleration sensor can detect the acceleration in all directions (generally three axes), and can detect the gravity and the direction when the mobile phone is stationary, and can be used for applications of recognizing the gesture of the mobile phone (such as horizontal and vertical screen switching, related games, magnetometer gesture calibration), vibration recognition related functions (such as pedometer and knocking), and the like; other sensors such as gyroscopes, barometers, hygrometers, thermometers, infrared sensors, etc. that may also be configured with the terminal device 1200 are not described in detail herein.
Audio circuitry 160, speaker 161, microphone 162 may provide an audio interface between a user and terminal device 1200. The audio circuit 160 may transmit the received electrical signal converted from audio data to the speaker 161, and the electrical signal is converted into a sound signal by the speaker 161 to be output; on the other hand, the microphone 162 converts the collected sound signal into an electrical signal, receives the electrical signal from the audio circuit 160, converts the electrical signal into audio data, outputs the audio data to the processor 180 for processing, transmits the audio data to, for example, another terminal via the RF circuit 110, or outputs the audio data to the memory 120 for further processing. Audio circuitry 160 may also include an ear bud jack to provide communication of the peripheral headphones with terminal device 1200.
Terminal device 1200 may facilitate user email, web browsing, streaming media access, etc. via a transmission module 170 (e.g., wi-Fi module) that provides wireless broadband internet access to the user. Although fig. 4 shows the transmission module 170, it is understood that it does not belong to the essential constitution of the terminal device 1200, and may be omitted entirely as needed within the scope of not changing the essence of the invention.
The processor 180 is a control center of the terminal device 1200, connects various parts of the entire mobile phone using various interfaces and lines, and performs various functions of the terminal device 1200 and processes data by running or executing software programs and/or modules stored in the memory 120, and calling data stored in the memory 120, thereby performing overall monitoring of the mobile phone. Optionally, the processor 180 may include one or more processing cores; in some embodiments, the processor 180 may integrate an application processor that primarily processes operating systems, user interfaces, applications, etc., with a modem processor that primarily processes wireless communications. It will be appreciated that the modem processor described above may not be integrated into the processor 180.
The terminal device 1200 also includes a power supply 190 that provides power to the various components, and in some embodiments, may be logically coupled to the processor 180 via a power management system to perform functions such as managing discharge, and managing power consumption via the power management system. The power supply 190 may also include one or more of any of a direct current or alternating current power supply, a recharging system, a power failure detection circuit, a power converter or inverter, a power status indicator, and the like.
Although not shown, the terminal device 1200 may further include a camera (such as a front camera, a rear camera), a bluetooth module, etc., which will not be described herein. In particular, in the present embodiment, the display unit 140 of the terminal device 1200 is a touch screen display, the terminal device 1200 further includes a memory 120, and one or more programs, wherein the one or more programs are stored in the memory 120 and configured to be executed by the one or more processors 180, the one or more programs include instructions for:
a text acquisition instruction, which is used for acquiring a code text to be detected, and judging whether the code text to be detected is built according to a preset writing frame according to a preset code construction rule;
a rule determining instruction, configured to determine, when the code text to be detected meets the code construction rule, a preset inspection rule corresponding to each code string that forms the code text to be detected;
and the result checking instruction is used for respectively carrying out defect detection operation on various code character strings in the code text to be detected according to the preset checking rules to obtain checking results corresponding to different preset checking rules.
In some embodiments, the text obtaining instruction is configured to perform traversal search on the code text to be detected according to a preset number of keywords, and determine whether the code text to be detected includes code strings corresponding to the number of keywords, so as to determine whether the code text to be detected is built according to a set composition frame.
In some embodiments, the text obtaining instruction is configured to determine whether the code text to be detected includes code strings corresponding to the plurality of keywords, and an appearance sequence of the code strings in the code text to be detected corresponds to a preset ordering sequence of the plurality of keywords, so as to determine whether the code text to be detected is built according to a set writing frame.
In some embodiments, the keywords include one or more of class information keywords, field attribute keywords, and method information keywords.
In some embodiments, the test results include: whether the naming standards of the class information accord with preset naming rules or not; or whether the reference relation of the byte codes in the field attributes accords with a preset reference rule; or whether the byte code instruction in the method information accords with the debugging printing rule.
In some embodiments, the program further includes defect handling instructions for marking abnormal class information of the class information that is not denominated; or deleting the abnormal field attribute with the byte code reference relation error in the field attribute; or deleting the abnormal method information of which the byte code instruction does not accord with the debugging printing rule in the method information.
In some embodiments, the program further comprises notification instructions for generating notification information comprising optimized code text after the code defect handling operation.
The embodiment of the application further provides a storage medium, in which a computer program is stored, and when the computer program runs on a computer, the computer executes the software code defect detection method according to any one of the embodiments.
It should be noted that, for the software code defect detection method described in the present application, it will be understood by those skilled in the art that all or part of the process of implementing the software code defect detection method described in the embodiments of the present application may be implemented by controlling related hardware by using a computer program, where the computer program may be stored in a computer readable storage medium, such as a memory of a terminal device, and executed by at least one processor in the terminal device, and the execution may include the process of implementing the embodiment of the software code defect detection method. The storage medium may be a magnetic disk, an optical disk, a Read Only Memory (ROM), a random access Memory (RAM, random Access Memory), or the like.
For the software code defect detection device in the embodiment of the present application, each functional module may be integrated in one processing chip, or each module may exist alone physically, or two or more modules may be integrated in one module. The integrated modules may be implemented in hardware or in software functional modules. The integrated module, if implemented as a software functional module and sold or used as a stand-alone product, may also be stored in a computer readable storage medium such as read-only memory, magnetic or optical disk, etc.
The method, the device, the medium and the equipment for detecting the software code defects provided by the embodiment of the application are described in detail. The principles and embodiments of the present application are described herein with specific examples, the above examples being provided only to assist in understanding the methods of the present application and their core ideas; meanwhile, those skilled in the art will have variations in the specific embodiments and application scope in light of the ideas of the present application, and the present description should not be construed as limiting the present application in view of the above.

Claims (10)

1. A method for detecting software code defects, comprising:
acquiring a code text to be detected, and judging whether the code text to be detected is built according to a preset writing frame or not according to a preset code construction rule;
when the code text to be detected meets the code construction rule, determining respective corresponding preset inspection rules according to various code character strings forming the code text to be detected;
and performing defect detection operation on various code character strings in the code text to be detected according to the preset detection rules to obtain detection results corresponding to different preset detection rules.
2. The method for detecting software code defects according to claim 1, wherein the determining whether the code text to be detected is built according to a set composition frame according to a preset code construction rule comprises:
and traversing the code text to be detected according to a plurality of preset keywords, judging whether the code text to be detected comprises code character strings corresponding to the plurality of keywords or not, and judging whether the code text to be detected is built according to a set writing frame or not.
3. The method for detecting software code defects according to claim 2, wherein said determining whether the code text to be detected includes code strings corresponding to the plurality of keywords to determine whether the code text to be detected is built according to a set composition frame comprises:
judging whether the code text to be detected comprises code character strings corresponding to the keywords, wherein the occurrence sequence of the code character strings in the code text to be detected corresponds to the preset ordering sequence of the keywords so as to judge whether the code text to be detected is built according to a set writing frame.
4. The software code defect detection method of claim 3, wherein the keywords include one or more of class information keywords, field attribute keywords, and method information keywords.
5. The software code defect detection method of claim 4, wherein the inspection result comprises:
whether the naming standards of the class information accord with preset naming rules or not; or (b)
Whether the reference relation of the byte codes in the field attributes accords with a preset reference rule or not; or (b)
Whether the byte code instruction in the method information accords with the debugging printing rule or not.
6. The software code defect detection method of claim 5, wherein after the obtaining of the inspection results corresponding to different preset inspection rules, the method further comprises a code defect processing operation:
marking abnormal class information with nonstandard naming in the class information; or (b)
Deleting the abnormal field attribute with the byte code reference relation error in the field attribute; or (b)
And deleting the abnormal method information of which the byte code instruction does not accord with the debugging printing rule in the method information.
7. The software code defect detection method of claim 6, wherein the method further comprises:
and generating notification information comprising optimized code text after the code defect processing operation.
8. A software code defect detection apparatus, characterized in that the software code defect detection apparatus comprises:
the text acquisition module is used for acquiring a code text to be detected, and judging whether the code text to be detected is built according to a preset writing frame or not according to preset code construction rules;
the rule determining module is used for determining respective corresponding preset checking rules according to various code character strings forming the code text to be detected when the code text to be detected meets the code construction rules;
and the result checking module is used for respectively carrying out defect detection operation on various code character strings in the code text to be detected according to the preset checking rules to obtain checking results corresponding to different preset checking rules.
9. A computer readable storage medium storing a plurality of instructions adapted to be loaded by a processor to perform the software code defect detection method of any of claims 1 to 7.
10. A terminal device comprising a processor and a memory, the memory storing a plurality of instructions, the processor loading the instructions to perform the software code defect detection method of any of claims 1 to 7.
CN202310323743.1A 2023-03-28 2023-03-28 Software code defect detection method, device, medium and equipment Pending CN116383053A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310323743.1A CN116383053A (en) 2023-03-28 2023-03-28 Software code defect detection method, device, medium and equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310323743.1A CN116383053A (en) 2023-03-28 2023-03-28 Software code defect detection method, device, medium and equipment

Publications (1)

Publication Number Publication Date
CN116383053A true CN116383053A (en) 2023-07-04

Family

ID=86972577

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310323743.1A Pending CN116383053A (en) 2023-03-28 2023-03-28 Software code defect detection method, device, medium and equipment

Country Status (1)

Country Link
CN (1) CN116383053A (en)

Similar Documents

Publication Publication Date Title
CN106502703B (en) Function calling method and device
CN104852885B (en) Method, device and system for verifying verification code
CN104427074B (en) A kind of methods, devices and systems for showing incoming information
CN111078556B (en) Application testing method and device
CN110020293B (en) Multimedia data display method, device and storage medium
CN112231144A (en) Data processing method and device and electronic equipment
CN112749074B (en) Test case recommending method and device
WO2021121225A1 (en) Method for installing application program, and electronic apparatus
CN103729283B (en) System log output method and device and terminal device
CN111359210B (en) Data processing method and device, electronic equipment and storage medium
CN107766351B (en) File directory identification method and device
CN115600213A (en) Vulnerability management method, device, medium and equipment based on application program
CN114510417A (en) Image rendering effect testing method and device, electronic equipment and storage medium
CN111027406B (en) Picture identification method and device, storage medium and electronic equipment
CN116383053A (en) Software code defect detection method, device, medium and equipment
CN109451295A (en) A kind of method and system obtaining virtual information
CN112667868A (en) Data detection method and device
CN114064447B (en) Interface testing method and device, storage medium and terminal
CN114422274B (en) Multi-scene vulnerability detection method and device based on cloud protogenesis and storage medium
CN116301578A (en) Parameter configuration method, device, medium and equipment for cache function
CN117787207A (en) Standard cell library verification method and device, storage medium and electronic equipment
CN117743170A (en) Test case generation method and device, storage medium and terminal equipment
CN117112340A (en) Application operation detection method and device, electronic equipment and storage medium
CN115640081A (en) Business case decision method and device, electronic equipment and storage medium
CN116185795A (en) Method and device for determining starting strategy of application program and electronic 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