CN111552640A - Code detection method, device, equipment and storage medium - Google Patents

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

Info

Publication number
CN111552640A
CN111552640A CN202010333281.8A CN202010333281A CN111552640A CN 111552640 A CN111552640 A CN 111552640A CN 202010333281 A CN202010333281 A CN 202010333281A CN 111552640 A CN111552640 A CN 111552640A
Authority
CN
China
Prior art keywords
code
detected
repaired
hard
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
CN202010333281.8A
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.)
Beijing ByteDance Network Technology Co Ltd
Original Assignee
Beijing ByteDance Network Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing ByteDance Network Technology Co Ltd filed Critical Beijing ByteDance Network Technology Co Ltd
Priority to CN202010333281.8A priority Critical patent/CN111552640A/en
Publication of CN111552640A publication Critical patent/CN111552640A/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

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)
  • User Interface Of Digital Computer (AREA)

Abstract

The embodiment of the disclosure discloses a code detection method, a device, equipment and a storage medium, wherein the method comprises the following steps: acquiring an original code, and extracting a code to be detected from the original code according to a detection condition; detecting the code to be detected, and judging whether the hard code to be repaired exists in the code to be detected; and if the to-be-repaired hard code exists in the to-be-detected code, acquiring the position information of the to-be-repaired hard code, and repairing the to-be-repaired hard code according to the position information. The code detection method provided by the embodiment of the invention selects the code to be detected for detection by setting the detection condition, avoids the inaccurate detection result caused by the code which does not need to be detected, and improves the detection speed and the detection efficiency.

Description

Code detection method, device, equipment and storage medium
Technical Field
The disclosed embodiments relate to the field of computer technologies, and in particular, to a code detection method, apparatus, device, and storage medium.
Background
With the rapid development of mobile internet technology, the demand for internationalization of application programs has increased. The internationalization of the application program means that the application program can display corresponding interfaces according to languages of different countries or regions without modifying internal codes, and errors which seriously affect the use do not occur.
When the application program is internationalized, the position of the hard code in the code needs to be found out and replaced by the key value of the corresponding internationalized language, so that when the application program is used by a user, the system can find the corresponding internationalized scheme and display the corresponding internationalized scheme on a page according to the system language and the key value set by the user. In order to ensure the accuracy of the application program after internationalization, after the hard code in the code is manually replaced, the replaced code needs to be detected to judge whether the hard code which is not replaced exists.
Currently, there are two methods for detecting codes: the method is characterized in that the condition that a user uses a system is simulated, the language of each page is switched, and whether the non-internationalized case exists or not is checked. Secondly, in some integrated development tools, the function of full-text search is used for detecting all codes. In the two modes, the detection method used in simulation has low efficiency and is easy to omit, and the method using full-text search detection has inaccurate full-text search judgment result due to the fact that codes contain other information.
Disclosure of Invention
The present disclosure provides a code detection method, apparatus, device and storage medium to achieve an improvement in code detection speed and detection efficiency.
In a first aspect, an embodiment of the present disclosure provides a code detection method, including:
acquiring an original code, and extracting a code to be detected from the original code according to a detection condition;
detecting the code to be detected, and judging whether the hard code to be repaired exists in the code to be detected;
and if the to-be-repaired hard code exists in the to-be-detected code, acquiring the position information of the to-be-repaired hard code, and repairing the to-be-repaired hard code according to the position information.
In a second aspect, an embodiment of the present disclosure further provides a code detection apparatus, including:
the code to be detected acquisition module is used for acquiring an original code and extracting the code to be detected from the original code according to a detection condition;
the code detection module is used for detecting the codes to be detected and judging whether the hard codes to be repaired exist in the codes to be detected;
and the position information acquisition module is used for acquiring the position information of the hard code to be repaired if the hard code to be repaired exists in the code to be detected so as to repair the hard code to be repaired according to the position information.
In a third aspect, an embodiment of the present disclosure further provides a computer device, where the computer device includes:
one or more processing devices;
storage means for storing one or more programs;
when the one or more programs are executed by the one or more processing devices, the one or more processing devices are caused to implement the code detection method provided by any embodiment of the present invention.
In a fourth aspect, the disclosed embodiments also provide a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the code detection method provided in any embodiment of the present invention.
According to the method and the device, the original code is obtained, and the code to be detected is extracted from the original code according to the detection condition; detecting the code to be detected, and judging whether the hard code to be repaired exists in the code to be detected; if the to-be-repaired hard code exists in the to-be-detected code, the position information of the to-be-repaired hard code is acquired so as to repair the to-be-repaired hard code according to the position information, and the code needing to be detected is selected for detection by setting a detection condition, so that the inaccuracy of a detection result caused by the code needing no detection is avoided, and the detection speed and the detection efficiency are improved.
Drawings
The above and other features, advantages and aspects of various embodiments of the present disclosure will become more apparent by referring to the following detailed description when taken in conjunction with the accompanying drawings. Throughout the drawings, the same or similar reference numbers refer to the same or similar elements. It should be understood that the drawings are schematic and that elements and features are not necessarily drawn to scale.
Fig. 1 is a flowchart of a code detection method according to an embodiment of the present disclosure;
fig. 2 is a flowchart of a code detection method according to a second embodiment of the disclosure;
fig. 3 is a schematic structural diagram of a code detection apparatus according to a third embodiment of the present disclosure;
fig. 4 is a schematic structural diagram of a computer device according to a fourth embodiment of the present disclosure.
Detailed Description
Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While certain embodiments of the present disclosure are shown in the drawings, it is to be understood that the present disclosure may be embodied in various forms and should not be construed as limited to the embodiments set forth herein, but rather are provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the disclosure are for illustration purposes only and are not intended to limit the scope of the disclosure.
It should be understood that the various steps recited in the method embodiments of the present disclosure may be performed in a different order, and/or performed in parallel. Moreover, method embodiments may include additional steps and/or omit performing the illustrated steps. The scope of the present disclosure is not limited in this respect.
The term "include" and variations thereof as used herein are open-ended, i.e., "including but not limited to". The term "based on" is "based, at least in part, on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". Relevant definitions for other terms will be given in the following description.
It should be noted that the terms "first", "second", and the like in the present disclosure are only used for distinguishing different devices, modules or units, and are not used for limiting the order or interdependence relationship of the functions performed by the devices, modules or units.
It is noted that references to "a", "an", and "the" modifications in this disclosure are intended to be illustrative rather than limiting, and that those skilled in the art will recognize that "one or more" may be used unless the context clearly dictates otherwise.
The names of messages or information exchanged between devices in the embodiments of the present disclosure are for illustrative purposes only, and are not intended to limit the scope of the messages or information.
In the following embodiments, optional features and examples are provided in each embodiment, and various features described in the embodiments may be combined to form a plurality of alternatives, and each numbered embodiment should not be regarded as only one technical solution.
Example one
Fig. 1 is a flowchart of a code detection method according to an embodiment of the present disclosure. The present embodiment is applicable to a case where the program code is detected after the application program is internationalized to determine whether unrepaired hard codes exist in the internationalized code, and the method may be executed by a code detection apparatus, where the code detection apparatus may be implemented in a software and/or hardware manner, and for example, the code detection apparatus may be configured in a terminal device. As shown in fig. 1, the method includes:
s110, acquiring an original code, and extracting a code to be detected from the original code according to a detection condition.
In this embodiment, the original code may be a program code after an application program is internationalized. Generally, application code may include annotations to code in addition to code for execution. In the embodiment, the content which does not need to be detected is filtered by skipping the information such as the comments and the like in the original code, the code to be detected which needs to be detected is extracted, and only the code to be detected which needs to be detected is detected, so that the detection speed is accelerated, and the detection accuracy is improved.
Optionally, a detection condition may be preset, and the detection condition is used to filter the original code to obtain the code to be detected in the original code. Wherein, the detection condition can be set according to the mode of adding the comment. For example, the detection condition may be to skip the annotation content in the original code, where the annotation content in the original code may be determined according to the annotation start identifier and/or the annotation end identifier, and if the annotation start identifier is "/", and the annotation end identifier is "/", the content between "/" and "/" in the original code is skipped, and the code other than the skipped content in the original code is regarded as the code to be detected.
For example, assume that the original code is "d _ w (j) ═ xite × e (k) × h (j); and (c) calculating the increment of the weight, outputting an error and an activation function according to the set parameters, skipping the content between the "/" and the "/", calculating the increment of the weight, outputting the error and the activation function according to the set parameters, and taking the code "d _ w (j) ═ xite & (j) ×" except the skipped content in the original code as the code to be detected.
In an embodiment of the present invention, the extracting, according to a detection condition, a code to be detected from the original code includes: dividing the original code into at least one split code; judging whether the segmentation codes contain preset skipping marks or not according to each segmentation code; if the segmentation code contains a preset skipping mark, determining a code to be detected contained in the segmentation code according to the skipping mark; and if the segmentation code does not contain a preset skipping mark, taking the segmentation code as the code to be detected.
Optionally, the original code may include multiple lines of code, and the original code may be divided into multiple split codes according to the lines of code. Illustratively, the original code is divided into a plurality of split codes according to the carriage return symbol, so that each split code corresponds to one line of codes in the original code. And judging whether the segmented codes contain preset skipping marks (such as the annotation starting marks and the annotation ending marks) or not for each segmented code, determining the skipping contents in the segmented codes according to the skipping marks when the segmented codes contain the preset skipping marks, taking the contents except the skipping contents in the segmented codes as codes to be detected, and taking all the contents of the segmented codes as the codes to be detected when the segmented codes do not contain the preset skipping marks.
It is understood that the skip flag is determined according to the annotation manner, and the skip flag may include a pair of flags or may be a single flag. Illustratively, assuming that "/" indicates the start of the annotation and "/" indicates the end of the annotation, the skip flag includes a pair of flags, that is, the skip flag includes "/" and "/", and the content between "/" and "/" is taken as the skip content; assuming that "//" indicates that the content is the annotation content from the position to the end of the line, the skip flag is a single flag, that is, the skip flag is "//", the content after "//" in the division code is taken as the skip content, that is, the content before "//" in the division code is taken as the code to be detected.
And S120, detecting the code to be detected, and judging whether the hard code to be repaired exists in the code to be detected.
In this embodiment, after the code to be detected that needs to be detected is extracted from the original code, the code to be detected is detected, and whether the hard code to be repaired exists in the code to be detected is determined. Hard coding is a software development practice that embeds data directly into the source code of a program or other executable object, as opposed to obtaining data externally or generating data at runtime.
It is to be understood that, when detecting a code to be detected, the hard code before replacement, i.e., the hard code to be repaired, is known. Optionally, whether the content matched with the hard code to be repaired exists or not can be searched for in the code to be detected, and when the content matched with the hard code to be repaired exists in the code to be detected, the existence of the hard code to be repaired in the code to be detected is indicated; and when the content matched with the hard code to be repaired does not exist in the code to be detected, the code to be detected shows that the hard code to be repaired does not exist.
Illustratively, if the hard code to be repaired is '10', whether the code to be detected has '10' is searched, if the code to be detected has '10', it indicates that the hard code to be repaired exists in the code to be detected, and if the code to be detected does not have '10', it indicates that the hard code to be repaired does not exist in the code to be detected.
In an implementation manner of the embodiment of the present invention, a regular expression may be used to detect a code to be detected, so as to determine whether a hard code to be repaired exists in the code to be detected. Regular expressions, also called regular expressions, use a single string to describe and match a series of strings that conform to a certain syntactic rule, and are commonly used to retrieve and replace text that conforms to a certain pattern (rule).
Optionally, the detecting the code to be detected and determining whether the hard code to be repaired exists in the code to be detected includes: and detecting the code to be detected according to a preset first regular expression, and judging whether the hard code to be repaired exists in the code to be detected. In this embodiment, a first regular expression may be generated according to the hard code to be repaired and the detection rule, and the code to be detected is matched according to the generated first regular expression, so as to find whether the code to be detected includes the hard code to be repaired.
S130, if the hard code to be repaired exists in the code to be detected, acquiring the position information of the hard code to be repaired, and repairing the hard code to be repaired according to the position information.
In this embodiment, if the hard code to be repaired is found in the code to be detected, the position information of the hard code to be repaired is obtained and recorded. Optionally, the location information of the hard code to be repaired may include a file path and a file name of a file to which the split code to be repaired belongs, and a number of lines of the split code to be repaired in the original code. The file path and the file name of the file to which the division code of the hard code to be restored belongs can be obtained through a calling interface, and the line number of the division code of the hard code to be restored in the original code can be determined according to the detection times. For example, when detecting the code to be detected, the number of lines where the split codes are located may be calculated according to the number of line feed carriage returns and the length of each split code. Optionally, after detecting all codes to be detected in the original code, counting recorded position information of all hard codes to be repaired, and generating a list for storage.
According to the method and the device, the original code is obtained, and the code to be detected is extracted from the original code according to the detection condition; detecting the code to be detected, and judging whether the hard code to be repaired exists in the code to be detected; if the to-be-repaired hard code exists in the to-be-detected code, the position information of the to-be-repaired hard code is acquired so as to repair the to-be-repaired hard code according to the position information, and the code needing to be detected is selected for detection by setting a detection condition, so that the inaccuracy of a detection result caused by the code needing no detection is avoided, and the detection speed and the detection efficiency are improved.
In this embodiment, after the location information of the hard code to be repaired is stored, the hard code to be repaired is repaired according to the location information of the hard code to be repaired. The method comprises the steps of firstly, restoring a hard code to be restored, wherein the step of restoring the hard code to be restored can be preset restoring logic, and automatically restoring the hard code to be restored according to the set restoring logic; or after the position information of the hard code to be repaired is displayed, the hard code to be repaired is repaired manually according to the position information of the hard code to be repaired.
On the basis of the scheme, the method further comprises the following steps: and repairing the hard code to be repaired according to a preset second regular expression and the position information of the hard code to be repaired. The regular expression can be used for replacing texts conforming to a certain mode (rule), a second regular expression for repairing the hard code to be repaired can be generated according to the replacement rule, and after the code to be detected contains the hard code to be repaired, the generated second regular expression is used for repairing the hard code to be repaired, so that the automatic repair of the hard code to be repaired is realized.
On the basis of the scheme, the method further comprises the following steps: and displaying the position information of the hard code to be repaired through a display device. In consideration of the fact that the hard code to be repaired is complex to repair, the regular expression is used for automatically repairing the logic complex, and the position information of the hard code to be repaired can be displayed through the display device, so that a user can repair the hard code to be repaired through the displayed position information of the hard code to be repaired.
On the basis of the scheme, the method further comprises the following steps: responding to a received hard coding repair request, and acquiring coding repair information contained in the hard coding repair request; and repairing the hard code to be repaired according to the code repairing information. After the position information of the hard code to be repaired is displayed through the display device, a user can trigger a hard code repair request through executing a repair action, and after the code detection device detects the hard code repair request triggered by the user, the hard code to be repaired is repaired according to the code repair information contained in the hard code request. And the hard code to be repaired is repaired in a manual repair mode, so that the repair of the hard code to be repaired is more accurate.
Example two
Fig. 2 is a flowchart of a code detection method according to a second embodiment of the disclosure. This embodiment may be combined with each of the alternatives in one or more of the embodiments described above. As shown in fig. 2, the method includes:
s210, traversing the directory files in the item to be detected according to the directory information of the item to be detected.
In this embodiment, the original code is embodied as a code in a directory file in the item to be detected. And sequentially detecting each directory file in the item to be detected, and judging whether the codes in each directory file contain the hard codes to be repaired.
In an embodiment of the present invention, traversing directory files in the item to be detected according to directory information of the item to be detected includes: and traversing the directory files in the item to be detected by using a depth-first search algorithm according to the directory information. In order to make the position information of the hard code to be repaired in the detection result conform to the reading habit of the code, a depth-first search algorithm can be used for traversing the directory files in the item to be detected. A depth first search algorithm is an algorithm for traversing or searching a tree or graph, traversing nodes of the tree along the depth of the tree, searching branches of the tree as deep as possible. And traversing the directory file by using a depth-first search algorithm, so that complete branches can be formed according to a traversal sequence, and further, a detection result after traversal does not need to be repaired across branches, and the reading habit of the code is met.
S220, judging whether the file type of the directory file is a candidate detection type or not aiming at each directory file.
It is contemplated that the directory file in the item to be detected may be a code file, a picture file, a font file, etc. It can be understood that the resources such as the picture file, the font file, and the like do not need to be detected, and the files which do not need to be detected can be determined according to the influence of the content contained in the directory on the internationalization, for example, the directory content under the node _ modules is a dependent package, which does not affect the internationalization of the application program, so that the files under the directory do not need to be detected. Optionally, the file type to be detected may be preset, or the file type not to be detected may be set, and whether the directory file is a candidate detection type is determined according to the preset file type.
For example, assuming that a file type to be detected is preset, it is determined whether the file type of the directory file matches the preset file type, if the file type of the directory file matches any one of the preset file types, it is determined that the file type of the directory file is a candidate detection type, and if the file type of the directory file does not match any one of the preset file types, it is determined that the file type of the directory file is not a candidate detection type.
If the file type of the directory file is not matched with any one of the preset file types, the file type of the directory file is judged to be not a candidate detection type, and if the file type of the directory file is not matched with the file type in the preset file type, the file type of the directory file is judged to be a candidate detection type.
And S230, if the file type of the directory file is the candidate detection type, acquiring a code in the directory file as the original code.
And when the file type of the directory file is in the candidate detection type, acquiring a code in the directory file as an original code, and detecting the code in the directory file.
And S240, extracting the code to be detected from the original code according to the detection condition.
And S250, detecting the code to be detected, and judging whether the hard code to be repaired exists in the code to be detected.
And S260, if the hard code to be repaired exists in the code to be detected, acquiring the position information of the hard code to be repaired, and repairing the hard code to be repaired according to the position information.
The method for acquiring the original code is embodied, and the directory file in the item to be detected is traversed according to the directory information of the item to be detected; judging whether the file type of the directory file is a candidate detection type or not aiming at each directory file; if the file type of the directory file is the candidate detection type, the code in the directory file is acquired as the original code, so that the directory file which does not need to be detected is skipped according to the file type, and the code detection speed is improved.
EXAMPLE III
Fig. 3 is a schematic structural diagram of a code detection apparatus according to a third embodiment of the present disclosure. The present embodiment is applicable to a case where PDF text is code-detected. The code detection device may be implemented in software and/or hardware, for example, the code detection device may be configured in a terminal device. As shown in fig. 3, the code detecting apparatus includes: a code acquisition module to be detected 310, a code detection module 320 and a position information acquisition module 330. Wherein:
the code to be detected acquisition module 310 is configured to acquire an original code and extract a code to be detected from the original code according to a detection condition;
the code detection module 320 is configured to detect the code to be detected and determine whether the hard code to be repaired exists in the code to be detected;
a position information obtaining module 330, configured to obtain position information of the to-be-repaired hard code if the to-be-repaired hard code exists in the to-be-detected code, so as to repair the to-be-repaired hard code according to the position information.
The method comprises the steps that an original code is obtained through a code obtaining module to be detected, and the code to be detected is extracted from the original code according to a detection condition; the code detection module detects the codes to be detected and judges whether the hard codes to be repaired exist in the codes to be detected; if the to-be-repaired hard code exists in the to-be-detected code, the position information acquisition module acquires the position information of the to-be-repaired hard code so as to repair the to-be-repaired hard code according to the position information, and selects the code to be detected to detect by setting a detection condition, so that the inaccuracy of a detection result caused by detecting the code which does not need to be detected is avoided, and the detection speed and the detection efficiency are improved.
Optionally, on the basis of the above technical solution, the to-be-detected code obtaining module 310 includes:
a code division unit for dividing the original code into at least one division code;
the identification judgment unit is used for judging whether the segmentation codes contain preset skipping identifications or not according to each segmentation code;
a code to be detected determination unit for: if the segmentation code contains a preset skipping mark, determining a code to be detected contained in the segmentation code according to the skipping mark;
and if the segmentation code does not contain a preset skipping mark, taking the segmentation code as the code to be detected.
Optionally, on the basis of the above technical solution, the to-be-detected code obtaining module 310 includes:
the directory traversal unit is used for traversing directory files in the item to be detected according to directory information of the item to be detected;
the type judging unit is used for judging whether the file type of the directory file is a candidate detection type or not aiming at each directory file;
and the code determining unit is used for acquiring the code in the directory file as the original code if the file type of the directory file is the candidate detection type.
Optionally, on the basis of the above technical solution, the directory traversal unit is specifically configured to:
and traversing the directory files in the item to be detected by using a depth-first search algorithm according to the directory information.
Optionally, on the basis of the foregoing technical solution, the code detection module 320 is specifically configured to:
and detecting the code to be detected according to a preset first regular expression, and judging whether the hard code to be repaired exists in the code to be detected.
Optionally, on the basis of the above technical solution, the apparatus further includes:
and the hard code repairing module is used for repairing the hard code to be repaired according to a preset second regular expression and the position information of the hard code to be repaired.
Optionally, on the basis of the above technical solution, the apparatus further includes:
and the repair position display module is used for displaying the position information of the hard code to be repaired through a display device.
Optionally, on the basis of the foregoing technical solution, the apparatus further includes a repair request response module, configured to:
responding to a received hard coding repair request, and acquiring coding repair information contained in the hard coding repair request;
and repairing the hard code to be repaired according to the code repairing information.
The code detection device provided by the embodiment of the disclosure can execute the code detection method provided by the embodiment of the disclosure, and has corresponding functional modules and beneficial effects of the execution method.
It should be noted that, the units and modules included in the apparatus are merely divided according to functional logic, but are not limited to the above division as long as the corresponding functions can be implemented; in addition, specific names of the functional units are only used for distinguishing one functional unit from another, and are not used for limiting the protection scope of the embodiments of the present disclosure.
Example four
Referring now to FIG. 4, shown is a schematic block diagram of a computer device 400 suitable for use in implementing embodiments of the present disclosure. The computer device in the embodiments of the present disclosure may include, but is not limited to, devices such as a mobile phone, a notebook computer, a digital broadcast receiver, a PDA (personal digital assistant), a PAD (tablet), a PMP (portable multimedia player), a vehicle terminal (e.g., a car navigation terminal), and the like. The computer device shown in fig. 4 is only an example and should not bring any limitation to the function and scope of use of the embodiments of the present disclosure.
As shown in fig. 4, the computer device 400 may include a processing means (e.g., a central processing unit, a graphics processor, etc.) 401 that may perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)402 or a program loaded from a storage means 406 into a Random Access Memory (RAM) 403. In the RAM 403, various programs and data necessary for the operation of the computer apparatus 400 are also stored. The processing device 401, the ROM 402, and the RAM 403 are connected to each other via a bus 404. An input/output (I/O) interface 405 is also connected to bus 404.
Generally, the following devices may be connected to the I/O interface 405: input devices 406 including, for example, a touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; an output device 407 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; storage devices 406 including, for example, magnetic tape, hard disk, etc.; and a communication device 409. The communication means 409 may allow the computer device 400 to communicate with other devices, either wirelessly or by wire, to exchange data. While fig. 4 illustrates a computer device 400 having various means, it is to be understood that not all illustrated means are required to be implemented or provided. More or fewer devices may alternatively be implemented or provided.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program carried on a non-transitory computer readable medium, the computer program containing program code for performing the method illustrated by the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network via the communication means 409, or from the storage means 406, or from the ROM 402. The computer program performs the above-described functions defined in the methods of the embodiments of the present disclosure when executed by the processing device 401.
It should be noted that the computer readable medium in the present disclosure can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In contrast, in the present disclosure, a computer readable signal medium may comprise a propagated data signal with computer readable program code embodied therein, either in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, optical cables, RF (radio frequency), etc., or any suitable combination of the foregoing.
In some embodiments, the clients, servers may communicate using any currently known or future developed network protocol, such as HTTP (HyperText transfer protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communications network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), the Internet (e.g., the Internet), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future developed network.
The computer readable medium may be embodied in the computer device; or may exist separately and not be incorporated into the computer device.
The computer readable medium carries one or more programs which, when executed by the computing device, cause the computing device to: acquiring an original code, and extracting a code to be detected from the original code according to a detection condition; detecting the code to be detected, and judging whether the hard code to be repaired exists in the code to be detected; and if the to-be-repaired hard code exists in the to-be-detected code, acquiring the position information of the to-be-repaired hard code, and repairing the to-be-repaired hard code according to the position information.
Computer program code for carrying out operations for the present disclosure may be written in any combination of one or more programming languages, including but not limited to an object oriented programming language such as Java, Smalltalk, C + +, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of methods, apparatus, computer devices, and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules and units described in the embodiments of the present disclosure may be implemented by software or hardware. For example, the module for acquiring the code to be detected may be described as a module for acquiring an original code and extracting the code to be detected from the original code according to a detection condition, and the directory traversal unit may be described as a module for traversing the directory file in the item to be detected according to the directory information of the item to be detected.
The functions described herein above may be performed, at least in part, by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field Programmable Gate Arrays (FPGAs), Application Specific Integrated Circuits (ASICs), Application Specific Standard Products (ASSPs), systems on a chip (SOCs), Complex Programmable Logic Devices (CPLDs), and the like.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
In accordance with one or more embodiments of the present disclosure, an example provides a code detection method, including:
acquiring an original code, and extracting a code to be detected from the original code according to a detection condition;
detecting the code to be detected, and judging whether the hard code to be repaired exists in the code to be detected;
and if the to-be-repaired hard code exists in the to-be-detected code, acquiring the position information of the to-be-repaired hard code, and repairing the to-be-repaired hard code according to the position information.
According to one or more embodiments of the present disclosure, example two provides a code detection method, and on the basis of the code detection method of example one, the extracting, according to a detection condition, a code to be detected from the original code includes:
dividing the original code into at least one split code;
judging whether the segmentation codes contain preset skipping marks or not according to each segmentation code;
if the segmentation code contains a preset skipping mark, determining a code to be detected contained in the segmentation code according to the skipping mark;
and if the segmentation code does not contain a preset skipping mark, taking the segmentation code as the code to be detected.
According to one or more embodiments of the present disclosure, example three provides a code detection method, and on the basis of the code detection method of example one, the acquiring an original code includes:
traversing directory files in the item to be detected according to directory information of the item to be detected;
judging whether the file type of the directory file is a candidate detection type or not aiming at each directory file;
and if the file type of the directory file is the candidate detection type, acquiring a code in the directory file as the original code.
According to one or more embodiments of the present disclosure, example four provides a code detection method, and on the basis of the code detection method of example three, traversing directory files in the item to be detected according to directory information of the item to be detected includes:
and traversing the directory files in the item to be detected by using a depth-first search algorithm according to the directory information.
According to one or more embodiments of the present disclosure, example five provides a code detection method, where on the basis of the code detection method of example one, the detecting the code to be detected and determining whether the hard code to be repaired exists in the code to be detected includes:
and detecting the code to be detected according to a preset first regular expression, and judging whether the hard code to be repaired exists in the code to be detected.
According to one or more embodiments of the present disclosure, example six provides a code detection method, and on the basis of the code detection method of example one, the method further includes:
and repairing the hard code to be repaired according to a preset second regular expression and the position information of the hard code to be repaired.
According to one or more embodiments of the present disclosure, example seven provides a code detection method, and on the basis of the code detection method of example one, the method further includes:
and displaying the position information of the hard code to be repaired through a display device.
Example eight provides a code detection method according to one or more embodiments of the present disclosure, and on the basis of the code detection method of example seven, the method further includes:
responding to a received hard coding repair request, and acquiring coding repair information contained in the hard coding repair request;
and repairing the hard code to be repaired according to the code repairing information.
Example nine provides, in accordance with one or more embodiments of the present disclosure, a code detection apparatus, comprising:
the code to be detected acquisition module is used for acquiring an original code and extracting the code to be detected from the original code according to a detection condition;
the code detection module is used for detecting the codes to be detected and judging whether the hard codes to be repaired exist in the codes to be detected;
and the position information acquisition module is used for acquiring the position information of the hard code to be repaired if the hard code to be repaired exists in the code to be detected so as to repair the hard code to be repaired according to the position information.
Example ten provides, in accordance with one or more embodiments of the present disclosure, a computer device comprising:
one or more processing devices;
storage means for storing one or more programs;
when executed by the one or more processing devices, cause the one or more processing devices to implement the code detection method of any of examples one to seven.
Example eleven provides a computer-readable storage medium having stored thereon a computer program that, when executed by a processor, implements a code detection method as recited in any one of examples one to seven.
The foregoing description is only exemplary of the preferred embodiments of the disclosure and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the disclosure herein is not limited to the particular combination of features described above, but also encompasses other embodiments in which any combination of the features described above or their equivalents does not depart from the spirit of the disclosure. For example, the above features and (but not limited to) the features disclosed in this disclosure having similar functions are replaced with each other to form the technical solution.
Further, while operations are depicted in a particular order, this should not be understood as requiring that such operations be performed in the particular order shown or in sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Likewise, while several specific implementation details are included in the above discussion, these should not be construed as limitations on the scope of the disclosure. Certain features that are described in the context of separate embodiments can also be implemented in combination in a single embodiment. Conversely, various features that are described in the context of a single embodiment can also be implemented in multiple embodiments separately or in any suitable subcombination.
Although the subject matter has been described in language specific to structural features and/or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are disclosed as example forms of implementing the claims.

Claims (11)

1. A code detection method, comprising:
acquiring an original code, and extracting a code to be detected from the original code according to a detection condition;
detecting the code to be detected, and judging whether the hard code to be repaired exists in the code to be detected;
and if the to-be-repaired hard code exists in the to-be-detected code, acquiring the position information of the to-be-repaired hard code, and repairing the to-be-repaired hard code according to the position information.
2. The method according to claim 1, wherein the extracting the code to be detected from the original code according to the detection condition comprises:
dividing the original code into at least one split code;
judging whether the segmentation codes contain preset skipping marks or not according to each segmentation code;
if the segmentation code contains a preset skipping mark, determining a code to be detected contained in the segmentation code according to the skipping mark;
and if the segmentation code does not contain a preset skipping mark, taking the segmentation code as the code to be detected.
3. The method of claim 1, wherein obtaining the original code comprises:
traversing directory files in the item to be detected according to directory information of the item to be detected;
judging whether the file type of the directory file is a candidate detection type or not aiming at each directory file;
and if the file type of the directory file is the candidate detection type, acquiring a code in the directory file as the original code.
4. The method of claim 3, wherein traversing directory files in the item to be detected according to directory information of the item to be detected comprises:
and traversing the directory files in the item to be detected by using a depth-first search algorithm according to the directory information.
5. The method according to claim 1, wherein the detecting the code to be detected and determining whether the hard code to be repaired exists in the code to be detected comprises:
and detecting the code to be detected according to a preset first regular expression, and judging whether the hard code to be repaired exists in the code to be detected.
6. The method of claim 1, further comprising:
and repairing the hard code to be repaired according to a preset second regular expression and the position information of the hard code to be repaired.
7. The method of claim 1, further comprising:
and displaying the position information of the hard code to be repaired through a display device.
8. The method of claim 7, further comprising:
responding to a received hard coding repair request, and acquiring coding repair information contained in the hard coding repair request;
and repairing the hard code to be repaired according to the code repairing information.
9. A code detection apparatus, comprising:
the code to be detected acquisition module is used for acquiring an original code and extracting the code to be detected from the original code according to a detection condition;
the code detection module is used for detecting the codes to be detected and judging whether the hard codes to be repaired exist in the codes to be detected;
and the position information acquisition module is used for acquiring the position information of the hard code to be repaired if the hard code to be repaired exists in the code to be detected so as to repair the hard code to be repaired according to the position information.
10. A computer device, characterized in that the computer device comprises:
one or more processing devices;
storage means for storing one or more programs;
when executed by the one or more processing devices, cause the one or more processing devices to implement the code detection method of any of claims 1-8.
11. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the code detection method according to any one of claims 1 to 8.
CN202010333281.8A 2020-04-24 2020-04-24 Code detection method, device, equipment and storage medium Pending CN111552640A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010333281.8A CN111552640A (en) 2020-04-24 2020-04-24 Code detection method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010333281.8A CN111552640A (en) 2020-04-24 2020-04-24 Code detection method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN111552640A true CN111552640A (en) 2020-08-18

Family

ID=72003914

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010333281.8A Pending CN111552640A (en) 2020-04-24 2020-04-24 Code detection method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN111552640A (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112486490A (en) * 2020-12-15 2021-03-12 平安银行股份有限公司 Front-end code packaging method and device, electronic equipment and storage medium
CN112631894A (en) * 2020-12-02 2021-04-09 北京健康之家科技有限公司 Code detection method, device, storage medium and computer equipment
CN115757181A (en) * 2022-12-05 2023-03-07 飞狐信息技术(天津)有限公司 Code detection method, device and equipment and readable storage medium
CN116346509A (en) * 2023-06-01 2023-06-27 北京比瓴科技有限公司 Hard coding certificate detection method, system, equipment and readable storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
RANJANKUMAR03: "HardCodeDetectorAPI" *

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112631894A (en) * 2020-12-02 2021-04-09 北京健康之家科技有限公司 Code detection method, device, storage medium and computer equipment
CN112486490A (en) * 2020-12-15 2021-03-12 平安银行股份有限公司 Front-end code packaging method and device, electronic equipment and storage medium
CN112486490B (en) * 2020-12-15 2024-03-19 平安银行股份有限公司 Front-end code packaging method and device, electronic equipment and storage medium
CN115757181A (en) * 2022-12-05 2023-03-07 飞狐信息技术(天津)有限公司 Code detection method, device and equipment and readable storage medium
CN115757181B (en) * 2022-12-05 2023-05-16 飞狐信息技术(天津)有限公司 Code detection method, device, equipment and readable storage medium
CN116346509A (en) * 2023-06-01 2023-06-27 北京比瓴科技有限公司 Hard coding certificate detection method, system, equipment and readable storage medium
CN116346509B (en) * 2023-06-01 2023-08-15 北京比瓴科技有限公司 Hard coding certificate detection method, system, equipment and readable storage medium

Similar Documents

Publication Publication Date Title
CN111552640A (en) Code detection method, device, equipment and storage medium
CN114422267B (en) Flow detection method, device, equipment and medium
CN110969012A (en) Text error correction method and device, storage medium and electronic equipment
CN106959976B (en) Search processing method and device
CN110781658B (en) Resume analysis method, resume analysis device, electronic equipment and storage medium
CN111597107B (en) Information output method and device and electronic equipment
CN113407767A (en) Method and device for determining text relevance, readable medium and electronic equipment
CN111241823A (en) Dependency configuration management method and device, electronic equipment and storage medium
CN110895587B (en) Method and device for determining target user
CN113971400B (en) Text detection method and device, electronic equipment and storage medium
CN111124541A (en) Configuration file generation method, device, equipment and medium
CN111339776B (en) Resume parsing method and device, electronic equipment and computer-readable storage medium
CN115618808A (en) Document typesetting method and device, electronic equipment and storage medium
CN115729797A (en) Code similarity function detection method and device, electronic equipment and storage medium
CN111737571B (en) Searching method and device and electronic equipment
CN110543243B (en) Data processing method, device, equipment and storage medium
CN112148751B (en) Method and device for querying data
CN113051400A (en) Method and device for determining annotation data, readable medium and electronic equipment
CN111737040A (en) Program code repairing method and device
CN115495469B (en) Method and device for updating chart file and electronic equipment
CN117743555B (en) Reply decision information transmission method, device, equipment and computer readable medium
CN117235744B (en) Source file online method, device, electronic equipment and computer readable medium
CN114492413B (en) Text proofreading method and device and electronic equipment
CN113760834B (en) File classification method, device, equipment and medium
CN113032808B (en) Data processing method and device, readable medium 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