Code detection method and device, equipment and storage medium

Through the code detection method based on the preset rule library, the problem of code irregularity is solved, the code quality and standardization is improved, and the development efficiency and quality are improved.

CN120066512APending Publication Date: 2025-05-30SHANGHAI IMILAB TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311617727.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-11-29
Publication Date
2025-05-30

AI Technical Summary

Technical Problem

During the writing process, the problem of irregular code may not cause problems in some application environments, but in other environments it will cause serious problems, and it is difficult for the existing technology to solve such problems efficiently.

Method used

Provide a code detection method, by obtaining the code to be detected, detecting based on the exception rules in the preset rule base, and generating prompt information to prompt the degree of abnormality of the exception information, helping developers to correct it in a timely manner.

Benefits of technology

This method can effectively improve the quality and standardization of code, improve the development efficiency and development quality of developers, and reduce the serious problems caused by code in specific environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120066512A_ABST
    Figure CN120066512A_ABST
Patent Text Reader

Abstract

The invention provides a code detection method and device, equipment and a storage medium. The method comprises the steps of obtaining a to-be-detected code; based on a target exception rule, detecting the to-be-detected code to obtain a target detection result; the target abnormal rule is one of a plurality of abnormal rules in a preset rule base; the target detection result is used for representing whether abnormal information exists in the to-be-detected code or not; when it is determined that abnormal information exists in the target detection result and the triggering condition of the target abnormal rule is met, prompt information is generated, and the prompt information is at least used for prompting the abnormal degree of the abnormal information.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technologies, and in particular, to a code detection method, apparatus, device, and storage medium. Background Art

[0002] During the process of writing code, problems such as non-standard code may occur; these non-standard codes may not cause problems in some application environments, but may cause serious problems in other application environments. Therefore, how to efficiently solve the problem of non-standard code is an urgent problem to be solved at present. Summary of the Invention

[0003] The present disclosure provides a code detection method, apparatus, device, and storage medium to solve or alleviate one or more technical problems in the prior art.

[0004] In a first aspect, the present disclosure provides a code detection method, including:

[0005] Obtaining the code to be detected;

[0006] Detecting the code to be detected based on a target exception rule to obtain a target detection result; the target exception rule is one of multiple exception rules in a preset rule library; the target detection result is used to indicate whether there is exception information in the code to be detected;

[0007] When it is determined that there is exception information in the target detection result and the trigger condition of the target exception rule is satisfied, generating a prompt information, where the prompt information is at least used to prompt the degree of exception of the exception information.

[0008] In a second aspect, the present disclosure provides a code detection apparatus, including:

[0009] An obtaining unit, configured to obtain the code to be detected;

[0010] A detection unit, configured to detect the code to be detected based on a target exception rule to obtain a target detection result; the target exception rule is one of multiple exception rules in a preset rule library; the target detection result is used to indicate whether there is exception information in the code to be detected;

[0011] A prompt generation unit, configured to generate a prompt information when it is determined that there is exception information in the target detection result and the trigger condition of the target exception rule is satisfied, where the prompt information is at least used to prompt the degree of exception of the exception information.

[0012] In a third aspect, there is provided an electronic device, including:

[0013] At least one processor; and

[0014] A memory communicatively connected to the at least one processor; wherein,

[0015] the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute any method in the embodiments of the present disclosure.

[0016] In a fourth aspect, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to cause the computer to execute any method in the embodiments of the present disclosure.

[0017] In a fifth aspect, a computer program product is provided, including a computer program which, when executed by a processor, implements any method in the embodiments of the present disclosure.

[0018] In this way, the solution of the present disclosure can detect the code to be detected based on a preset rule library, and generate a prompt message when a trigger condition is met, which is convenient for prompting the developer to correct it in time. In this way, the quality of the code written by the developer is greatly improved, and the written code is more standardized, thereby further improving the development efficiency and development quality of the developer.

[0019] It should be understood that the content described in this part is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it used to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. Description of the Drawings

[0020] In the drawings, unless otherwise specified, the same reference numerals throughout the several views denote the same or similar parts or elements. These drawings are not necessarily drawn to scale. It should be understood that these drawings only depict some embodiments provided in accordance with the present disclosure and should not be regarded as limiting the scope of the present disclosure.

[0021] Figure 1 is a schematic flowchart of a code detection method according to an embodiment of the present application Figure 1 ;

[0022] FIG. 2(a) is a schematic diagram of an application scenario of a code detection method according to an embodiment of the present application in Android studio;

[0023] FIG. 2(b) is a schematic diagram of the implementation of the underlying logic of a code detection method according to an embodiment of the present application in Android studio;

[0024] Figure 3 is a schematic diagram of the structure of a rule core module in an Android studio example according to an embodiment of the present application;

[0025] Figure 4 is a schematic flowchart of a code detection method according to an embodiment of the present application in an example;

[0026] Figure 5 is a schematic structural diagram of a code detection device according to an embodiment of the present application;

[0027] Figure 6 is a block diagram of an electronic device for implementing the code detection method according to an embodiment of the present disclosure. Detailed implementation manners

[0028] The present disclosure will be further described in detail below with reference to the accompanying drawings. The same reference numerals in the drawings denote elements having the same or similar functions. Although various aspects of the embodiments are shown in the drawings, the drawings are not necessarily drawn to scale unless otherwise specified.

[0029] In addition, for better illustration of the present disclosure, numerous specific details are given in the following detailed implementation manners. Those skilled in the art should understand that the present disclosure can still be implemented without some of these specific details. In some instances, methods, means, elements, and circuits well known to those skilled in the art are not described in detail so as to highlight the gist of the present disclosure.

[0030] During the process of writing code, everyone has their own writing style. Especially for novice developers with less experience, their understanding of the business logic of the code is not deep enough, and it is easy to write some incorrect code logics, which may lead to code not meeting the specification requirements; although these non-compliant codes do not cause problems in a normal environment, they directly cause serious problems in a specific environment.

[0031] For example, during software development, the general software release process is: development, self-testing, internal testing, and going live; in this process, there may be a large number of vulnerabilities (bugs) in the code written by developers, and most bugs will be discovered during self-testing and internal testing, but there are still a very small number of bugs that occur occasionally and have a very low probability, which will only be discovered after the software goes live and reaches a certain scale or a certain time point; to address the above problems, currently, it usually relies on the technical capabilities of developers or code review by managers to avoid bugs in the code. However, this method will increase the time cost of submitting and modifying code texts, seriously affecting the development efficiency and quality of developers.

[0032] Based on this, the present disclosure proposes a code detection method to solve the above technical problems.

[0033] Specifically, Figure 1 is a schematic process of a code detection method according to an embodiment of the present application Figure 1This method is optionally applied to electronic devices, such as personal computers, servers, server clusters and other electronic devices.

[0034] Furthermore, this method at least includes at least part of the following content. As Figure 1 shown, the code detection method includes:

[0035] Step S101: Obtain the code to be detected.

[0036] Here, in a specific example, the code to be detected can be obtained in the following way; specifically, the above-mentioned obtaining of the code to be detected (for example, the above-mentioned step S101) specifically includes:

[0037] When an editing operation is detected on the code page, the code corresponding to the current editing operation in the code page is used as the code to be detected.

[0038] For example, when a user performs an editing operation on a code page in a development tool, such as Android studio, the development tool or a third-party plugin will automatically obtain the code corresponding to the current editing operation and use it as the code to be detected. In this way, it is convenient to give real-time prompts for code specifications while the user is editing the code, thereby improving the quality of the code and at the same time improving the development efficiency of developers.

[0039] It should be noted that in practical applications, the obtaining method of the code to be detected can also be to receive the code text actively uploaded by the user, and the present disclosure scheme does not limit the obtaining method.

[0040] Step S102: Detect the code to be detected based on the target exception rule to obtain a target detection result.

[0041] Here, the target exception rule is one of multiple exception rules in the preset rule library; the target detection result is used to indicate whether there is abnormal information in the code to be detected.

[0042] Furthermore, the exception rules in the preset rule library can specifically be rules preset by the user in advance.

[0043] In a specific example, before detecting the code to be detected based on the target exception rule to obtain a target detection result, the following method can be used to obtain the exception rule related to the code to be detected, which specifically includes: matching the keyword identifiers in the code to be detected with the keyword identifiers corresponding to each exception rule in the preset rule library to obtain a matching result; based on the matching result, determining at least one target exception rule from multiple exception rules.

[0044] That is to say, in this example, during the process of detecting the code to be detected using the preset rule library, first, based on the keyword identifier in the code to be detected, at least one target exception rule related to the code to be detected is screened out from the preset rule library, and then the screened target exception rule is used to detect the code to be detected. For example, in one example, taking "setColor" in the code to be detected "Textview.setColor(R.color.white)" as the keyword identifier, the target exception rule related to "setColor" is screened out from the preset rule library, and then the screened target exception rule is used to detect the code to be detected.

[0045] Here, in practical applications, multiple exception rules in the preset rule library can also be classified to obtain the class identifiers of various exception rules, and the keyword identifier of the code to be detected is matched with the class identifiers of various exception rules in the preset rule library. Then, among the matched class exception rules, the target exception rule that matches the keyword identifier of the code to be detected is screened out. In this way, the target exception rule for detecting the code to be detected can be quickly obtained, and there is no need to screen in the full set of exception rules, thereby further improving the processing efficiency.

[0046] In this way, the solution of the present disclosure can screen out the target exception rule related to the code to be detected from the preset rule library based on the keyword identifier of the code to be detected. In this way, the detection of the code to be detected can be quickly completed, the detection efficiency of the code is improved, and real-time prompts can be given for the non-standard parts in the code, laying a foundation for improving the development efficiency of developers in the future.

[0047] Step S103: When it is determined that there is abnormal information in the target detection result and the triggering condition of the target exception rule is satisfied, a prompt message is generated.

[0048] Here, the prompt message is at least used to prompt the abnormal degree of the abnormal information. Here, the abnormal degree of the abnormal information refers to the degree of influence of the abnormal information on the normal operation or operation result of the code program. For example, if the influence degree of the abnormal information on the normal operation or operation result of the code program is small, the abnormal degree of the abnormal information is specifically "suggestion"; if the influence degree of the abnormal information on the normal operation or operation result of the code program is large, the abnormal degree of the abnormal information is "warning". If the abnormal information may cause the code program to fail to operate normally or the operation result to be incorrect, the abnormal degree of the abnormal information is "error", etc.

[0049] Further, in one example, the prompt information can also be specifically used to indicate the abnormal information and the description content of the abnormal information. For example, the abnormal information is "MISS:getResource:#", and the description content of the abnormal information is "The getResource function is missing, which may cause bugs and incorrect color values."

[0050] Further, in a specific example, the following method can be used to obtain the abnormal degree of the abnormal information. The specific method includes: when it is determined that there is abnormal information in the target detection result, based on the rule type of the target abnormal rule, obtain the abnormal degree of the abnormal information. For example, taking the abnormal rule 1 with the rule type of "error" as an example, if the code to be detected is detected to have the abnormal information in the abnormal rule 1, then the rule type of the abnormal rule 1 (that is, "error") is used as the abnormal degree of the abnormal information. At this time, the generated prompt information includes the abnormal information of the code to be detected and the abnormal degree of the abnormal information. In this way, it is convenient to attract the attention of developers to the non-standard parts in the code to be detected, so as to improve the standardization of the code, and further improve the development efficiency and quality of developers.

[0051] It should be noted that the corresponding relationship between the abnormal rule and the rule type can be specifically one-to-one or many-to-one, and the solution of the present disclosure does not limit this.

[0052] Further, in a specific example, the prompt information can be generated at the following different times. Specifically:

[0053] Method 1, that is, when it is determined that there is abnormal information in the target detection result and the trigger condition of the target abnormal rule is satisfied, generate the prompt information (for example, step S103 described above). Specifically, it includes:

[0054] When it is determined that there is at least one abnormal information in the target detection result, generate the prompt information for each abnormal information.

[0055] That is to say, in this example, whether there is one abnormal information or multiple abnormal information in the target detection result of the code to be detected, the corresponding prompt information is generated. In this way, the quality of the code written by developers is greatly improved, making the written code more standardized, and further improving the development efficiency and quality.

[0056] Method 2, that is, when it is determined that there is abnormal information in the target detection result and the trigger condition of the target abnormal rule is satisfied, generate the prompt information (for example, step S103 described above). Specifically, it includes:

[0057] When it is determined that there are multiple abnormal information in the target detection result and at least one of the following conditions is satisfied, a prompt message is generated:

[0058] Condition 1: It is determined that the abnormal information included in the target detection result is within the preset abnormal information range.

[0059] Condition 2: It is determined that the number of abnormal information included in the target detection result is greater than the preset threshold.

[0060] Here, the preset threshold can be set according to the actual needs of the user (such as developers), and the present disclosure does not specifically limit the setting of the preset threshold.

[0061] Condition 3: It is determined that the abnormal type of the abnormal information included in the target detection result is within the preset type range.

[0062] Here, the abnormal type of the abnormal information may specifically refer to the type of problem existing in the code to be detected in the abnormal information. For example, there are problems such as code missing and code redundancy.

[0063] Furthermore, in one example, the abnormal type of the abnormal information may also affect the abnormal degree of the abnormal information. For example, in one example, the abnormal degree of the abnormal information can also be obtained based on the rule type of the target abnormal rule and / or the abnormal type of the abnormal information.

[0064] Furthermore, when there is abnormal information in the target detection result and at least Condition 3 is satisfied, the generated prompt message may also include the abnormal type of the abnormal information. For example, it also prompts that there are problems such as code missing or code redundancy in the code to be detected.

[0065] Condition 4: It is determined that the abnormal degree of the abnormal information included in the target detection result is within the preset abnormal degree range.

[0066] Here, the above conditions in this example are only for illustrative purposes. In actual applications, developers can flexibly set the generation timing of the prompt message according to the importance of the abnormal information, so as to avoid possible important vulnerabilities in the code to be detected, and make the written code more standardized, thereby further improving the development efficiency and development quality of developers.

[0067] In this way, the present disclosure can detect the code to be detected based on the preset rule library and generate a prompt message when the trigger condition is satisfied, which is convenient for prompting developers to correct in time. In this way, the quality of the code written by developers is greatly improved, and the written code is more standardized, thereby further improving the development efficiency and development quality of developers.

[0068] In a specific example of the present disclosure solution, the following method can be used to update the preset rule library; specifically, it further includes:

[0069] Step S104: Generate at least one exception rule based on the expression specification requirements of the standard code.

[0070] Step S105: When it is determined that the at least one generated exception rule is not included in the preset rule library, update the preset rule library.

[0071] It should be noted that in this example, there is no restriction on the update timing of the preset rule library. For example, it can be updated regularly, or updated before detecting the code to be detected, etc. The present disclosure solution does not limit this.

[0072] In this way, the present disclosure solution provides a specific example for updating the preset rule library. In this way, the accuracy of code detection is greatly improved, and thus the code is more standardized and of high quality, laying a foundation for improving the development efficiency and development quality of developers in the future.

[0073] The following further illustrates the present disclosure solution with specific examples; the present disclosure solution proposes a code detection method. Specifically, based on the preset exception rules, the newly generated code content is detected and a prompt message is generated.

[0074] Specifically, taking the development tool Android studio as an example, during the development process of Android studio, by leveraging the plug-in development capabilities provided by Android studio, the method of the present disclosure solution can be integrated into Android studio in the form of a plug-in. For example, as shown in Figure 2(a), specifically, the exception rules in the plug-in container are used to detect the code to be detected. If it is detected that the code to be detected is not standardized, a prompt message is generated to prompt the developer.

[0075] Furthermore, Figure 2(b) is a schematic diagram of the implementation of the underlying logic of the above-mentioned plug-in, specifically including:

[0076] (1) Rule source module: used to construct or update the preset rule library; this rule source module contains the exception rules preset by the developer and the code corresponding to the exception rules.

[0077] (2) Rule type module: Classify multiple exception rules from the rule source module according to the preset exception degree of the preset exception information to obtain multiple rule types. The specific rule types are:

[0078] (a) Error (or fatal error): indicating that the code to be detected must be rectified, otherwise it cannot be compiled. At this time, it can be prompted in red.

[0079] (b) Reminder: It indicates that there are vulnerabilities (bugs) in the code to be detected that may cause problems. Specifically, it needs to be analyzed in combination with the code by yourself. At this time, orange can be used for reminder;

[0080] (c) Warning: It indicates that bugs in the code to be detected are found according to the previously summarized experience rules, and yellow can be used for reminder;

[0081] (d) Suggestion: It indicates a writing or naming that does not meet the industry's specification requirements. Although it will not cause problems, it is recommended to be consistent with the industry;

[0082] (e) Mandatory: It indicates a mandatory constraint made according to the actual situation (such as the business environment). This type of problem is not necessarily a bug.

[0083] It can be understood that the rule types in this example are only for illustrative purposes. In actual applications, they can be set according to actual needs, and the present disclosure solution does not make specific restrictions on this.

[0084] (3) Rule manager module: It is mainly used to manage source data and exception rules, and to notify user interface (UI) events, etc.

[0085] (4) Rule core module: It contains the core code of exception rules and is mainly used for the establishment and processing of all exception rules, or the parsing and adaptation of exception rule configurations. Specifically, as Figure 3 shown, it includes: a source code parsing layer for parsing source code files into code texts, and a core process protocol layer for accessing appropriate recognition protocols, such as accessing local recognition, cloud recognition and other protocols.

[0086] Furthermore, the local recognition function mainly uses the exception rules in the preset rule library to detect the code to be detected; the cloud recognition function mainly converts the source code text into binary data, transmits it to the cloud large model to obtain the recognition result, and finally returns the recognition result to the Rule core.

[0087] (5) Rule UI module: It is mainly used to control the page display and prompt in the development tool to refresh the UI.

[0088] It should be noted that in this example, the applicable scenario of the present disclosure solution can be specifically the Android system, or other systems, such as applicable to the IOS system. The present disclosure solution does not limit the applicable scenario.

[0089] In summary, the specific implementation process of the present disclosure solution is as follows Figure 4 shown and includes:

[0090] Step 1: Obtain the code to be detected.

[0091] Specifically, scan the code on the code page in Android studio to obtain the code to be detected. For example, obtain the code to be detected Textview.setColor(R.color.white). Or, in the case where an editing operation is detected on the code page in Android studio, the code corresponding to the current editing operation on the code page can be directly obtained, and the obtained code is used as the code to be detected.

[0092] It should be noted that if the obtained is a source code file, text parsing is performed on the source code file to obtain the code to be detected.

[0093] Step 2: Match the keyword identifier of the code to be detected with the keyword identifier corresponding to the exception rule in the preset rule library to obtain at least one target exception rule related to the code to be detected. For example, obtain the exception rule 1 related to the code to be detected. The exception rule 1 is as follows:

[0094]

[0095] Here, the fields in this exception rule 1 specifically include:

[0096] item: Used to represent an exception rule;

[0097] name: Used to represent the name of the exception rule 1. For example, the name of the exception rule 1 is "Textview waring" (i.e., text view warning);

[0098] desc: Used to represent the description information prompted to the developer. For example, the description information prompted to the developer in the exception rule 1 is "Lack of getResource may cause bugs and incorrect color values";

[0099] value: Used to represent the code that needs to be normatively detected (i.e., the code to be detected described above); "*" represents any wildcard character;

[0100] type: Used to represent the rule type of the exception rule, such as error, warning, suggestion, etc.;

[0101] condition: Used to represent the trigger condition, mainly used to trigger the generation of prompt information;

[0102] MISS: getResource:#: The main content of the trigger condition, where MISS is the keyword (i.e., the exception type described above, which can be denoted as "key"), here it represents "missing", "getResource" is the value corresponding to the keyword (which can be denoted as "value"), and "#" is the type of the value (which can be denoted as "valueType"), here it represents a function.

[0103] In addition, the trigger condition is also used to translate the abnormal situation that the developer wants to express into a language that the code can recognize. For example, "missing the getResource function" can be translated into a code language that can be understood at the code level, that is, "MISS: getResource:#".

[0104] Here, the expression form of the trigger condition in this example is "key: value: valueType". In actual applications, the expression form of the trigger condition can also be specifically "key-1: value-1 && key-2: value-2", such as "MISS: value-1 && Redundancy: value-2", which means that there is a problem of missing value-1 in the code to be detected, and value-2 in the code to be detected is redundant code. The present disclosure does not limit the expression form of the trigger condition.

[0105] Furthermore, the exception rules in the preset rule library can specifically be rules preset by users in advance, or generated based on the expression specification requirements of standard codes.

[0106] Step 3: Based on the target exception rule, detect the code to be detected to obtain a target detection result, and the target detection result is used to indicate whether there is abnormal information in the code to be detected.

[0107] Step 4: When it is determined that there is abnormal information in the target detection result and the trigger condition of the target exception rule is satisfied, generate a prompt message.

[0108] Here, the prompt message at least includes abnormal information, the exception type of the abnormal information, the exception degree of the abnormal information, and the description content of the abnormal information, etc.; in addition, different colors can also be highlighted according to the different exception degrees of the abnormal information.

[0109] Here, the trigger condition of the target exception rule includes at least one of the following conditions:

[0110] Condition 1: Determine that the abnormal information included in the target detection result is within the preset abnormal information range;

[0111] Condition 2: Determine that the number of abnormal information included in the target detection result is greater than the preset threshold;

[0112] Here, the preset threshold can be set according to the actual needs of users (such as developers), and the present disclosure does not specifically limit the setting of the preset threshold.

[0113] Condition 3: Determine that the exception type of the exception information included in the target detection result is within the preset type range;

[0114] Condition 4: Determine that the exception degree of the exception information included in the target detection result is within the preset exception degree range.

[0115] Here, regarding the relevant content of the exception type of the exception information and the exception degree of the exception information, reference can be made to the above example, and details are not elaborated here.

[0116] It can be understood that the above is only an exemplary illustration. In actual applications, the trigger conditions required for the detection of different codes are different, and the present disclosure does not specifically limit this.

[0117] Continuing with the code to be detected Textview.setColor(R.color.white) as an example, use exception rule 1 to detect the code to be detected to obtain the target detection result; here, the trigger condition of exception rule 1 is that the exception information in the target detection result is "MISS:getResource:#" (that is, corresponding to condition 1 described above); further, in the case of determining that there is exception information of missing the getResource function in the target detection result and satisfying condition 1 of exception rule 1, generate a prompt message for the code to be detected, and the prompt message is as follows:

[0118] (1) Color: yellow;

[0119] (2) Exception degree: warning;

[0120] (3) Exception type: MISS (code missing)

[0121] (4) Exception information: MISS:getResource:#

[0122] (5) Description content of the exception information: Missing the getResource function,

[0123] It may cause bugs and result in incorrect color values.

[0124] To sum up, compared with the prior art, the present disclosure has the following several advantages, specifically including:

[0125] First, the detection is more accurate. Compared with the prior art, the disclosed solution uses a preset rule library that can be flexibly set to detect the code to be detected, which is conducive to improving the accuracy of code detection, making the code more standardized, and thus improving the development efficiency and quality of developers.

[0126] Second, the diversity of prompt information. Compared with the prior art, the prompt information generated by the disclosed solution not only points out the abnormal information of the code to be detected, but also points out the importance of the abnormal information to the code program. For example, it prompts the degree of abnormality of the abnormal information (such as warning, suggestion, etc.). In this way, it can attract the attention of developers to the code to be detected and improve the standardization of the code.

[0127] Third, wide application range. The disclosed solution can be applied to development scenarios such as Android and IOS, with a wider application range.

[0128] The disclosed solution also provides a code detection device, as Figure 5 shown, including:

[0129] An acquisition unit 501, configured to acquire the code to be detected;

[0130] A detection unit 502, configured to detect the code to be detected based on a target exception rule to obtain a target detection result; the target exception rule is one of multiple exception rules in the preset rule library; the target detection result is used to indicate whether there is abnormal information in the code to be detected;

[0131] A prompt generation unit 503, configured to generate a prompt information when it is determined that there is abnormal information in the target detection result and the trigger condition of the target exception rule is satisfied, and the prompt information is at least used to prompt the degree of abnormality of the abnormal information.

[0132] In a specific example of the disclosed solution, the prompt generation unit is further configured to:

[0133] When it is determined that there is abnormal information in the target detection result, obtain the degree of abnormality of the abnormal information based on the rule type of the target exception rule.

[0134] In a specific example of the disclosed solution, the acquisition unit is specifically configured to:

[0135] When it is detected that an editing operation is performed on the code page, take the code corresponding to the current editing operation in the code page as the code to be detected.

[0136] In a specific example of the disclosed solution, the detection unit is further configured to:

[0137] Match the keyword identifiers in the code to be detected with the keyword identifiers corresponding to each exception rule in the preset rule library to obtain a matching result;

[0138] Based on the matching result, determine at least one target exception rule from multiple exception rules.

[0139] In a specific example of the present disclosure solution, the prompt generation unit is specifically configured to:

[0140] When it is determined that there is at least one exception message in the target detection result, generate a prompt message for each exception message.

[0141] In a specific example of the present disclosure solution, the prompt generation unit is specifically configured to:

[0142] When it is determined that there are multiple exception messages in the target detection result and at least one of the following conditions is met, generate a prompt message:

[0143] Determine that the exception message included in the target detection result is within the preset exception message range;

[0144] Determine that the number of exception messages included in the target detection result is greater than a preset threshold;

[0145] Determine that the exception type of the exception message included in the target detection result is within the preset type range;

[0146] Determine that the exception degree of the exception message included in the target detection result is within the preset exception degree range.

[0147] In a specific example of the present disclosure solution, it further includes: an update unit; wherein, the update unit is used to generate at least one exception rule based on the expression specification requirements of the standard code; when it is determined that the preset rule library does not include the at least one generated exception rule, update the preset rule library.

[0148] For the specific functions and example descriptions of the units of the device in the embodiments of the present disclosure, reference may be made to the relevant descriptions of the corresponding steps in the above method embodiments, which will not be elaborated here.

[0149] In the technical solution of the present disclosure, the acquisition, storage, and application of the user's personal information involved all comply with the provisions of relevant laws and regulations and do not violate public order and good customs.

[0150] Figure 6 It is a structural block diagram of an electronic device according to an embodiment of the present disclosure. As Figure 6As shown, the electronic device includes: a memory 610 and a processor 620. The memory 610 stores computer programs that can run on the processor 620. The number of the memory 610 and the processor 620 can be one or more. The memory 610 can store one or more computer programs. When the one or more computer programs are executed by the electronic device, the electronic device is caused to execute the methods provided in the foregoing method embodiments. The electronic device may further include: a communication interface 630, configured to communicate with external devices and perform data interaction and transmission.

[0151] If the memory 610, the processor 620, and the communication interface 630 are implemented independently, the memory 610, the processor 620, and the communication interface 630 can be interconnected through a bus and communicate with each other. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 6 only a thick line is shown in the figure, but it does not mean that there is only one bus or one type of bus.

[0152] Optionally, in a specific implementation, if the memory 610, the processor 620, and the communication interface 630 are integrated on a single chip, the memory 610, the processor 620, and the communication interface 630 can communicate with each other through an internal interface.

[0153] It should be understood that the foregoing processor can be a Central Processing Unit (CPU), or can also be other general-purpose processors, Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field Programmable Gate Arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor, etc. It is worth noting that the processor can be a processor that supports the Advanced RISC Machines (ARM) architecture.

[0154] Further, optionally, the above-mentioned memory may include a read-only memory and a random access memory, and may also include a non-volatile random access memory. The memory may be a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memories. Among them, the non-volatile memory may include a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may include a random access memory (RAM), which is used as an external cache. By way of example but not limitation, many forms of RAM are available. For example, static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchlink dynamic random access memory (SLDRAM), and direct rambus random access memory (DR RAM).

[0155] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer instructions are loaded and executed on a computer, the processes or functions described in the embodiments of the present disclosure are generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (such as coaxial cable, optical fiber, Digital Subscriber Line (DSL)) or wireless (such as infrared, Bluetooth, microwave, etc.) means. The computer-readable storage medium can be any available medium that can be accessed by a computer, or a data storage device such as a server or data center that includes one or more integrated available media. The available medium can be a magnetic medium (such as a floppy disk, hard disk, magnetic tape), an optical medium (such as a Digital Versatile Disc (DVD)), or a semiconductor medium (such as a Solid State Disk (SSD)), etc. It should be noted that the computer-readable storage medium mentioned in the present disclosure can be a non-volatile storage medium, in other words, a non-transitory storage medium.

[0156] Those of ordinary skill in the art can understand that all or part of the steps for implementing the above embodiments can be completed by hardware, or can be completed by a program instructing relevant hardware. The program can be stored in a computer-readable storage medium, and the storage medium mentioned above can be a read-only memory, a magnetic disk, an optical disc, etc.

[0157] In the description of the embodiments of the present disclosure, the descriptions referring to terms such as "one embodiment", "some embodiments", "example", "specific example", or "some examples" mean that the specific features, structures, materials, or characteristics described in connection with the embodiment or example are included in at least one embodiment or example of the present disclosure. Moreover, the specific features, structures, materials, or characteristics described can be combined in a suitable manner in any one or more embodiments or examples. In addition, without contradiction, those skilled in the art can combine and combine the different embodiments or examples described in this specification and the features of different embodiments or examples.

[0158] In the description of the embodiments of the present disclosure, unless otherwise specified, " / " means "or". For example, A / B may represent A or B. "And / or" herein is merely a description of the relationship between associated objects, indicating that there can be three relationships. For example, A and / or B may represent: A exists alone, A and B exist simultaneously, and B exists alone.

[0159] In the description of the embodiments of the present disclosure, the terms "first" and "second" are only used for descriptive purposes and cannot be construed as indicating or implying relative importance or implicitly specifying the quantity of the indicated technical features. Thus, features defined with "first" and "second" may explicitly or implicitly include one or more of such features. In the description of the embodiments of the present disclosure, unless otherwise specified, "a plurality of" means two or more.

[0160] The above are only exemplary embodiments of the present disclosure and are not intended to limit the present disclosure. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present disclosure shall be included within the protection scope of the present disclosure.

Claims

1. A code detection method, comprising: obtaining the code to be detected; detecting the code to be detected based on a target exception rule to obtain a target detection result; the target exception rule is one of multiple exception rules in a preset rule library; the target detection result is used to indicate whether there is exception information in the code to be detected; when it is determined that there is exception information in the target detection result and the trigger condition of the target exception rule is satisfied, generating a prompt information, where the prompt information is at least used to prompt the degree of exception of the exception information.

2. The method according to claim 1, further comprising: when it is determined that there is exception information in the target detection result, obtaining the degree of exception of the exception information based on the rule type of the target exception rule.

3. The method according to claim 1 or 2, wherein, the obtaining the code to be detected includes: when an edit operation is monitored on a code page, taking the code corresponding to the current edit operation in the code page as the code to be detected.

4. The method according to claim 1, wherein, before detecting the code to be detected based on a target exception rule to obtain a target detection result, further comprising: matching the keyword identifier in the code to be detected with the keyword identifiers corresponding to each exception rule in the preset rule library to obtain a matching result; based on the matching result, determining at least one target exception rule from multiple exception rules.

5. The method according to claim 1 or 2 or 4, wherein, the generating a prompt information when it is determined that there is exception information in the target detection result and the trigger condition of the target exception rule is satisfied includes: when it is determined that there is at least one exception information in the target detection result, generating a prompt information for each exception information.

6. The method according to claim 1 or 2 or 4, wherein, the generating a prompt information when it is determined that there is exception information in the target detection result and the trigger condition of the target exception rule is satisfied includes: when it is determined that there are multiple exception information in the target detection result and at least one of the following conditions is satisfied, generating a prompt information: determining that the exception information included in the target detection result is within a preset exception information range; determining that the number of exception information included in the target detection result is greater than a preset threshold; determining that the exception type of the exception information included in the target detection result is within a preset type range; determining that the degree of exception of the exception information included in the target detection result is within a preset exception degree range.

7. The method according to claim 1 or 2 or 4, further comprising: generating at least one exception rule based on the expression specification requirements of a standard code; when it is determined that the preset rule library does not include the at least one generated exception rule, updating the preset rule library.

8. A code detection device, comprising: an obtaining unit, configured to obtain the code to be detected; A detection unit, configured to detect the code to be detected based on a target exception rule, and obtain a target detection result; the target exception rule is one of multiple exception rules in a preset rule library; the target detection result is used to indicate whether there is exception information in the code to be detected; A prompt generation unit, configured to generate a prompt information when it is determined that there is exception information in the target detection result and the trigger condition of the target exception rule is satisfied, and the prompt information is at least used to prompt the degree of exception of the exception information.

9. The apparatus according to claim 8, wherein, the prompt generation unit is further configured to: when it is determined that there is exception information in the target detection result, obtain the degree of exception of the exception information based on the rule type of the target exception rule.

10. The apparatus according to claim 8 or 9, wherein, the obtaining unit is specifically configured to: when it is monitored that an editing operation is performed on a code page, use the code corresponding to the current editing operation in the code page as the code to be detected.

11. The apparatus according to claim 8, wherein, the detection unit is further configured to: match the keyword identifier in the code to be detected with the keyword identifiers corresponding to the respective exception rules in the preset rule library to obtain a matching result; based on the matching result, determine at least one target exception rule from multiple exception rules.

12. The apparatus according to claim 8 or 9 or 11, wherein, the prompt generation unit is specifically configured to: when it is determined that there is at least one exception information in the target detection result, generate a prompt information for each exception information.

13. The apparatus according to claim 8 or 9 or 11, wherein, the prompt generation unit is specifically configured to: generate a prompt information when it is determined that there are multiple exception information in the target detection result and at least one of the following conditions is satisfied: determine that the exception information included in the target detection result is within a preset exception information range; determine that the number of exception information included in the target detection result is greater than a preset threshold; determine that the exception type of the exception information included in the target detection result is within a preset type range; determine that the degree of exception of the exception information included in the target detection result is within a preset exception degree range.

14. The apparatus according to claim 8 or 9 or 11 further includes: an update unit; wherein, the update unit is configured to generate at least one exception rule based on the expression specification requirements of a standard code, and update the preset rule library when it is determined that the preset rule library does not include the at least one generated exception rule.

15. An electronic device, including: at least one processor; and a memory communicatively connected to the at least one processor; wherein, the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the method according to any one of claims 1-7.

16. A non-transitory computer-readable storage medium storing computer instructions, wherein, The computer instructions are for causing the computer to perform the method according to any one of claims 1-7.