CN112612516B - Code processing method and device - Google Patents

Code processing method and device Download PDF

Info

Publication number
CN112612516B
CN112612516B CN202011629194.3A CN202011629194A CN112612516B CN 112612516 B CN112612516 B CN 112612516B CN 202011629194 A CN202011629194 A CN 202011629194A CN 112612516 B CN112612516 B CN 112612516B
Authority
CN
China
Prior art keywords
function
class
outdated
referenced
computer program
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202011629194.3A
Other languages
Chinese (zh)
Other versions
CN112612516A (en
Inventor
荆东伟
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ruiting Network Technology Shanghai Co ltd
Original Assignee
Ruiting Network Technology Shanghai 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 Ruiting Network Technology Shanghai Co ltd filed Critical Ruiting Network Technology Shanghai Co ltd
Priority to CN202011629194.3A priority Critical patent/CN112612516B/en
Publication of CN112612516A publication Critical patent/CN112612516A/en
Application granted granted Critical
Publication of CN112612516B publication Critical patent/CN112612516B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/72Code refactoring
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/75Structural analysis for program understanding
    • 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/448Execution paradigms, e.g. implementations of programming paradigms
    • G06F9/4482Procedural
    • G06F9/4484Executing subprograms

Landscapes

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

Abstract

The application discloses a code processing method and a code processing device. And carrying out Gitdiff verification on the computer program codes in the items to obtain Gitdiff information, wherein the Gitdiff information comprises identification information of changed classes in the computer program codes in the items. The classes of changes include at least: the class in which the code is modified or added. It is detected whether the identification information of the class in the item is located in Gitdiff information. If so, checking whether the referenced function in the class comprises an outdated function. In the case where the functions referenced in the class include outdated functions, a detection report is output that prompts the functions referenced in the class to include outdated functions. The method can detect whether outdated functions are referenced in the computer program codes in the changed classes in the project, and can detect whether all the computer program codes in the project are referenced by outdated functions, so that the aim of incremental detection (the class with unchanged codes can be ignored) is fulfilled.

Description

Code processing method and device
Technical Field
The present application relates to the field of computer technologies, and in particular, to a code processing method and apparatus.
Background
Currently, various APPs (Application programs) on mobile phones are widely applied, along with the increasing requirements of people on functions of APPs, manufacturers of APPs need to continuously update iterative APPs, and in the process of updating iterative APPs, existing outdated functions in source codes of APPs often need to be updated, for example, new functions are used in codes to gradually replace outdated functions, so that outdated functions in source codes in APPs are gradually abandoned. In order to facilitate maintenance of the APP afterwards, this requires that the outdated functions are not referenced in the source code of the APP anymore and that new functions are referenced in the course of a subsequent iterative update to the APP.
Disclosure of Invention
In order to refer to new functions without referring to outdated functions in the source code of the APP in the process of updating the APP in a subsequent iteration, after a technician updates the source code of the APP, it is necessary to detect whether the outdated functions are referred to in the source code of the APP, and in the case that the outdated functions are referred to in the source code of the APP, the technician can be prompted in time to modify the source code of the APP, so that the source code of the APP does not refer to the outdated functions any more, but refers to the new functions,
The application discloses a code processing method and a code processing device.
In a first aspect, the present application shows a code processing method, the method comprising:
carrying out Gitdiff verification on the computer program codes in the project to obtain Gitdiff information, wherein Gitdiff information comprises identification information of changed classes in the computer program codes in the project; the classes of changes include at least: a class in which code is modified or added;
for any one of the classes in the computer program code in the item, detecting whether the identification information of the class in the item is located in the Gitdiff information;
Checking whether a function referenced in the class includes an outdated function if the identification information of the class in the item is located in the Gitdiff information;
in the case that the functions referenced in the class include outdated functions, a detection report is output prompting that the functions referenced in the class include outdated functions.
In an alternative implementation, the verifying whether the function referenced in the class includes an outdated function includes:
detecting a referenced function in the class;
determining whether the referenced function is stored in a preset outdated list, wherein the preset outdated list is used for recording the outdated function;
and determining the referenced function as an outdated function in the condition that the referenced function is stored in the preset outdated list.
In an alternative implementation, the Gitdiff information includes the line number of the modified or added code in the changed class in the computer program code in the item;
The function of detecting references in the class includes:
screening the class for computer program codes corresponding to the line numbers;
And detecting the referenced function in the computer program code corresponding to the line number.
In an alternative implementation, after detecting the referenced function in the class, the method further includes:
Determining whether the referenced function is located in a preset data packet configured in advance;
And executing the step of determining whether the referenced function is stored in a preset outdated list in the case that the referenced function is located in a preset data packet configured in advance.
In an alternative implementation, the detection report includes at least one of: the outdated function, the line number of the outdated function in the computer program code of the item, the code screenshot of the class in which the outdated function is located, and the severity of the event referencing the outdated function in the class;
The output detection report includes:
and storing the detection report in a preset file, and/or displaying the detection report.
In a second aspect, the present application shows a code processing apparatus, the apparatus comprising:
The first verification module is used for carrying out Gitdiff verification on the computer program codes in the project to obtain Gitdiff information, and the Gitdiff information comprises identification information of the changed class in the computer program codes in the project; the classes of changes include at least: a class in which code is modified or added;
a detection module, configured to detect, for any one class in the computer program code in the item, whether identification information of the class in the item is located in the Gitdiff information;
a second checking module for checking whether a function referenced in the class includes an outdated function if the identification information of the class in the item is located in the Gitdiff information;
And the output module is used for outputting a detection report in the case that the functions quoted in the class comprise outdated functions, wherein the detection report is used for prompting that the functions quoted in the class comprise outdated functions.
In an alternative implementation, the second checking module includes:
a detection unit for detecting a referenced function in the class;
a first determining unit, configured to determine whether the referenced function is stored in a preset outdated list, where the preset outdated list is used for recording outdated functions;
And a second determining unit, configured to determine the referenced function as an outdated function if the referenced function is stored in the preset outdated list.
In an alternative implementation, the Gitdiff information includes the line number of the modified or added code in the changed class in the computer program code in the item;
The detection unit includes:
a screening subunit, configured to screen, in the class, computer program codes corresponding to the line numbers;
And the detection subunit is used for detecting the referenced function in the computer program code corresponding to the line number.
In an alternative implementation, the second checking module further includes:
a third determining unit, configured to determine whether the referenced function is located in a preset data packet configured in advance;
The first determining unit is further configured to determine whether the referenced function is stored in a preset outdated list if the referenced function is located in a preset data packet configured in advance.
In an alternative implementation, the detection report includes at least one of: the outdated function, the line number of the outdated function in the computer program code of the item, the code screenshot of the class in which the outdated function is located, and the severity of the event referencing the outdated function in the class;
the output module includes:
The storage unit is used for storing the detection report in a preset file;
and the display unit is used for displaying the detection report.
In a third aspect, the present application shows an electronic device comprising:
A processor;
a memory for storing processor-executable instructions;
wherein the processor is configured to perform the code processing method according to the first aspect.
In a fourth aspect, the present application shows a non-transitory computer readable storage medium, which when executed by a processor of an electronic device, causes the electronic device to perform the code processing method according to the first aspect.
In a fifth aspect, the application shows a computer program product, instructions in which, when executed by a processor of an electronic device, enable the electronic device to perform the code processing method according to the first aspect.
The technical scheme provided by the application can comprise the following beneficial effects:
In the application, the computer program code in the project is subjected to Gitdiff verification to obtain Gitdiff information, and the Gitdiff information comprises identification information of the changed class in the computer program code in the project. The classes of changes include at least: the class in which the code is modified or added. It is detected whether the identification information of the class in the item is located in Gitdiff information. In the case that the identification information of the class in the item is located in Gitdiff information, it is checked whether the functions referenced in the class include outdated functions. In the case where the functions referenced in the class include outdated functions, a detection report is output that prompts the functions referenced in the class to include outdated functions.
By the method and the device, whether the outdated functions are referenced in the computer program codes in the changed classes (the classes with modified codes or increased codes) in the project can be detected, and whether all the computer program codes in the project are referenced with the outdated functions can be not detected, so that the aim of incremental detection (classes with unchanged codes can be ignored) is fulfilled.
The application realizes detection of whether the outdated function is quoted in the class in the project based on the lin detection, for example, a lin detection tool needs to be called, and then the detection logic (comprising the flow of the steps S101-S104 and the like) of the application is configured for the lin detection tool, so that the lin detection tool can realize the purpose of detecting whether the outdated function is quoted in the class in the project based on the detection logic.
The line detection tool has a default configuration, after the line detection tool is started, the line detection tool loads the default configuration in the line detection tool, and then the line detection tool usually executes detection operation according to the default configuration.
However, in the present application, after the link detection tool loads the default configuration in the link detection tool, the detection logic of the present application may be used as a configuration to replace the default configuration loaded by the link detection tool, so that the link detection tool may use the detection logic of the present application as a configuration, and further, the link detection tool may perform detection according to the detection logic of the present application, for example, to achieve the purpose of detecting whether an outdated function is referenced in a class in an item according to the present application, and may perform detection not according to the default configuration.
However, the present application does not change the default configuration of the lin detection tool and the lin detection tool, and in the case that the purpose of detecting whether the outdated function is cited in the class in the item needs to be achieved, the default configuration loaded by the lin detection tool is replaced by using the detection logic of the present application as the configuration, so that the lin detection tool can use the detection logic of the present application as the configuration, and further, the purpose of detecting whether the outdated function is cited in the class in the item according to the detection logic of the present application is achieved by the lin detection tool.
In the case that the purpose of detecting whether the outdated function is cited in the class in the project according to the application does not need to be achieved, the detection logic according to the application can be used as a default configuration for replacing the loading of the lin detection tool, so that the lin detection tool can execute detection operation according to the default configuration, or the lin detection tool can not be influenced by the detection logic according to the application, or the lin detection tool can execute detection of other business logic.
Thus, the method of the application does not affect the detection of the link detection tool to execute detection operation or other services according to the default configuration.
Drawings
FIG. 1 is a flow chart of the steps of a code processing method of the present application;
FIG. 2 is a block diagram of a code processing apparatus of the present application;
FIG. 3 is a block diagram of an electronic device shown in the present application;
fig. 4 is a block diagram of an electronic device in accordance with the present application.
Detailed Description
In order that the above-recited objects, features and advantages of the present application will become more readily apparent, a more particular description of the application will be rendered by reference to the appended drawings and appended detailed description.
Referring to fig. 1, there is shown a flow chart of steps of a code processing method of the present application, which may specifically include the steps of:
In step S101, the computer program code in the item is checked Gitdiff to obtain Gitdiff information, and the Gitdiff information includes identification information of the changed class in the computer program code in the item. The classes of changes include at least: the class in which the code is modified or added.
The Gitdiff check of the computer program code in the item is to detect a class in the item in which the code is modified or added, and after Gitdiff check of the computer program code in the item, gitdiff information is output. Gitdiff may or may not be null in the information.
Where there is a class in the computer program code in the item where the code is modified and/or the code is added, the Gitdiff information includes the identification information of the class in the item, i.e., gitdiff information is not null. Or in the case where there is no class in the computer program code in the item in which the code is modified and no code is added, the Gitdiff information does not include the identification information of any one class in the computer program code in the item, that is, gitdiff information is null.
Thereafter, the following steps S102 to S104 may be performed for any one of the classes of the computer program code in the item, as well as for each of the other classes of the computer program code in the item. The specific flow is as follows:
In step S102, it is detected whether the identification information of the category in the item is located in Gitdiff information.
In the application, the identification information of the category in the project comprises: the path of the class in the project or the name of the class in the project, etc., and the identification information of different classes in the project is different.
In this step, the identification information of the class in the item may be obtained, and then the identification information of the class in the item is searched for in Gitdiff information, so as to determine whether the identification information of the class in the item is located in Gitdiff information.
Wherein, in case the identification information of the class in the item is located in Gitdiff information, it is explained that the code in the class is modified and/or added, and then step S103 may be performed.
Or if the identification information of the class in the item is not located in Gitdiff information, it is indicated that the code in the class is not modified and is not added, the process can be ended for the class, and then the processes of steps S102 to S104 are started to be executed for other classes in the item.
In case the identification information of the class in the item is located in Gitdiff information, it is checked in step S103 whether the functions referenced in the class comprise outdated functions.
In one embodiment of the present application, the visitCallExpression method in the MethodVisitHandler class may be called to detect expressions in the class, then detect whether there is a referenced function in each expression, and then check whether each referenced function detected is an outdated function, so that it may be implemented to detect whether the referenced functions in the class include outdated functions.
Step S104 may be executed in a case where the functions referenced in the class include outdated functions, or the flow may be ended for the class and then the flows of steps S102 to S104 may be started for other classes in the item in a case where the functions referenced in the class do not include outdated functions.
Wherein in the case where no expression is detected in the class, or in the case where an expression is detected in the class but no referenced function is present in the expression, or in the case where an expression is detected in the class, a referenced function is present in the expression but the referenced function is an unequally-used function, it may be determined that there is no case where the referenced function in the class includes an unequally-used function.
In one embodiment of the present application, the technician may develop other projects in addition to the project mentioned in the development step S101, where the projects may include different functional blocks in the application program, etc., and in the computer program code of each project, if a certain function is an outdated function, the technician may label the function to identify that the function is an outdated function, where the label may be "// DEPRECATED", etc. In one example "// DEPRECATED" may be added at the end of the row where the function is located to mark the function in the row as an outdated function, etc.
Thus, when checking whether the functions referenced in the class include outdated functions, computer program code in all items may be traversed, and when traversing to "// DEPRECATED", it is determined whether the function in the row in which "// DEPRECATED" is located is a function referenced in the class, and if the function in the row in which "// DEPRECATED" is located is a function referenced in the class, the function referenced in the class may be determined as an outdated function. If the function in the row of "// DEPRECATED" is not a function referenced in the class, the traversal may continue until it is determined that none of the functions in the row of computer program code in all of the items are functions referenced in the class, and it may be determined that the functions referenced in the class do not include outdated functions.
However, in the above manner, it is necessary to traverse the computer program codes in all the items, and if the number of the computer program codes in all the items is large, it takes a long time to check whether the functions referenced in the class include outdated functions, resulting in low efficiency in checking whether the functions referenced in the class include outdated functions.
Therefore, in order to improve the efficiency of checking whether the functions referenced in the class include outdated functions, in another embodiment of the present application, a technician may count outdated functions in advance, and then store the outdated functions in a preset outdated list, so, when checking whether the functions referenced in the class include outdated functions, the method may be implemented according to the following procedure, including:
1031. the referenced function is detected in the class.
In an embodiment of the application, the computer program code in the class may include a plurality of lines, some of which are newly added or modified and some of which are old, e.g., not newly added and not modified. In order to accurately determine the functions referenced in the newly added or modified code in the class, in another embodiment of the application, gitdiff information includes the line number of the modified or added code in the changed class in the computer program code in the item; thus, the computer program code corresponding to the line number can be screened in the class, and then the referenced function can be detected in the computer program code corresponding to the line number.
1032. It is determined whether the referenced function is stored in a preset outdated list that is used to record outdated functions.
1033. In the case where the referenced function is stored in a preset outdated list, the referenced function is determined to be an outdated function.
1034. In the event that the referenced function is not stored in the preset outdated list, the referenced function is determined to not be an outdated function.
Wherein, at times, the technician does not need to care whether the referenced function is an outdated function, i.e., can tolerate the referenced function to be an outdated function, i.e., does not need to modify the referenced function to be an unexpired function, although the referenced function is sometimes an outdated function.
In this case, a technician can precisely configure in advance which outdated functions are referenced to be tolerated, which outdated functions are referenced to be intolerable, and so on.
Logic in computer program code in the present application includes, among other things, "items" → "data packets" → "classes" → "functions".
Thus, in one embodiment, it may be configured in terms of a "data package" dimension which references to functions that are outdated are intolerable, e.g., a preset data package may be configured in advance, the functions included in the preset data package being outdated functions and being intolerable, i.e., the functions in the preset data package being referenced are intolerable.
Thus, in addition to the foregoing embodiments, the method further includes: after detecting the referenced function in the class, determining whether the referenced function is in a preset data packet configured in advance, and determining whether the referenced function is stored in a preset outdated list again in the case that the referenced function is in the preset data packet configured in advance. In the case where the referenced function is not located in a preset packet configured in advance, the flow may be ended.
By the embodiment of the application, the detection of the functions referenced in the class can be accurately controlled.
In the case where the function referenced in the class includes an outdated function, in step S104, a detection report is output, the detection report being used to prompt that the function referenced in the class includes an outdated function.
In the present application, in the case that the function referenced in the class includes an outdated function, a detection report may be output to prompt a technician that the function referenced in the class includes an outdated function, so that the technician may perceive that the function referenced in the class includes an outdated function, and then modify the outdated function to an unequalized function, so that the outdated function is not referenced in the class.
In one embodiment of the application, the detection report includes at least one of: the outdated function, the line number of the outdated function in the computer program code of the item, the code screenshot of the class in which the outdated function is located, and the severity of the event referencing the outdated function in the class.
When the detection report is output, the detection report can be stored in a preset file, and/or the detection report can be displayed for a technician to check the detection report, or the detection report can be played through a sound box for the technician to perceive the detection report, or the detection report can be sent to terminal equipment used by the technician, so that the technician can check the detection report on the terminal equipment used by the technician. The method can be particularly used for transmitting through mail, an internet instant messaging tool, short messages or PUSH and the like, and the method is not limited to the specific transmitting mode.
According to the application, the technician does not need to manually acquire the detection report, so that the burden of the technician can be reduced, and the labor cost is further reduced.
In the application, the computer program code in the project is subjected to Gitdiff verification to obtain Gitdiff information, and the Gitdiff information comprises identification information of the changed class in the computer program code in the project. The classes of changes include at least: the class in which the code is modified or added. It is detected whether the identification information of the class in the item is located in Gitdiff information. In the case that the identification information of the class in the item is located in Gitdiff information, it is checked whether the functions referenced in the class include outdated functions. In the case where the functions referenced in the class include outdated functions, a detection report is output that prompts the functions referenced in the class to include outdated functions.
By the method and the device, whether the outdated functions are referenced in the computer program codes in the changed classes (the classes with modified codes or increased codes) in the project can be detected, and whether all the computer program codes in the project are referenced with the outdated functions can be not detected, so that the aim of incremental detection (classes with unchanged codes can be ignored) is fulfilled.
The application realizes detection of whether the outdated function is quoted in the class in the project based on the lin detection, for example, a lin detection tool needs to be called, and then the detection logic (comprising the flow of the steps S101-S104 and the like) of the application is configured for the lin detection tool, so that the lin detection tool can realize the purpose of detecting whether the outdated function is quoted in the class in the project based on the detection logic.
The line detection tool has a default configuration, after the line detection tool is started, the line detection tool loads the default configuration in the line detection tool, and then the line detection tool usually executes detection operation according to the default configuration.
However, in the present application, after the link detection tool loads the default configuration in the link detection tool, the detection logic of the present application may be used as a configuration to replace the default configuration loaded by the link detection tool, so that the link detection tool may use the detection logic of the present application as a configuration, and further, the link detection tool may perform detection according to the detection logic of the present application, for example, to achieve the purpose of detecting whether an outdated function is referenced in a class in an item according to the present application, and may perform detection not according to the default configuration.
However, the present application does not change the default configuration of the lin detection tool and the lin detection tool, and in the case that the purpose of detecting whether the outdated function is cited in the class in the item needs to be achieved, the default configuration loaded by the lin detection tool is replaced by using the detection logic of the present application as the configuration, so that the lin detection tool can use the detection logic of the present application as the configuration, and further, the purpose of detecting whether the outdated function is cited in the class in the item according to the detection logic of the present application is achieved by the lin detection tool.
In the case that the purpose of detecting whether the outdated function is cited in the class in the project according to the application does not need to be achieved, the detection logic according to the application can be used as a default configuration for replacing the loading of the lin detection tool, so that the lin detection tool can execute detection operation according to the default configuration, or the lin detection tool can not be influenced by the detection logic according to the application, or the lin detection tool can execute detection of other business logic.
Thus, the method of the application does not affect the detection of the link detection tool to execute detection operation or other services according to the default configuration.
It should be noted that, for simplicity of explanation, the method embodiments are shown as a series of acts, but it should be understood by those skilled in the art that the present application is not limited by the order of acts, as some steps may occur in other orders or concurrently in accordance with the application. Further, those skilled in the art will appreciate that the embodiments described in the specification are all alternative embodiments and that the actions involved are not necessarily required for the present application.
Referring to fig. 2, there is shown a block diagram of a code processing apparatus of the present application, which may specifically include the following modules:
the first verification module 11 is configured to perform Gitdiff verification on the computer program code in the item to obtain Gitdiff information, where Gitdiff information includes identification information of a changed class in the computer program code in the item; the classes of changes include at least: a class in which code is modified or added;
a detection module 12, configured to detect, for any one class in the computer program code in the item, whether identification information of the class in the item is located in the Gitdiff information;
A second checking module 13, configured to check whether a function referenced in the class includes an outdated function if identification information of the class in the item is located in the Gitdiff information;
An output module 14 for outputting a detection report for prompting that the function referenced in the class includes an outdated function in case that the function referenced in the class includes an outdated function.
In an alternative implementation, the second checking module includes:
a detection unit for detecting a referenced function in the class;
a first determining unit, configured to determine whether the referenced function is stored in a preset outdated list, where the preset outdated list is used for recording outdated functions;
And a second determining unit, configured to determine the referenced function as an outdated function if the referenced function is stored in the preset outdated list.
In an alternative implementation, the Gitdiff information includes the line number of the modified or added code in the changed class in the computer program code in the item;
The detection unit includes:
a screening subunit, configured to screen, in the class, computer program codes corresponding to the line numbers;
And the detection subunit is used for detecting the referenced function in the computer program code corresponding to the line number.
In an alternative implementation, the second checking module further includes:
a third determining unit, configured to determine whether the referenced function is located in a preset data packet configured in advance;
The first determining unit is further configured to determine whether the referenced function is stored in a preset outdated list if the referenced function is located in a preset data packet configured in advance.
In an alternative implementation, the detection report includes at least one of: the outdated function, the line number of the outdated function in the computer program code of the item, the code screenshot of the class in which the outdated function is located, and the severity of the event referencing the outdated function in the class;
the output module includes:
The storage unit is used for storing the detection report in a preset file;
and the display unit is used for displaying the detection report.
In the application, the computer program code in the project is subjected to Gitdiff verification to obtain Gitdiff information, and the Gitdiff information comprises identification information of the changed class in the computer program code in the project. The classes of changes include at least: the class in which the code is modified or added. It is detected whether the identification information of the class in the item is located in Gitdiff information. In the case that the identification information of the class in the item is located in Gitdiff information, it is checked whether the functions referenced in the class include outdated functions. In the case where the functions referenced in the class include outdated functions, a detection report is output that prompts the functions referenced in the class to include outdated functions.
By the method and the device, whether the outdated functions are referenced in the computer program codes in the changed classes (the classes with modified codes or increased codes) in the project can be detected, and whether all the computer program codes in the project are referenced with the outdated functions can be not detected, so that the aim of incremental detection (classes with unchanged codes can be ignored) is fulfilled.
The application realizes detection of whether the outdated function is quoted in the class in the project based on the lin detection, for example, a lin detection tool needs to be called, and then the detection logic (comprising the flow of the steps S101-S104 and the like) of the application is configured for the lin detection tool, so that the lin detection tool can realize the purpose of detecting whether the outdated function is quoted in the class in the project based on the detection logic.
The line detection tool has a default configuration, after the line detection tool is started, the line detection tool loads the default configuration in the line detection tool, and then the line detection tool usually executes detection operation according to the default configuration.
However, in the present application, after the link detection tool loads the default configuration in the link detection tool, the detection logic of the present application may be used as a configuration to replace the default configuration loaded by the link detection tool, so that the link detection tool may use the detection logic of the present application as a configuration, and further, the link detection tool may perform detection according to the detection logic of the present application, for example, to achieve the purpose of detecting whether an outdated function is referenced in a class in an item according to the present application, and may perform detection not according to the default configuration.
However, the present application does not change the default configuration of the lin detection tool and the lin detection tool, and in the case that the purpose of detecting whether the outdated function is cited in the class in the item needs to be achieved, the default configuration loaded by the lin detection tool is replaced by using the detection logic of the present application as the configuration, so that the lin detection tool can use the detection logic of the present application as the configuration, and further, the purpose of detecting whether the outdated function is cited in the class in the item according to the detection logic of the present application is achieved by the lin detection tool.
In the case that the purpose of detecting whether the outdated function is cited in the class in the project according to the application does not need to be achieved, the detection logic according to the application can be used as a default configuration for replacing the loading of the lin detection tool, so that the lin detection tool can execute detection operation according to the default configuration, or the lin detection tool can not be influenced by the detection logic according to the application, or the lin detection tool can execute detection of other business logic.
Thus, the method of the application does not affect the detection of the link detection tool to execute detection operation or other services according to the default configuration.
For the device embodiments, since they are substantially similar to the method embodiments, the description is relatively simple, and reference is made to the description of the method embodiments for relevant points.
Fig. 3 is a block diagram of an electronic device 800 in accordance with the present application. For example, electronic device 800 may be a mobile phone, computer, digital broadcast terminal, messaging device, game console, tablet device, medical device, exercise device, personal digital assistant, or the like.
Referring to fig. 3, the electronic device 800 may include one or more of the following components: a processing component 802, a memory 804, a power component 806, a multimedia component 808, an audio component 810, an input/output (I/O) interface 812, a sensor component 814, and a communication component 816.
The processing component 802 generally controls overall operation of the electronic device 800, such as operations associated with display, telephone calls, data communications, camera operations, and recording operations. The processing component 802 may include one or more processors 820 to execute instructions to perform all or part of the steps of the methods described above. Further, the processing component 802 can include one or more modules that facilitate interactions between the processing component 802 and other components. For example, the processing component 802 can include a multimedia module to facilitate interaction between the multimedia component 808 and the processing component 802.
The memory 804 is configured to store various types of data to support operations at the device 800. Examples of such data include instructions for any application or method operating on the electronic device 800, contact data, phonebook data, messages, images, videos, and so forth. The memory 804 may be implemented by any type or combination of volatile or nonvolatile memory devices such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disk.
The power supply component 806 provides power to the various components of the electronic device 800. The power components 806 may include a power management system, one or more power sources, and other components associated with generating, managing, and distributing power for the electronic device 800.
The multimedia component 808 includes a screen between the electronic device 800 and the user that provides an output interface. In some embodiments, the screen may include a Liquid Crystal Display (LCD) and a Touch Panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from a user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensor may sense not only the boundary of a touch or slide action, but also the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 808 includes a front camera and/or a rear camera. The front camera and/or the rear camera may receive external multimedia data when the device 800 is in an operational mode, such as a shooting mode or a video mode. Each front camera and rear camera may be a fixed optical lens system or have focal length and optical zoom capabilities.
The audio component 810 is configured to output and/or input audio signals. For example, the audio component 810 includes a Microphone (MIC) configured to receive external audio signals when the electronic device 800 is in an operational mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signals may be further stored in the memory 804 or transmitted via the communication component 816. In some embodiments, audio component 810 further includes a speaker for outputting audio signals.
The I/O interface 812 provides an interface between the processing component 802 and peripheral interface modules, which may be a keyboard, click wheel, buttons, etc. These buttons may include, but are not limited to: homepage button, volume button, start button, and lock button.
The sensor assembly 814 includes one or more sensors for providing status assessment of various aspects of the electronic device 800. For example, the sensor assembly 814 may detect an on/off state of the device 800, a relative positioning of the components, such as a display and keypad of the electronic device 800, the sensor assembly 814 may also detect a change in position of the electronic device 800 or a component of the electronic device 800, the presence or absence of a user's contact with the electronic device 800, an orientation or acceleration/deceleration of the electronic device 800, and a change in temperature of the electronic device 800. The sensor assembly 814 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor assembly 814 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 814 may also include an acceleration sensor, a gyroscopic sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
The communication component 816 is configured to facilitate communication between the electronic device 800 and other devices, either wired or wireless. The electronic device 800 may access a wireless network based on a communication standard, such as WiFi, an operator network (e.g., 2G, 3G, 4G, or 5G), or a combination thereof. In one exemplary embodiment, the communication component 816 receives broadcast signals or broadcast operation information from an external broadcast management system via a broadcast channel. In one exemplary embodiment, the communication component 816 further includes a Near Field Communication (NFC) module to facilitate short range communications. For example, the NFC module may be implemented based on Radio Frequency Identification (RFID) technology, infrared data association (IrDA) technology, ultra Wideband (UWB) technology, bluetooth (BT) technology, and other technologies.
In an exemplary embodiment, the electronic device 800 may be implemented by one or more Application Specific Integrated Circuits (ASICs), digital Signal Processors (DSPs), digital Signal Processing Devices (DSPDs), programmable Logic Devices (PLDs), field Programmable Gate Arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic elements for executing the methods described above.
In an exemplary embodiment, a non-transitory computer readable storage medium is also provided, such as memory 804 including instructions executable by processor 820 of electronic device 800 to perform the above-described method. For example, the non-transitory computer readable storage medium may be ROM, random Access Memory (RAM), CD-ROM, magnetic tape, floppy disk, optical data storage device, etc.
Fig. 4 is a block diagram of an electronic device 1900 in accordance with the present application. For example, electronic device 1900 may be provided as a server.
Referring to FIG. 4, electronic device 1900 includes a processing component 1922 that further includes one or more processors and memory resources represented by memory 1932 for storing instructions, such as application programs, that can be executed by processing component 1922. The application programs stored in memory 1932 may include one or more modules each corresponding to a set of instructions. Further, processing component 1922 is configured to execute instructions to perform the methods described above.
The electronic device 1900 may also include a power component 1926 configured to perform power management of the electronic device 1900, a wired or wireless network interface 1950 configured to connect the electronic device 1900 to a network, and an input/output (I/O) interface 1958. The electronic device 1900 may operate based on an operating system stored in memory 1932, such as Windows Server, mac OS XTM, unixTM, linuxTM, freeBSDTM, or the like.
In this specification, each embodiment is described in a progressive manner, and each embodiment is mainly described by differences from other embodiments, and identical and similar parts between the embodiments are all enough to be referred to each other.
It will be apparent to those skilled in the art that embodiments of the present application may be provided as a method, apparatus, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application 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.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, terminal devices (systems), and computer program products according to the application. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations 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 terminal device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal device, 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.
While preferred embodiments of the present application have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. It is therefore intended that the following claims be interpreted as including the preferred embodiments and all such alterations and modifications as fall within the scope of the application.
Finally, it is further noted that relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or terminal 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 terminal. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or terminal device that comprises the element.
The foregoing has described in detail a code processing method and apparatus provided by the present application, and specific examples have been used herein to illustrate the principles and embodiments of the present application, the above examples being provided only to assist in understanding the method and core idea of the present application; meanwhile, as those skilled in the art will have variations in the specific embodiments and application scope in accordance with the ideas of the present application, the present description should not be construed as limiting the present application in view of the above.

Claims (10)

1. A method of code processing, the method comprising:
carrying out Gitdiff verification on the computer program codes in the project to obtain Gitdiff information, wherein Gitdiff information comprises identification information of changed classes in the computer program codes in the project; the classes of changes include at least: a class in which code is modified or added;
for any one of the classes in the computer program code in the item, detecting whether the identification information of the class in the item is located in the Gitdiff information;
Checking whether a function referenced in the class includes an outdated function if the identification information of the class in the item is located in the Gitdiff information;
outputting a detection report for prompting that the function referenced in the class comprises an outdated function in the case that the function referenced in the class comprises an outdated function;
the verifying whether the function referenced in the class includes an outdated function includes:
detecting a referenced function in the class;
Determining whether the referenced function is located in a preset data packet configured in advance; the functions included in the preset data packet are outdated functions and cannot be referenced;
In the case that the referenced function is located in a preset data packet configured in advance, it is determined whether the referenced function is stored in a preset outdated list.
2. The method of claim 1, wherein the pre-set outdated list is used to record outdated functions, and wherein the determining whether the referenced function is stored in the pre-set outdated list comprises:
and determining the referenced function as an outdated function in the condition that the referenced function is stored in the preset outdated list.
3. The method of claim 2, wherein the Gitdiff information includes a line number of modified or added code in a changed class of computer program code in the item;
The function of detecting references in the class includes:
screening the class for computer program codes corresponding to the line numbers;
And detecting the referenced function in the computer program code corresponding to the line number.
4. The method of claim 1, wherein the detection report includes at least one of: the outdated function, the line number of the outdated function in the computer program code of the item, the code screenshot of the class in which the outdated function is located, and the severity of the event referencing the outdated function in the class;
The output detection report includes:
and storing the detection report in a preset file, and/or displaying the detection report.
5. A code processing apparatus, the apparatus comprising:
The first verification module is used for carrying out Gitdiff verification on the computer program codes in the project to obtain Gitdiff information, and the Gitdiff information comprises identification information of the changed class in the computer program codes in the project; the classes of changes include at least: a class in which code is modified or added;
a detection module, configured to detect, for any one class in the computer program code in the item, whether identification information of the class in the item is located in the Gitdiff information;
a second checking module for checking whether a function referenced in the class includes an outdated function if the identification information of the class in the item is located in the Gitdiff information;
An output module, configured to output a detection report when the function referenced in the class includes an outdated function, where the detection report is used to prompt that the function referenced in the class includes an outdated function;
the second verification module further includes:
a detection unit for detecting a referenced function in the class;
A third determining unit, configured to determine whether the referenced function is located in a preset data packet configured in advance; the functions included in the preset data packet are outdated functions and cannot be referenced;
A first determining unit, configured to determine whether the referenced function is stored in a preset outdated list, in a case that the referenced function is located in a preset data packet configured in advance.
6. The apparatus of claim 5, wherein the pre-set outdated list is for recording outdated functions; the second verification module includes:
And a second determining unit, configured to determine the referenced function as an outdated function if the referenced function is stored in the preset outdated list.
7. The apparatus of claim 6, wherein the Gitdiff information includes a line number of modified or added code in a changed class of computer program code in the item;
The detection unit includes:
a screening subunit, configured to screen, in the class, computer program codes corresponding to the line numbers;
And the detection subunit is used for detecting the referenced function in the computer program code corresponding to the line number.
8. The apparatus of claim 6, wherein the detection report comprises at least one of: the outdated function, the line number of the outdated function in the computer program code of the item, the code screenshot of the class in which the outdated function is located, and the severity of the event referencing the outdated function in the class;
the output module includes:
The storage unit is used for storing the detection report in a preset file;
and the display unit is used for displaying the detection report.
9. An electronic device, the electronic device comprising:
A processor;
a memory for storing processor-executable instructions;
Wherein the processor is configured to perform the code processing method of any of claims 1-4.
10. A non-transitory computer readable storage medium, which when executed by a processor of an electronic device, causes the electronic device to perform the code processing method of any of claims 1-4.
CN202011629194.3A 2020-12-30 2020-12-30 Code processing method and device Active CN112612516B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011629194.3A CN112612516B (en) 2020-12-30 2020-12-30 Code processing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011629194.3A CN112612516B (en) 2020-12-30 2020-12-30 Code processing method and device

Publications (2)

Publication Number Publication Date
CN112612516A CN112612516A (en) 2021-04-06
CN112612516B true CN112612516B (en) 2024-05-03

Family

ID=75253095

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011629194.3A Active CN112612516B (en) 2020-12-30 2020-12-30 Code processing method and device

Country Status (1)

Country Link
CN (1) CN112612516B (en)

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2014112303A1 (en) * 2013-01-21 2014-07-24 日産自動車株式会社 Missed-data-update review device, missed-data-update review method, and missed-data-update review program
JP2014153777A (en) * 2013-02-05 2014-08-25 Tokyo Kogei Univ Source code inspection device
CN105677415A (en) * 2016-01-06 2016-06-15 网易(杭州)网络有限公司 Hot updating method and device
CN107292168A (en) * 2016-03-30 2017-10-24 阿里巴巴集团控股有限公司 Detect method and device, the server of program code
CN108932192A (en) * 2017-05-22 2018-12-04 南京大学 A kind of Python Program Type defect inspection method based on abstract syntax tree
CN109508204A (en) * 2018-11-15 2019-03-22 四川长虹电器股份有限公司 A kind of front-end code quality determining method and device
CN109918127A (en) * 2019-03-07 2019-06-21 扬州大学 A kind of defect error correction method based on code revision pattern differentials
CN110209568A (en) * 2018-04-24 2019-09-06 腾讯科技(深圳)有限公司 Coverage rate test method, apparatus and storage equipment
CN112100072A (en) * 2020-09-16 2020-12-18 广州虎牙科技有限公司 Static detection method, device, equipment and medium for application program codes
CN112148602A (en) * 2020-09-17 2020-12-29 云南电网有限责任公司信息中心 Source code security analysis method based on history optimization feature intelligent learning

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8370799B2 (en) * 2010-09-28 2013-02-05 International Business Machines Corporation Provision of code base modification using automatic learning of code changes
EP2829970B1 (en) * 2013-07-26 2017-02-01 Fujitsu Limited A method and apparatus for porting source code

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2014112303A1 (en) * 2013-01-21 2014-07-24 日産自動車株式会社 Missed-data-update review device, missed-data-update review method, and missed-data-update review program
JP2014153777A (en) * 2013-02-05 2014-08-25 Tokyo Kogei Univ Source code inspection device
CN105677415A (en) * 2016-01-06 2016-06-15 网易(杭州)网络有限公司 Hot updating method and device
CN107292168A (en) * 2016-03-30 2017-10-24 阿里巴巴集团控股有限公司 Detect method and device, the server of program code
CN108932192A (en) * 2017-05-22 2018-12-04 南京大学 A kind of Python Program Type defect inspection method based on abstract syntax tree
CN110209568A (en) * 2018-04-24 2019-09-06 腾讯科技(深圳)有限公司 Coverage rate test method, apparatus and storage equipment
CN109508204A (en) * 2018-11-15 2019-03-22 四川长虹电器股份有限公司 A kind of front-end code quality determining method and device
CN109918127A (en) * 2019-03-07 2019-06-21 扬州大学 A kind of defect error correction method based on code revision pattern differentials
CN112100072A (en) * 2020-09-16 2020-12-18 广州虎牙科技有限公司 Static detection method, device, equipment and medium for application program codes
CN112148602A (en) * 2020-09-17 2020-12-29 云南电网有限责任公司信息中心 Source code security analysis method based on history optimization feature intelligent learning

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
山金孝 等.《OpenShift云原生架构》.北京:机械工业出版社,2020,第261-262页. *
里欧·法尼尼 等.《 Red Hat Linux 6.1技术大全》.北京:北京希望电子出版社,2000,第203-204页. *

Also Published As

Publication number Publication date
CN112612516A (en) 2021-04-06

Similar Documents

Publication Publication Date Title
KR101770931B1 (en) Method, apparatus, program and computer-readable recording medium of generating communication module firmware and plug-in
CN107423106B (en) Method and apparatus for supporting multi-frame syntax
EP3089436A1 (en) Methods and devices for calling based on cloud card
CN107463372B (en) Data-driven page updating method and device
CN108153540B (en) System upgrading method, device, terminal and storage medium
CN116069612A (en) Abnormality positioning method and device and electronic equipment
CN112612516B (en) Code processing method and device
CN112333233B (en) Event information reporting method and device, electronic equipment and storage medium
CN106354595B (en) Mobile terminal, hardware component state detection method and device
CN110457084B (en) Loading method and device
CN113590091A (en) Data processing method and device, electronic equipment and storage medium
CN108427568B (en) User interface updating method and device
CN111597106A (en) Point burying management method and device
CN113946228A (en) Statement recommendation method and device, electronic equipment and readable storage medium
CN107766722B (en) Application software installation processing method and device and electronic equipment
CN111221593A (en) Dynamic loading method and device
CN113946346B (en) Data processing method and device, electronic equipment and storage medium
CN116450534B (en) Method, device, equipment and medium for generating mobile terminal application program
CN110990073B (en) Method and device for verifying customization requirements of application program
CN110995767B (en) Request processing method and device
CN114489641B (en) Data processing method and device, electronic equipment and storage medium
CN109726118B (en) Application program development method and device, electronic equipment and storage medium
CN111538486B (en) Layout file nesting layer number screening method and device and electronic equipment
CN112418276B (en) Classifier processing method and device
CN111767249B (en) Method and device for determining self-running time of function

Legal Events

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