Detailed Description
The embodiment of the specification provides a method, a device and equipment for detecting an abandoned code.
In order to make those skilled in the art better understand the technical solutions in the present specification, the technical solutions in the embodiments of the present specification will be clearly and completely described below with reference to the drawings in the embodiments of the present specification, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be obtained by a person skilled in the art without making any inventive step based on the embodiments of the present disclosure, shall fall within the scope of protection of the present application.
In the embodiment of the present specification, for the client code, the obsolete code contained therein mainly originates from two aspects: one is the code surrounded by obsolete network requests, usually due to server changes; the second is code that is no longer called as the service transitions, typically due to client changes. Changes in the services at the application layer, or changes in the underlying implementation logic although the services themselves at the application layer are unchanged, may result in changes to the server and/or client. The scheme of the present specification can be used for effectively detecting the obsolete codes derived from the two aspects.
Fig. 1 is a schematic diagram of an overall architecture related to the solution of the present specification in a practical application scenario. In this whole framework, mainly include: client code, associated responsible persons, request interfaces of the server, and a obsolete code detection system for executing the scheme. The obsolete code detection system comprises at least a first scanning system for scanning client codes, a second scanning system for scanning request interfaces of the server, a notification system for notifying the relevant responsible persons. Based on these two scanning systems, the obsolete codes from the two aspects can be detected, respectively.
The solution of the present description is explained below mainly based on the exemplary architecture of fig. 1.
Fig. 2 is a schematic flowchart of a method for detecting a waste code according to an embodiment of the present disclosure. The process may be automatically executed according to a preset policy, for example, after the current version of the client is online for a long time (for example, at the end of the version or when the version is offline); alternatively, the process may be executed based on an active trigger of a developer.
From the perspective of a device, the execution subject of the process may be a device of a developer, such as a version management server, a business server, and the like. From the program perspective, the execution subject of the flow may be a program installed in the above-mentioned device, and the program may be in the form of a client, a web page side, a server side, or the like.
The flow in fig. 2 may include the following steps:
s202: and acquiring a client code.
In this embodiment, the client code may be the same version of code as the client, for example, the current version of code. At least a portion of the client code for which each of the submitters has submitted its own responsibility may be received for subsequent detection.
S204: and determining the request interface which is not called within the time range of the version of the client code according to the monitoring data called by the request interface of the server.
In this embodiment of the present specification, the client can send a network request to the server to request the server to perform corresponding service processing, where this process is implemented by the client calling a request interface of the server, and the request interface in step S204 at least includes a request interface that the server provides for the client to call.
Monitoring of the invocation of the request interface can be established in advance, and monitoring data can be obtained through monitoring records. Based on the monitoring data, the request interfaces which are not called within the time range of the version of the client code are more likely to be out of use and become obsolete interfaces.
S206: and screening the code which is correspondingly written for the un-called request interface in the client-side code.
In the embodiment of the specification, for the obsolete interface of the server, at least part of the code written for the obsolete interface in the client code naturally becomes obsolete code. The obsolete codes include, for example: a calling code segment for calling the obsolete interface; it may also contain other code serving the calling code segment, code for further business processing based on the returned results of the obsolete interfaces, etc.
In practical applications, in order to improve the screening efficiency and reliability, the range included in the correspondingly written code in step S206 may be predefined more precisely by using a preset policy, which is not specifically limited herein, but is merely exemplary. For example, the correspondingly written code may be predefined as: the client code comprises a calling code segment used for calling the un-called request interface; or, if necessary, the range of the correspondingly written code may be expanded appropriately on the basis of the foregoing example.
S208: and judging the abandoned codes in the client codes according to the screened codes.
In the present embodiment, the screened codes may be directly determined as obsolete codes in the client codes, or the screening in step S206 may be regarded as coarse screening, and the fine screening result may be further refined based on the coarse screening result in step S208 and determined as obsolete codes in the client codes. Which way to adopt in practical application may depend on the accuracy in the screening in step S206.
By the method of fig. 2, obsolete codes in the client code originating from the first aspect described above can be efficiently and automatically detected.
Based on the method of fig. 2, the present specification also provides some specific embodiments of the method, and further provides the following descriptions.
In this embodiment, on the basis of the flow in fig. 2, in order to detect the obsolete code in the client code, the following steps may be further performed: determining callable code segments in the client code that are not called by locally scanning the client code; and judging the abandoned codes in the client codes according to the determined callable code sections, wherein the callable code sections are more likely to be out of use and become the abandoned codes. The callable code segment comprises for example at least one of: methods, classes, parameters, objects, constructs, associations.
In the embodiment of the present specification, after the obsolete codes are automatically detected through the above scheme, the obsolete codes can be directly offline, or, more surely, the relevant responsible person is notified to offline the obsolete codes or the detection result is reviewed. For the latter case, the responsible person is required to intervene in the subsequent work, for example, after determining the obsolete code in the client code, the following steps may be executed: determining a responsible for the obsolete code; the responsible person is notified to go off the line of the obsolete code by sending an electronic message, such as an email, a short message or an instant message, and how to process the obsolete code subsequently after the responsible person receives the notification is not specifically limited.
For example, when the codes are submitted before, the submitter of each part of the codes is recorded as a responsible person, and after the abandoned codes are detected, the corresponding submitter is notified; alternatively, the user may be notified of a pre-designated person in charge regardless of who the code submitter is.
According to the above description, the embodiment of the present specification further provides a schematic diagram of an implementation principle of the foregoing obsolete code detection method in an actual application scenario, as shown in fig. 3.
In fig. 3, the client code is scanned locally, and the request interface of the server is scanned to detect the obsolete code originated from the above two aspects; the method comprises the steps that locally scanned callable code segments which are not called can be regarded as obsolete codes, and for scanned request interfaces of the callable service terminals, the calling codes of clients which are interfaced with the request interfaces can be regarded as the obsolete codes; and further, notifying the corresponding responsible person of the offline abandon code through an electronic message.
Based on the same idea, the embodiments of the present specification further provide a device and an apparatus corresponding to the above method, see fig. 4 and fig. 5.
Fig. 4 is a schematic structural diagram of an obsolete code detection device corresponding to fig. 2 provided in an embodiment of the present specification, where a dashed box represents an optional module, and the device includes:
an obtaining module 401, which obtains a client code;
a determining module 402, configured to determine, according to monitoring data called by a request interface of a server, a request interface that has not been called within a time range of a version to which a client code belongs;
a screening module 403, which screens, from the client codes, codes written for the un-called request interfaces correspondingly;
and a judging module 404, which judges the obsolete codes in the client codes according to the screened codes.
Optionally, the apparatus further comprises:
a local scanning module 405, which determines callable code segments in the client code that are not called by locally scanning the client code;
and judging the abandonment code in the client code according to the determined callable code segment which is not called.
Optionally, the invokable code segment comprises a method and/or class.
Optionally, the apparatus further comprises:
a notification module 406, configured to determine a responsible party of the obsolete code after the determination module 404 determines the obsolete code in the client code, and notify the responsible party of taking off the line of the obsolete code by sending an electronic message.
Optionally, the obtaining module 401 obtains the client code, which specifically includes:
the obtaining module 401 receives client codes submitted by one or more submitters;
the notifying module 406 determines the responsible party of the obsolete code, and specifically includes:
the notification module 406 determines that the submitter of the obsolete code is the principal of the obsolete code.
Fig. 5 is a schematic structural diagram of an obsolete code detection device corresponding to fig. 2 provided in an embodiment of the present specification, where the device includes:
at least one processor; and the number of the first and second groups,
a memory communicatively coupled to the at least one processor; wherein,
the memory stores instructions executable by the at least one processor to enable the at least one processor to:
acquiring a client code;
determining a request interface which is not called within the time range of the version to which the client code belongs according to monitoring data called by the request interface of the server;
and screening the code which is correspondingly written for the un-called request interface in the client-side code.
Based on the same idea, the embodiments of the present specification further provide a non-volatile computer storage medium corresponding to fig. 2, storing computer-executable instructions configured to:
acquiring a client code;
determining a request interface which is not called within the time range of the version to which the client code belongs according to monitoring data called by the request interface of the server;
and screening the code which is correspondingly written for the un-called request interface in the client-side code.
The foregoing description has been directed to specific embodiments of this disclosure. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims may be performed in a different order than in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing may also be possible or may be advantageous.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the embodiments of the apparatus, the device, and the nonvolatile computer storage medium, since they are substantially similar to the embodiments of the method, the description is simple, and for the relevant points, reference may be made to the partial description of the embodiments of the method.
The apparatus, the device, the nonvolatile computer storage medium, and the method provided in the embodiments of the present specification correspond to each other, and therefore, the apparatus, the device, and the nonvolatile computer storage medium also have advantageous technical effects similar to those of the corresponding method.
In the 90 s of the 20 th century, improvements in a technology could clearly distinguish between improvements in hardware (e.g., improvements in circuit structures such as diodes, transistors, switches, etc.) and improvements in software (improvements in process flow). However, as technology advances, many of today's process flow improvements have been seen as direct improvements in hardware circuit architecture. Designers almost always obtain the corresponding hardware circuit structure by programming an improved method flow into the hardware circuit. Thus, it cannot be said that an improvement in the process flow cannot be realized by hardware physical modules. For example, a Programmable Logic Device (PLD), such as a Field Programmable Gate Array (FPGA), is an integrated circuit whose Logic functions are determined by programming the Device by a user. A digital system is "integrated" on a PLD by the designer's own programming without requiring the chip manufacturer to design and fabricate application-specific integrated circuit chips. Furthermore, nowadays, instead of manually making an integrated Circuit chip, such Programming is often implemented by "logic compiler" software, which is similar to a software compiler used in program development and writing, but the original code before compiling is also written by a specific Programming Language, which is called Hardware Description Language (HDL), and HDL is not only one but many, such as abel (advanced Boolean Expression Language), ahdl (alternate Language Description Language), traffic, pl (core unified Programming Language), HDCal, JHDL (Java Hardware Description Language), langue, Lola, HDL, laspam, hardsradware (Hardware Description Language), vhjhd (Hardware Description Language), and vhigh-Language, which are currently used in most common. It will also be apparent to those skilled in the art that hardware circuitry that implements the logical method flows can be readily obtained by merely slightly programming the method flows into an integrated circuit using the hardware description languages described above.
The controller may be implemented in any suitable manner, for example, the controller may take the form of, for example, a microprocessor or processor and a computer-readable medium storing computer-readable program code (e.g., software or firmware) executable by the (micro) processor, logic gates, switches, an Application Specific Integrated Circuit (ASIC), a programmable logic controller, and an embedded microcontroller, examples of which include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320, the memory controller may also be implemented as part of the control logic for the memory. Those skilled in the art will also appreciate that, in addition to implementing the controller as pure computer readable program code, the same functionality can be implemented by logically programming method steps such that the controller is in the form of logic gates, switches, application specific integrated circuits, programmable logic controllers, embedded microcontrollers and the like. Such a controller may thus be considered a hardware component, and the means included therein for performing the various functions may also be considered as a structure within the hardware component. Or even means for performing the functions may be regarded as being both a software module for performing the method and a structure within a hardware component.
The systems, devices, modules or units illustrated in the above embodiments may be implemented by a computer chip or an entity, or by a product with certain functions. One typical implementation device is a computer. In particular, the computer may be, for example, a personal computer, a laptop computer, a cellular telephone, a camera phone, a smartphone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
For convenience of description, the above devices are described as being divided into various units by function, and are described separately. Of course, the functions of the various elements may be implemented in the same one or more software and/or hardware implementations of the present description.
As will be appreciated by one skilled in the art, the present specification embodiments may be provided as a method, system, or computer program product. Accordingly, embodiments of the present description may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, embodiments of the present description may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and so forth) having computer-usable program code embodied therein.
The description has been presented with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the description. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, Random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
As will be appreciated by one skilled in the art, the embodiments of the present description may be provided as a method, system, or computer program product. Accordingly, the description may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the description may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
This description may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types. The specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including memory storage devices.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the system embodiment, since it is substantially similar to the method embodiment, the description is simple, and for the relevant points, reference may be made to the partial description of the method embodiment.
The above description is only an example of the present specification, and is not intended to limit the present application. Various modifications and changes may occur to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.