CN113495835A - Code checking method and device, computer equipment and storage medium - Google Patents

Code checking method and device, computer equipment and storage medium Download PDF

Info

Publication number
CN113495835A
CN113495835A CN202010264603.8A CN202010264603A CN113495835A CN 113495835 A CN113495835 A CN 113495835A CN 202010264603 A CN202010264603 A CN 202010264603A CN 113495835 A CN113495835 A CN 113495835A
Authority
CN
China
Prior art keywords
verification
result
code
check
parameter
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
CN202010264603.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.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen 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 Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN202010264603.8A priority Critical patent/CN113495835A/en
Publication of CN113495835A publication Critical patent/CN113495835A/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/3604Software analysis for verifying properties of programs
    • G06F11/3608Software analysis for verifying properties of programs using formal methods, e.g. model checking, abstract interpretation

Landscapes

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

Abstract

The application relates to a code checking method, a code checking device, computer equipment and a storage medium. The method comprises the following steps: displaying an interface code on an interface; responding to the trigger operation of the interface code, and carrying out code style verification on the interface code according to a preset style verification rule to obtain a verification result; and displaying a verification report, wherein the verification report is generated according to the verification result. By adopting the method, the error rate of the submitted code can be reduced.

Description

Code checking method and device, computer equipment and storage medium
Technical Field
The present application relates to the field of computer technologies, and in particular, to a code checking method and apparatus, a computer device, and a storage medium.
Background
Some errors are inevitable when developers write code in computer languages. The developer will compile the code, and the compiler will prompt syntax errors in the code after compiling. The traditional code checking method can check out syntax errors, but cannot check out other code errors, so that the submitted code has high error rate.
Disclosure of Invention
In view of the above, it is desirable to provide a code verification method, apparatus, computer device and storage medium capable of reducing a code error rate in response to the above technical problems.
A method of code verification, the method comprising:
displaying an interface code on an interface;
responding to the trigger operation of the interface code, and carrying out code style verification on the interface code according to a preset style verification rule to obtain a verification result;
and displaying a verification report, wherein the verification report is generated according to the verification result.
A code verification apparatus, the apparatus comprising:
the first display module is used for displaying the interface code on the interface;
the checking module is used for responding to the triggering operation of the interface code and carrying out code style checking on the interface code according to a preset style checking rule to obtain a checking result;
and the second display module is used for displaying a verification report, and the verification report is generated according to the verification result.
In one embodiment, the check module is configured to perform at least one of a uniform resource locator check, a parameter check, a paging check, and a version check on the interface code according to a preset style check rule to obtain a check result.
In one embodiment, the check module is used for determining a uniform resource locator in the interface code; performing word segmentation processing on the uniform resource locator to obtain a target word; and checking the part of speech of the target word to obtain a resource locator checking result.
In one embodiment, the second display module is configured to display a verification report, where the verification report is generated according to a resource locator verification result, where the verification report includes a first resource locator verification result, and the first resource locator verification result is error information related to terms that are all non-nouns.
In one embodiment, the second display module is configured to display the verification report. The verification module is used for determining an operation instruction corresponding to the uniform resource locator when the resource locator verification result is a second resource locator verification result, wherein the second resource locator verification result is error information related to verbs contained in parts of speech; and when the operation instruction is not the preset operation instruction, generating a verification report according to the verification result of the second resource locator, wherein the verification report comprises the verification result of the second resource locator.
In one embodiment, the checking module is used for acquiring each reference parameter identifier and reference parameter description in the database; detecting a target parameter identification and a corresponding target parameter description in an interface code; and determining a first similarity between the target parameter identifier and each reference parameter identifier, and determining a second similarity between the target parameter description and each corresponding reference parameter description to obtain a parameter similarity checking result. The second display module is used for displaying a verification report, wherein the verification report is generated according to a parameter similarity verification result, the verification report comprises a first parameter similarity verification result, and the first parameter similarity verification result comprises error information related to the fact that both the first similarity and the corresponding second similarity reach a similarity threshold.
In one embodiment, the checking module is used for detecting the target parameter identification in the interface code; and checking the target parameter identification according to the words in the dictionary library to obtain a parameter word checking result. The second display module is used for displaying a verification report, wherein the verification report is generated according to the parameter word verification result, the verification report comprises a first parameter word verification result, and the first parameter word verification result is error information related to the target parameter identification spelling error.
In one embodiment, the check module is used for determining a read interface related instruction in the interface code; acquiring a reference paging parameter identifier; and verifying the related instruction of the read interface according to the reference paging parameter identifier to obtain a paging verification result. The second display module is used for displaying a check report, wherein the check report is generated according to the paging check result, the check report comprises a first paging check result, and the first paging check result is error information which is related to the instruction related to the read interface and does not contain the reference paging parameter identifier.
In one embodiment, the checking module is used for acquiring a history version number and a target version number corresponding to the interface code; and carrying out version verification on the target version number according to the historical version number to obtain a version number verification result. The second display module is used for displaying a verification report, and the verification report is generated according to a version number verification result, wherein the verification report comprises a first version number verification result, and the first version number verification result is error information related to version number conflict.
In one embodiment, the code verification apparatus further comprises a review module. The evaluation module is used for sending the interface code to a target terminal where the account with evaluation authority is located when the check report does not contain error information; receiving a review result returned by the target terminal, wherein the review result is obtained after the interface code is reviewed; and when the evaluation result is that the interface code passes, generating an interface code file corresponding to the interface code.
A computer device comprising a memory and a processor, the memory storing a computer program, the processor implementing the following steps when executing the computer program:
displaying an interface code on an interface;
responding to the trigger operation of the interface code, and carrying out code style verification on the interface code according to a preset style verification rule to obtain a verification result;
and displaying a verification report, wherein the verification report is generated according to the verification result.
A computer-readable storage medium, on which a computer program is stored which, when executed by a processor, carries out the steps of:
displaying an interface code on an interface;
responding to the trigger operation of the interface code, and carrying out code style verification on the interface code according to a preset style verification rule to obtain a verification result;
and displaying a verification report, wherein the verification report is generated according to the verification result.
According to the code checking method, the code checking device, the computer equipment and the storage medium, the interface code is displayed on the interface, the code style checking is carried out on the interface code according to the preset style checking rule by responding to the triggering operation of the interface code, the checking result is obtained, and the checking report is displayed, wherein the checking report is generated according to the checking result, and the code style checking can be carried out on the interface code, so that the code is more in line with the compiling specification, the error rate of the submitted code is reduced, the manual checking work is reduced, the checking accuracy is improved, the code is more in line with the preset code style, the interface code in line with the preset code style is more easily called, and the readability of the interface code is improved.
Drawings
FIG. 1 is a flow diagram illustrating a code verification method according to one embodiment;
FIG. 2 is an interface diagram of a merge request interface, under an embodiment;
FIG. 3 is a schematic diagram of an interface for verification reporting in one embodiment;
FIG. 4 is a block diagram of a process for verifying an interface code according to one embodiment;
FIG. 5 is a flow diagram illustrating a check of a uniform resource locator in one embodiment;
FIG. 6 is a flowchart illustrating a process for verifying parameters of an interface code according to predefined style verification rules according to an embodiment;
FIG. 7 is a schematic diagram of an interface for initiating a review in one embodiment;
FIG. 8 is a timing diagram of a code verification method in one embodiment;
FIG. 9 is a block diagram showing the structure of a code verifying apparatus according to an embodiment;
FIG. 10 is a diagram showing an internal structure of a computer device according to an embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
In one embodiment, as shown in fig. 1, a flowchart of a code verification method in one embodiment is shown. The embodiment is illustrated by applying the method to a terminal, and it can be understood that the method can also be applied to a server, and can also be applied to a system comprising the terminal and the server, and is implemented by interaction between the terminal and the server. The code checking method can be realized through a code checking program. Similarly, the code checking program can be applied to the terminal, the server and a system comprising the terminal and the server, and is realized through the interaction of the terminal and the server. The terminal can be, but is not limited to, various personal computers, notebook computers, smart phones, tablet computers and portable wearable devices, and the server can be implemented by an independent server or a server cluster formed by a plurality of servers. The method comprises the following steps:
step 102, displaying an interface code on an interface.
The interface code refers to a code related to a software interface. The Interface code may specifically be API (Application Programming Interface) code for enabling an Application or computer device to have the ability to access routines without accessing the source code or understanding internal working mechanisms.
Specifically, an interface code may be displayed on an interface of the terminal. The terminal can hide the code in the interface, and display the code on the interface by triggering the relevant operations of 'browsing the code' and the like of the interface.
In this embodiment, as shown in fig. 2, an interface schematic diagram of a merge request interface in one embodiment is shown. The interface includes a source branch and a target branch. The source branch comprises the code of the source branch of the interface, and the target branch is the code of the interface to be checked. Interface code can be displayed on the interface through a "browse code" control on the interface. The "compare two branches" control is a basic function of the git repository to compare the differences between the two branches.
And 104, responding to the trigger operation of the interface code, and carrying out code style verification on the interface code according to a preset style verification rule to obtain a verification result.
Wherein the triggering operation is used for triggering code style verification of the interface code. The trigger operation may specifically refer to a code check operation, a code commit operation, a merge request, and the like, but is not limited thereto. The preset style check rule is used for checking whether the interface code accords with a preset style. The preset style is a software architecture style and provides a set of design principles and constraints. For example, the preset style may be a restful style, and the like, but is not limited thereto, and software designed based on this style may be simpler, have a higher hierarchy, and be easier to implement mechanisms such as caching.
Specifically, the code verification program responds to a trigger operation on the interface code on the interface, and the trigger operation is used for instructing the terminal to perform code style verification on the interface code according to a preset style verification rule to obtain a verification result. The check result may include a correct result and an incorrect result. The correct result may be used to indicate that the whole interface code is error-free, or that a certain part of the interface code is error-free, or that the error number is 0, etc., but is not limited thereto. The error result is used for indicating that an error occurs in the interface code, and the error result may include at least one of an error name, a non-compliant style check rule, an error path, and an illegal value.
In this embodiment, the code style verification of the interface code according to the preset style verification rule may also be implemented on the server.
And 106, displaying a verification report, wherein the verification report is generated according to the verification result.
Wherein, the check report is used for indicating the check result of the interface code.
Specifically, the code verification program generates a verification report according to the verification result. And the code checking program displays a checking report on an interface of the terminal.
In this embodiment, as shown in fig. 3, an interface schematic diagram of a verification report in one embodiment is shown. The verification report is displayed on the interface after responding to the triggering operation of the interface code. The check report includes check types, wherein the check types include Schema check, Openapi generation check, and semantic check (i.e., code style check). I.e. the trigger operation can also be used to trigger a syntax check on the interface code. Syntax checks such as Schema check and Openapi generation check in the figure. The "semantic check" in the figure is a code style check, and the suggested number is a suspected error, and there are 43 points in the figure. The error information includes a non-compliant rule, an error path, and an illegal value corresponding to each check type. In the figure, no error occurs through Schema check and Openapi Generation check, and the semantic check (i.e. code style check) comprises error information. The error information is that the interface name is illegal, and the non-compliant semantic rule (i.e. code style check rule) is that the interface name does not contain the following verb. The error path and illegal values are also shown in the interface.
According to the code checking method, the interface code is displayed on the interface, the code style checking is carried out on the interface code according to the preset style checking rule by responding to the triggering operation of the interface code, the checking result is obtained, and the checking report is displayed, wherein the checking report is generated according to the checking result, and the code style checking can be carried out on the interface code, so that the code is more in line with the compiling specification, the error rate of the submitted code is reduced, the manual checking work is reduced, the checking accuracy is improved, the code is more in line with the preset code style, the interface code in line with the preset code style is more easily called, and the readability of the interface code is improved.
In one embodiment, performing code style check on the interface code according to a preset style check rule to obtain a check result, includes: and performing at least one of uniform resource locator verification, parameter verification, paging verification and version verification on the interface code according to a preset style verification rule to obtain a verification result.
Specifically, as shown in fig. 4, a block diagram of a process for verifying an interface code in one embodiment is shown. Including syntax checking, version checking, uniform resource locator checking (URL checking), parameter checking, and paging checking.
For example, the preset style may be a REST (Representational State Transfer) style, also referred to as a RESTful style, or a SOAP (Simple Object Access Protocol), and the like, but is not limited thereto. The Restful style content may include, but is not limited to, nouns necessary in the uniform resource locator, operation instructions corresponding to verbs included in the uniform resource locator are preset operation instructions, target parameter identifiers are reference parameter identifiers in the database, target parameter descriptions are reference parameter descriptions in the database, the target parameter identifiers are spelled correctly, page parameters are necessary in the read interface related instructions, and version numbers do not conflict. Then, the preset style check rule is a check rule set according to a preset style.
The RESTful style may facilitate different software or programs to communicate information with each other over a network, such as the internet. Presentation layer state transitions are a set of constraints and attributes determined based on the hypertext transfer protocol (HTTP), a software build style that provides web services. Presentation level state transitions are used to perform resource interactions between networked computing systems.
A Uniform Resource Locator (URL) is a representation of the location and access method of a Resource that is available from the internet. For example, a web address is a uniform resource locator. And the code checking program determines the uniform resource locator in the interface code and checks the uniform resource locator according to a uniform resource locator checking rule in the preset style checking rule to obtain a uniform resource locator checking result.
The parameter is a variable in the interface code, and the parameter may specifically refer to at least one of a parameter identifier, a parameter value, and a parameter description. The code checking program can carry out parameter checking on the interface code according to a parameter checking rule in the code style checking rule. The parameter check may specifically check whether the parameter identifier conforms to the syntax, whether the parameter identifier is a parameter identifier in the database, whether the parameter value conforms to the standard, or the like, but is not limited thereto.
The page check may specifically be checking a page number of a page, a page size, and the like, but is not limited thereto. The code checking program can carry out paging check on the interface code according to a paging check rule in the code style check rule. For example, the code checking program checks whether the interface code includes a paging parameter, whether the paging page number exceeds a page number threshold, whether the page size exceeds a page size threshold, and the like, but is not limited thereto.
And the version check, namely a code check program checks the target version number of the interface code. The code checking program can check the version of the interface code according to the paging checking rule in the code style checking rule. For example, whether the target version number conforms to a preset sequence, whether the target version number conflicts with the historical version number, and the like can be checked.
The check result includes at least one of a uniform resource locator check result, a parameter check result, a paging check result, and a version check result. The parameter verification result may include at least one of a parameter similarity verification result and a parameter word verification result.
For example, when the code verification program only performs parameter verification and version verification according to the preset style verification rule, the obtained verification result only includes the parameter verification result and the version verification result, and the verification report is generated according to the parameter verification result and the version verification result.
According to the code checking method, at least one of uniform resource locator checking, parameter checking, paging checking and version checking is carried out on the interface code according to the preset style checking rule, the checking result is obtained, whether the interface code accords with the preset style or not can be checked, therefore, the code is enabled to be more accordant with the compiling specification, the error rate of submitted codes is reduced, the code is enabled to be more accordant with the preset code style, the interface code which accords with the preset code style is more easily called, and the readability of the interface code is also improved.
In one embodiment, as shown in fig. 5, a flowchart illustrating the process of performing the url check in one embodiment is shown. Carrying out uniform resource locator verification on the interface code according to a preset style verification rule to obtain a verification result, wherein the method comprises the following steps:
step 502, determining a uniform resource locator in an interface code.
The preset style check rule needs to check the part of speech of each target word in the uniform resource locator.
Specifically, the code check program may determine the uniform resource locator in the interface code according to the preset character string. For example, the uniform resource locator contains "/" or "http: "and the like, the uniform resource locator in the interface code can be determined according to the preset character string.
And step 504, performing word segmentation processing on the uniform resource locator to obtain a target word.
The target word may be a word having a word meaning, or may be a single letter or number.
Specifically, the code checking program may perform word segmentation processing on the uniform resource locator in a Natural Language processing Toolkit (NLTK) manner or the like to obtain the target word. For example,/v 3/nesting/dis, then v3 may be a target word, nesting a target word, and dis a target word.
Step 506, checking the part of speech of the target word to obtain a resource locator checking result.
The part of speech of the target word may be noun, adjective, verb, adverb, etc., but is not limited thereto. The resource locator check result is a part-of-speech result used for representing the target word. The result of the resource locator check may be that the uniform resource locator includes verbs, adjectives, nouns, and no verbs … …, but is not limited thereto.
Specifically, the code verification program verifies the part of speech of the target word to obtain a resource locator verification result corresponding to the uniform resource locator.
In this embodiment, when the interface code includes at least two uniform resource locators, the code checking program performs word segmentation processing on each of the at least two uniform resource locators to obtain a target word corresponding to each of the at least two uniform resource locators. And checking the part of speech of the target word to obtain a resource locator check result corresponding to each uniform resource locator.
According to the code checking method, the uniform resource locators in the interface codes are determined, word segmentation is carried out on the uniform resource locators to obtain the target words, the part of speech of the target words is checked to obtain the resource location checking result, and whether the uniform resource locators accord with the preset style or not can be checked, so that the codes accord with the writing standard better, the error rate of the codes is reduced, the manual checking work is reduced, and the checking accuracy is improved.
In one embodiment, the verification report is generated according to the verification result, and includes: the check report is generated according to the resource locator check result, wherein the check report comprises the first resource locator check result, and the first resource locator check result is error information related to parts of speech which are not nouns.
The first locator check result comprises error information related to the nouns which are not all part of speech of the target word of the uniform resource locator. The error information related to "none of the parts of speech of the target word is a noun" is error information that is semantically identical or similar to "none of the parts of speech of the target word is a noun". For example, error information such as "none of the parts of speech of the uniform resource locator is a noun" or "the uniform resource locator does not conform to a predetermined code style" may be displayed in the verification report, but is not limited thereto.
Specifically, the resource locator check result may be an error check result of the resource locator or a correct check result of the resource locator. The correct result of checking the uniform resource locator for the interface code according to the preset style check rule should include that the result of checking the uniform resource locator includes nouns. Namely, the noun must be in the code style that specifies the uniform resource locator. For example,/v 3/training/disks includes the term "disks", then the uniform resource locator conforms to a predetermined code style. The first resource locator check result is an error check result. And the code checking program generates a checking report according to the resource positioning checking result, wherein the checking report comprises the first resource locator checking result. The check report may further include other check results, for example, when the code check program further performs page check on the interface code, the check report may further include page check results.
In this embodiment, when the resource locator check result is the third locator check result, that is, the third locator check result includes correct information that the parts of speech of the target word are all nouns, the report is displayed without including the third locator check result.
According to the code verification method, the verification report is generated according to the resource locator verification result, wherein the verification report comprises the first resource locator verification result, the first resource locator verification result is the error information which is not related to the nouns in terms of parts of speech, under the general condition, the verification result displayed in the code verification report is the error result, the error information which is related to the nouns in terms of parts of speech is the error result, the verification report comprising the error result can be displayed, the verification result is made to be readable, and therefore the error rate of the code is reduced.
In one embodiment, the verification report is generated according to the verification result, and includes: when the resource locator check result is a second resource locator check result, determining an operation instruction corresponding to the uniform resource locator, wherein the second resource locator check result is error information related to the part of speech including verbs; and when the operation instruction is not the preset operation instruction, generating a verification report according to the verification result of the second resource locator, wherein the verification report comprises the verification result of the second resource locator.
And the second resource locator check result indicates that the part of speech of the target word comprises a verb. The related error information is information with the same or similar semanteme. For example, the error information related to the verb included in the part of speech may be, but is not limited to, "verb included in uniform resource locator a", "verb close included in uniform resource locator a", or the like. The operation instruction may be an "http method" for describing an operation on the resource. In the API code editing, the following four operation instructions are included but not limited to:
GET for obtaining resources
POST for adding new resources
PUT for updating resources
DELETE for deleting resources
Specifically, the correct result of performing the uniform resource locator check on the interface code according to the preset style check rule should include that when the uniform resource locator includes a verb, the corresponding operation instruction in the uniform resource locator is a preset operation instruction. The preset operation instruction may be "POST" in the above. For example, if the uniform resource locator is/v 3/pay/transactions/id/4200000188201810052881913584/close, then checking the part of speech of the target word in the uniform resource locator to obtain that pay and close are both verbs and transactions and id are nouns. Then the uniform resource locator includes the verb, and the corresponding operation instruction is determined. When the operation instruction corresponding to the uniform resource locator is POST, the check result does not need to be displayed in the check report; when the operation instruction corresponding to the uniform resource locator is not POST, for example, GET, then the second resource locator verification result needs to be displayed in the verification report. Other verification results, such as the first locator verification result, etc., may also be included in the verification report.
According to the code checking method, when the resource locator checking result is wrong information related to verbs contained in the part-of-speech of the target word, the operation instruction corresponding to the uniform resource locator is checked, when the resource locator checking result is not the preset operation instruction, the displayed checking report comprises the second resource locator checking result, under a general condition, the checking result displayed in the checking report is a wrong result, the uniform resource locator comprises the verbs but the corresponding operation instruction is not the preset operation instruction, namely the wrong result, the checking report containing the wrong result can be displayed, the checking result has readability, and therefore the error rate of the code is reduced.
In one embodiment, performing uniform resource locator verification on the interface code according to a preset style verification rule to obtain a verification result, including:
step (a1), determine the uniform resource locator in the interface code.
And (a2) performing word segmentation processing on the uniform resource locator to obtain the target word.
And (a3) checking the part of speech of the target word to obtain a resource locator checking result.
And (a4), when the resource locator check result is a second resource locator check result, determining an operation instruction corresponding to the uniform resource locator, wherein the second resource locator check result is error information related to the part of speech including the verb.
And (a5) when the operation instruction is not a preset operation instruction, generating a verification report according to the first resource locator verification result and the second resource locator verification result, wherein the verification report includes the first resource locator verification result and the second resource locator verification result, and the first resource locator verification result is error information related to parts of speech which are not nouns.
The code checking method comprises the steps of determining the uniform resource locator in the interface code, performing word segmentation processing on the uniform resource locator to obtain a target word, checking the part of speech of the target word to obtain a resource location checking result, checking whether the uniform resource locator accords with a preset style or not, wherein the checking report comprises a first resource locator checking result and a second resource locator checking result, in general, the check result displayed in the code check report is an error result, and both the first resource locator check result and the second resource locator check result are error information, the check report containing the error result can be displayed, so that the check result has readability, therefore, the error rate of the code is reduced, the code is enabled to be more in line with the writing specification, the error rate of the code is reduced, the manual checking work is reduced, and the checking accuracy is improved.
In an embodiment, as shown in fig. 6, a schematic flowchart of a process for checking parameters of an interface code according to a preset style checking rule in an embodiment includes:
step 602, obtaining each reference parameter identifier and reference parameter description in the database.
The reference parameter identifier may be referred to as a reference parameter name. The reference parameter names are different. The reference parameter identification may be composed of at least one of a number, a letter, a symbol. The reference parameter description may include reference parameter values and interpretations of the reference parameters. Each reference parameter identification has a corresponding reference parameter description. For example, the reference parameter is identified as "batch number", the reference parameter is described as "unique id assigned to each batch, example value: 12345000".
Specifically, the reference database includes at least one reference parameter identifier and a corresponding reference parameter description. And the code checking program acquires each reference parameter identification and the corresponding reference parameter description from the database.
Step 604, detecting the target parameter identification and the corresponding target parameter description in the interface code.
The target parameter identification may be referred to as a target parameter name. The target parameter identifications are different. The target parameter identification may be composed of at least one of numbers, words, letters, and symbols. The target parameter description may include at least one of a target parameter value and an interpretation of the target parameter, but is not limited thereto. Each target parameter identification has a corresponding target parameter description.
Specifically, the code verification program may detect the operation instruction related words first, and then determine the target parameter identifier according to the operation instruction related words, thereby determining the corresponding target parameter description.
Step 606, determining a first similarity between the target parameter identifier and each reference parameter identifier, and determining a second similarity between the target parameter description and each corresponding reference parameter description, to obtain a parameter similarity check result.
The parameter verification result includes the first similarity and the second similarity. The code checking program can adopt algorithms such as Jaccard Similarity algorithm, cosine Similarity algorithm, Euclidean distance algorithm and the like, but is not limited to calculating the first Similarity and the second Similarity.
Specifically, the code verification program determines a first similarity between a target parameter identifier and each reference parameter identifier in the database. For example, if the target parameter is identified as "lot number" and there are 10 reference parameter identifications in the database, then 10 first similarities will be obtained. Similarly, the code verification program determines a second similarity between the one object parameter identification and the corresponding one object parameter description and each reference parameter description in the database. For example, the target parameter is described as "unique id assigned to each batch, example value: 12345000 ", there are 10 reference parameter descriptions in the database, then 10 second similarities are obtained.
Step 608, the verification report is generated according to the parameter similarity verification result, where the verification report includes the first parameter similarity verification result, and the first parameter similarity verification result includes error information related to the similarity that both the first similarity and the corresponding second similarity reach the similarity threshold.
Wherein, the similarity threshold value can be configured according to the requirement. The similarity threshold may be only one, e.g. 80%. The similarity threshold may also be two, and is divided into a first similarity threshold corresponding to the first similarity and a second similarity threshold corresponding to the second similarity. And the first similarity threshold and the second similarity threshold may not be the same. The "error information related to the first similarity and the corresponding second similarity both reaching the similarity threshold" may be, for example, but not limited to, "there are similar parameter identifiers and parameter descriptions in the database," "the parameter identifiers and parameter descriptions do not conform to the preset style," and the like.
The parameter similarity check result comprises a first similarity of the target parameter identification and a second similarity of the target parameter description corresponding to the target parameter identification. The parameter similarity check result may be a correct check result of the parameter similarity or an incorrect check result of the parameter similarity. The parameter similarity check result may include a first parameter similarity check result, a second parameter similarity check result, a third parameter similarity check result, and a fourth parameter similarity check result. And the error result of parameter verification on the interface code according to the preset style verification rule is a first parameter similarity verification result, and the first parameter similarity verification result comprises error information related to the similarity threshold value reached by the first similarity and the corresponding second similarity. The second parameter similarity check result, the third parameter similarity check result and the fourth parameter similarity check result are all correct information. Then the second parameter similarity check result may be that the first similarity reaches the similarity threshold and the corresponding second similarity does not reach the similarity threshold. The third parameter similarity check result may be that the first similarity does not reach the similarity threshold and the corresponding second similarity reaches the similarity threshold. The fourth parameter similarity check result may be that both the first similarity and the corresponding second similarity do not reach the similarity threshold. The first, second, third and fourth are names, and the first similarity may be referred to as the second similarity and the second similarity may be referred to as the first similarity, but the two meanings are different.
And the second similarity corresponding to the first similarity is the target parameter description corresponding to the target parameter identification, and the second similarity between the target parameter description and the reference parameter description is realized. And performing parameter verification on the interface code according to a preset style verification rule, namely verifying the similarity of the target parameter identifier and the target reference identifier.
Specifically, the code verification program generates a verification report according to the parameter similarity verification result. For example, the first similarity between the target parameter identification "lot number" and the reference parameter identification "lot number" is 100%, the target parameter describes "a unique id assigned to each lot, an example value: 12345000 "description with reference parameters" unique id assigned to each batch, example value: 12345000 ", also 100%. And obtaining a first parameter similarity checking result.
The code checking method determines a first similarity between the target parameter identifier and each reference parameter identifier, and determines a second similarity between the target parameter description and each corresponding reference parameter description to obtain a parameter similarity checking result, wherein the checking result displayed in the checking report is an error result under a general condition; since the first similarity and the corresponding second similarity both reach the similarity threshold, that is, it is indicated that the target parameter identifier and the target parameter description may be the same identifier and the same description as a certain reference parameter identifier and a certain reference parameter description in the database, that is, there is actually a correct identifier and description in the database, and there may be slight errors in the target parameter identifier, an error result may be displayed in the verification report, so that the parameter similarity verification result has readability, thereby also reducing the error rate of the parameter identifier and the parameter description.
In one embodiment, the parameter verification of the interface code according to the preset style verification rule comprises: detecting a target parameter identifier in an interface code; and verifying the target parameter identification according to words in a dictionary library to obtain a parameter word verification result. The verification report is generated according to the verification result and comprises: the verification report is generated according to the parameter word verification result, wherein the verification report comprises a first parameter word verification result, and the first parameter word verification result is error information related to the target parameter identification spelling error.
Specifically, the dictionary library may be an english dictionary library or a chinese dictionary library. The words in the dictionary repository can be used to check whether the spelling of the target parameter identifier is incorrect, i.e. whether the target parameter identifier is a word in the dictionary. The parameter word check result may include a correct parameter word check result or an incorrect parameter word check result. The first parameter word check result is error information related to the target parameter identification spelling error, and may be information such as "parameter identification a spelling error", "parameter identification spelling error in the nth line of the code", "parameter identification a is not in the dictionary", and the like.
The code checking method comprises the steps of detecting a target parameter identifier in an interface code, checking the target parameter identifier according to words in a dictionary library, checking whether spelling of the target parameter identifier is wrong or not to obtain a parameter word checking result, generating a checking report according to the parameter word checking result, displaying the checking report, wherein the displayed checking report comprises a first parameter word checking result which is error information related to spelling errors of the target parameter identifier, namely the checking report comprises the spelling error information of the parameters, so that the parameter word checking result has readability, and the error rate of the parameter identifier is reduced.
In one embodiment, the parameter verification of the interface code according to the preset style verification rule comprises:
and (b1) acquiring the reference parameter identifications and the reference parameter descriptions in the database.
And (b2) detecting the target parameter identification and the corresponding target parameter description in the interface code.
And (b3) determining a first similarity between the target parameter identifier and each reference parameter identifier, and determining a second similarity between the target parameter description and each corresponding reference parameter description to obtain a parameter similarity check result.
And (b4) detecting the target parameter identification in the interface code.
And (b5) checking the target parameter identification according to the words in the dictionary library to obtain a parameter word checking result.
And (b6) generating a verification report according to the parameter similarity verification result and the parameter word verification result, wherein the verification report includes a first parameter similarity verification result and a first parameter word verification result, the first parameter similarity verification result includes error information related to the similarity threshold value reached by both the first similarity and the corresponding second similarity, and the first parameter word verification result is error information related to the spelling error of the target parameter identifier.
The code checking method determines a first similarity between the target parameter identifier and each reference parameter identifier, and determines a second similarity between the target parameter description and each corresponding reference parameter description to obtain a parameter similarity checking result, wherein the checking result displayed in the checking report is an error result under a general condition; since the first similarity and the corresponding second similarity both reach the similarity threshold, that is, it indicates that the target parameter identifier and the target parameter description may be the same identifier and the same description as a certain reference parameter identifier and a certain reference parameter description in the database, that is, there is actually correct identifier and description in the database, there may be slight errors in the target parameter identifier, and when writing a code, the target parameter identifier may also have spelling errors, and then an error result, that is, an error is reported, may be displayed in the verification report, so that the parameter similarity verification result has readability, thereby also reducing the error rate of the parameter identifier and the parameter description.
In one embodiment, performing a paging check on the interface code according to a preset style check rule includes: determining a read interface related instruction in the interface code; acquiring a reference paging parameter identifier; and verifying the related instruction of the read interface according to the reference paging parameter identifier to obtain a paging verification result. The verification report is generated according to the verification result and comprises: the check report is generated according to the paging check result, wherein the check report includes a first paging check result, and the first paging check result is error information related to the instruction related to the read interface and not including the reference paging parameter identifier.
The read interface related instruction refers to an instruction for reading a resource. For example, get is a read interface operation instruction, and get abcdefg is a read interface related instruction. The paging parameter identifier may be, but is not limited to, a paging page number parameter identifier, a paging size parameter identifier, and the like. One of the specifications in the default code style is that the instructions associated with the read interface include paging parameters. I.e. whether the abcdefg contains a paging parameter. The error information associated with the instruction related to the read interface not including the reference page parameter identifier may be, for example, but not limited to, "the instruction does not include the page parameter identifier", "the instruction does not include the offset", and the like.
Specifically, the code check program determines a read interface related instruction in the interface code and obtains a reference paging parameter identifier. Wherein, the reference paging parameter id is a correct paging parameter id. For example, the reference page parameter identifier is "offset", "limit", "page number", "page size", etc., but is not limited thereto. The code checking program paging checking result may include a first paging checking result and a second paging checking result. The first paging check result is that the instruction related to the read interface does not include the reference paging parameter identifier, the related error information needs to report an error, and the first paging check result needs to be displayed in the check report. The second paging check result is that the instruction related to the read interface contains parameter paging parameter identification, and the related correct information does not need to report an error.
According to the code checking method, the read interface related instruction in the interface code is determined, the reference paging parameter identifier is obtained, the read interface related instruction is checked according to the reference paging parameter identifier to obtain the paging checking result, the checking report comprises the error information which is related to the read interface related instruction and does not contain the reference paging parameter identifier, and the error information corresponding to the read interface related instruction can be displayed more visually, so that the error rate of the read interface related instruction is reduced, the interface code is easier to call, and the calling efficiency is improved.
In one embodiment, the performing version check on the interface code according to the preset style check rule includes: acquiring a history version number and a target version number corresponding to an interface code; and carrying out version verification on the target version number according to the historical version number to obtain a version number verification result. The verification report is generated according to the verification result and comprises: and the verification report is generated according to the version number verification result, wherein the verification report comprises a first version number verification result, and the first version number verification result is error information related to version number conflict.
Wherein, the version number refers to the identification number of the version. Each part of interface code has a corresponding version number, and the version numbers of the interface codes are different. Historical version numbers are all version numbers of the interface code in the past. The target version number is the current version number of the interface code. The checking report comprises a first version number checking result and can also comprise a second version number checking result. And the first version number verification result is that the version numbers conflict, and the second version number verification result is that the version numbers do not conflict. For example, the error information related to the version number conflict may be "there is a conflict between the version number of the interface code and the historical version number", "the version number of the interface code is wrong", or the like, but is not limited thereto.
Specifically, the code checking program obtains a history version number and a target version number corresponding to the interface code. And the code checking program checks whether the target version number conflicts with the historical version number or not to obtain a version number checking result. And the code checking program generates a checking report according to the version number checking result. The displayed check report comprises a first version number check result, and the first version number check result is error information related to version number conflict.
According to the code checking method, the historical version number and the target version number corresponding to the interface code are obtained, the version of the target version number is checked according to the historical version number, the displayed checking report comprises error information relevant to version number conflict, the error information relevant to the version number can be displayed more visually, and therefore the error rate of the version number is reduced.
In one embodiment, the code verification method further comprises: when the check report does not contain error information, sending the interface code to a target terminal where the account with the evaluation authority is located; receiving a review result returned by the target terminal, wherein the review result is obtained after the interface code is reviewed; and when the evaluation result is that the interface code passes, generating an interface code file corresponding to the interface code.
The error information may be that none of the parts of speech of the uniform resource locator is a noun, the part of speech of the uniform resource locator includes a verb, the operation instruction is not a preset operation instruction, both the first similarity and the second similarity reach a similarity threshold, the target parameter identifies a spelling error, the read interface related instruction does not include a reference paging parameter identifier, and the version number conflicts. The account with the review authority is the account with the review on the interface code. For example, an administrator account. And the terminal where the account with the evaluation authority is located becomes the target terminal. For example, if an account z with a review authority logs in the terminal 1, the terminal 1 is a target terminal; the account z with the review authority logs in the terminal 2, and then the terminal 2 is the target terminal.
Specifically, when the code verification program determines that the verification report does not contain error information, the interface code is automatically sent to the target terminal where the account with the review authority is located. And the target terminal acquires a review result obtained after the code is reviewed, sends the review result to the server, and the server sends the review result to the terminal uploading the interface code. And when the evaluation result is that the interface code passes, automatically generating an interface code file corresponding to the interface code by the code checking program. The interface code file may be an API document.
In this embodiment, as shown in fig. 7, a schematic interface diagram of initiating a review in one embodiment is shown. The title is that an interface for inquiring the information of the merchant of the receipt unit according to the payment order number is added. The process includes "electronic bill API review" (i.e., code style check on interface code) → "master" (i.e., review). The review rules can be set as desired. The review rule is that all reviewers (i.e., accounts with review privileges) are required to agree. The reviewer's account number may include, but is not limited to, "AAA", "BBB" … …, and the reviewer may be added. The result of the review can be commented, approved or rejected on the interface.
According to the code checking method, when the checking report does not contain error information, the interface code is sent to the target terminal where the account with the evaluation authority is located, the evaluation result returned by the target terminal is received, wherein the evaluation result is obtained after the interface code is evaluated, and when the evaluation result is passed, the interface code file corresponding to the interface code is generated, so that the interface code can be further checked, and the error rate of the interface code is reduced.
In one embodiment, the trigger operation includes a merge request to merge the interface code with the code of the source branch.
Wherein the interface code is the code of the target branch of the development. The code of the source branch contains the code of the various interfaces. An interface Merge Request (MR) is used to Merge the interface code with the code of the source branch.
Specifically, in response to a merging request for interface codes, code style verification is performed on the interface codes according to a preset style verification rule to obtain a verification result; and displaying a verification report, wherein the verification report is generated according to the verification result. When the check report does not contain error information, sending the interface code to a target terminal where the account with the evaluation authority is located; receiving a review result returned by the target terminal, wherein the review result is obtained after the interface code is reviewed; and when the evaluation result is that the interface code passes, generating an interface code file corresponding to the interface code and merging the interface code with the code of the source branch.
According to the code checking method, the triggering operation comprises the merging request, the merging request is used for merging the interface code and the code of the source branch, namely, the code style checking is carried out when the interface code is submitted, the error rate of the interface code can be reduced, and the reviewing efficiency is improved.
In one embodiment, the check report includes error information corresponding to the interface code, the error information including at least one of an error name, a non-compliant style check rule, an error path, and an illegal value.
Specifically, the error name may be a type of error, for example, the parameter check result may be referred to as an interface parameter error, an interface name illegal, or the like, but is not limited thereto. The non-compliant style check rule includes, but is not limited to, at least one of a noun not included in the URL, a noun included in the URL but not corresponding operation instruction being a preset operation instruction, similarity between the target parameter identifier and the reference parameter identifier in the database reaching a similarity threshold, similarity between the target parameter description and the reference parameter description in the database reaching a similarity threshold, a misspelling of the parameter identifier, no paging parameter in the read interface related instruction, and a version number conflict. The error path is used to characterize the path in which the error occurred, etc. Illegal values are used to characterize the interface code in which the error occurred.
According to the code checking method, the checking report comprises the error information corresponding to the interface code, the error information comprises at least one of the error name, the inconsistent style checking rule, the error path and the illegal value, the error information can be displayed more visually, the subsequent code modification is facilitated, and the code modification efficiency is improved.
In an embodiment, as shown in fig. 8, a timing diagram of a code checking method in an embodiment includes a terminal a where an account with an interface code submission authority is located, a contract repository, a target terminal where an account with a review authority is located, and a terminal B where an account paying attention to the interface code is located. The contract repository is a Git repository for storing an OpenAPI (OPEN Application Programming Interface) of the payment Interface. Git is an open-source, distributed version control system for agilely and efficiently processing projects.
Terminal a initiates a merge contract (i.e., a merge request) for the interface code. And the contract warehouse checks the interface code, namely, the code style check is carried out on the interface code according to a preset style check rule, and the grammar check is carried out on the interface code. And the contract warehouse returns a verification result which does not conform to the code style to the terminal A, and a verification report is displayed on the terminal A. Alternatively, when the verification result is pass, an interface code document is generated, and an SDK (Software Development Kit) is generated. And the contract warehouse initiates a review request to a target terminal where the account with the review authority is located, and sends the interface code to the target terminal where the account with the review authority is located. And recording the evaluation data in the evaluation process by the contract warehouse, namely receiving the evaluation result returned by the target terminal. And when the evaluation result is that the interface code is not passed, prompting the terminal A to modify the interface code. Error information related to the interface code may be included in the review result. When the result of the evaluation is pass, executing a merging contract (merging request), and merging the interface code and the source branch code. And the contract repository can send API review information such as a verification report, review data, etc. to the terminal B where the account concerned with the interface code is located. In addition, the contract repository can also generate a weekly report related to the interface code and return the weekly report to the account B concerned with the interface code, namely the one-week progress condition of the API.
In one embodiment, a code verification method includes:
and (c1) displaying the interface code on the interface.
Step (c2), in response to the merge request to the interface code, determining a uniform resource locator in the interface code.
And (c3) performing word segmentation processing on the uniform resource locator to obtain the target word.
And (c4) checking the part of speech of the target word to obtain a resource locator checking result.
And (c5) when the resource locator check result is a second resource locator check result, determining the operation instruction corresponding to the uniform resource locator, wherein the second resource locator check result is error information related to the part of speech including verbs.
And (c6) when the operation instruction is not the preset operation instruction, generating a verification report according to the verification result of the second resource locator.
And (c7) acquiring the reference parameter identifications and the reference parameter descriptions in the database.
And (c8) detecting the target parameter identification and the corresponding target parameter description in the interface code.
And (c9) determining a first similarity between the target parameter identifier and each reference parameter identifier, and determining a second similarity between the target parameter description and each corresponding reference parameter description to obtain a parameter similarity check result.
And (c10) detecting the target parameter identification in the interface code.
And (c11) checking the target parameter identification according to the words in the dictionary library to obtain a parameter word checking result.
And (c12) determining the read interface related instruction in the interface code.
And (c13) obtaining the reference paging parameter identifier.
And (c14) checking the instruction related to the read interface according to the reference paging parameter identifier to obtain a paging check result.
And (c15) acquiring the historical version number and the target version number corresponding to the interface code.
And (c16) carrying out version verification on the target version number according to the historical version number to obtain a version number verification result.
Step (c17), displaying a verification report, wherein the verification report comprises at least one of a first resource locator verification result, a second resource locator verification result, a first parameter similarity verification result, a first parameter word verification result, a first paging verification result, a first version number verification result and a verification result conforming to a preset style, the first resource locator verification result is error information which is not related to nouns with different parts of speech, the second resource locator verification result is error information which is related to verbs with parts of speech, the first parameter similarity verification result comprises error information which is related to similarity threshold values when the first similarity and the corresponding second similarity both reach the similarity threshold values, the first parameter word verification result is error information related to target parameter identification spelling errors, the first paging verification result is error information related to reading interface related instructions without reference paging parameter identifications, the first version number check result is error information related to version number conflict.
And (c18) when the check report does not contain error information, sending the interface code to the target terminal where the account with the review authority is located.
And step (c19), receiving a review result returned by the target terminal, wherein the review result is obtained after the interface code is reviewed.
And (c20) when the result of the evaluation is passed, generating an interface code file corresponding to the interface code.
According to the code checking method, the interface code is displayed on the interface, at least one of uniform resource locator checking, parameter checking, paging checking and version checking is carried out on the interface code according to the preset style checking rule by responding to the triggering operation of the interface code, the checking result is obtained, and the checking report is displayed, wherein the checking report is generated according to the checking result, and the code style checking can be carried out on the interface code, so that the code is more in line with the compiling specification, the code error rate is reduced, the manual checking work is reduced, the checking accuracy is improved, the code is more in line with the preset code style, the interface code in line with the preset code style is more easily called, and the readability of the interface code is improved.
In an embodiment, the present application further provides an application scenario, where the application scenario applies the code verification method described above. Specifically, the application of the code verification method in the application scenario is as follows: displaying a payment interface code on an interface; responding to a merging request for the payment interface code, and performing at least one of uniform resource locator verification, parameter verification, paging verification and version verification on the payment interface code according to a preset style verification rule to obtain a verification result; and displaying a verification report, wherein the verification report is generated according to the verification result. The payment interface code may be, among other things, code for providing a payment resource call, such as for creating a voucher batch, activating a voucher batch, issuing a voucher, pausing a voucher batch, restarting a voucher batch, querying a voucher enabled merchant, querying a voucher enabled item, etc. The terminal where the account with the interface calling authority is located can complete corresponding operation by calling the payment interface code. The payment interface code is verified, so that the error rate of the payment interface code can be reduced, the payment interface code can be more easily called, and meanwhile, the efficiency of calling the payment interface is improved.
In an embodiment, the present application further provides an application scenario, where the application scenario applies the code verification method described above. Specifically, the application of the code verification method in the application scenario is as follows: displaying the applet interface code on the interface; responding to a merging request for the small program interface codes, and performing at least one of uniform resource locator verification, parameter verification, paging verification and version verification on the program interface codes according to a preset style verification rule to obtain a verification result; and displaying a verification report, wherein the verification report is generated according to the verification result. Wherein, the applet is an application program which can be used without downloading and installation. The applet interface code may be used to provide an interface to the server where the applet resides. The user terminal can realize the communication between the small program and other servers by calling the small program interface code so as to realize the related operation of the small program. The small program interface code is verified, so that the error rate of the small program interface code can be reduced, the small program interface code can be more easily called, and the efficiency of calling the small program is improved.
In an embodiment, the present application further provides an application scenario, where the application scenario applies the code verification method described above. Specifically, the application of the code verification method in the application scenario is as follows: displaying a cloud server interface code on an interface; responding to a merging request for the interface code of the cloud server, and performing at least one of uniform resource locator verification, parameter verification, paging verification and version verification on the program interface code of the program according to a preset style verification rule to obtain a verification result; and displaying a verification report, wherein the verification report is generated according to the verification result. The cloud server is used for providing data storage services, website building services and the like for groups or individuals, and is not limited to the above. The cloud server interface code may be used to provide an interface for accessing a cloud server. The user terminal can realize the communication between the cloud server and other servers or other terminals by calling the cloud server interface code so as to realize the operation related to the cloud server. The cloud server interface code is verified, so that the error rate of the cloud server interface code can be reduced, the cloud server interface code can be more easily called, and meanwhile, the efficiency of calling the cloud server is improved.
It should be understood that although the various steps in the flowcharts of fig. 1, 5 and 6 are shown in order as indicated by the arrows, the steps are not necessarily performed in order as indicated by the arrows. The steps are not performed in the exact order shown and described, and may be performed in other orders, unless explicitly stated otherwise. Moreover, at least some of the steps in fig. 1, 5 and 6 may include multiple steps or multiple stages, which are not necessarily performed at the same time, but may be performed at different times, which are not necessarily performed in sequence, but may be performed in turn or alternately with other steps or at least some of the other steps or stages.
In one embodiment, as shown in fig. 9, there is provided a code checking apparatus, which may be a part of a computer device using a software module or a hardware module, or a combination of the two, and specifically includes: a first display module 902, a verification module 904, and a second display module 906, wherein:
a first display module 902, configured to display an interface code on an interface;
the verification module 904 is configured to perform code style verification on the interface code according to a preset style verification rule in response to a trigger operation on the interface code to obtain a verification result;
and a second display module 906, configured to display a verification report, where the verification report is generated according to a verification result.
According to the code checking device, the interface code is displayed on the interface, the code style checking is carried out on the interface code according to the preset style checking rule by responding to the triggering operation of the interface code, the checking result is obtained, and the checking report is displayed, wherein the checking report is generated according to the checking result, and the code style checking can be carried out on the interface code, so that the code is more in line with the compiling specification, the error rate of the code is reduced, the manual checking work is reduced, the checking accuracy is improved, the code is more in line with the preset code style, the interface code in line with the preset code style is more easily called, and the readability of the interface code is improved.
In one embodiment, the checking module 904 is configured to perform at least one of a uniform resource locator check, a parameter check, a paging check, and a version check on the interface code according to a preset style check rule to obtain a check result.
According to the code checking device, at least one of uniform resource locator checking, parameter checking, paging checking and version checking is carried out on the interface code according to the preset style checking rule, the checking result is obtained, whether the interface code accords with the preset style or not can be checked, therefore, the code is enabled to accord with the compiling standard better, the error rate of the code is reduced, the code is enabled to accord with the preset code style better, the interface code which accords with the preset code style is enabled to be called more easily, and the readability of the interface code is improved.
In one embodiment, the check module 904 is used to determine a uniform resource locator in the interface code; performing word segmentation processing on the uniform resource locator to obtain a target word; and checking the part of speech of the target word to obtain a resource locator checking result.
According to the code checking device, the uniform resource locators in the interface codes are determined, word segmentation is carried out on the uniform resource locators to obtain the target words, the part of speech of the target words is checked to obtain the resource positioning checking result, and whether the uniform resource locators accord with the preset style or not can be checked, so that the codes accord with the writing standard better, the code error rate is reduced, the manual checking work is reduced, and the checking accuracy is improved.
In an embodiment, the second display module 906 is configured to display a check report, where the check report is generated according to a resource locator check result, where the check report includes a first resource locator check result, and the first resource locator check result is error information related to terms that are all non-nouns.
The code verification device generates a verification report according to the resource locator verification result, wherein the verification report comprises a first resource locator verification result, the first resource locator verification result is error information which is not related to nouns in terms of parts of speech, under a general condition, the verification result displayed in the code verification report is the error result, and the error information which is related to the nouns in terms of parts of speech is the error result, and the verification report comprising the error result can be displayed, so that the verification result has readability, and the error rate of the code is reduced.
In one embodiment, the second display module 906 is configured to display a check report, and when the resource locator check result is a second resource locator check result, determine an operation instruction corresponding to the uniform resource locator, where the second resource locator check result is error information related to the part of speech including the verb; and when the operation instruction is not the preset operation instruction, generating a verification report according to the verification result of the second resource locator, wherein the verification report comprises the verification result of the second resource locator.
According to the code checking device, when the resource locator checking result is wrong information related to verbs contained in the part-of-speech of the target word, the operation instruction corresponding to the uniform resource locator is checked, when the resource locator checking result is not the preset operation instruction, the displayed checking report comprises the second resource locator checking result, under a general condition, the checking result displayed in the checking report is a wrong result, the uniform resource locator comprises the verbs but the corresponding operation instruction is not the preset operation instruction, namely the wrong result, the checking report containing the wrong result can be displayed, the checking result has readability, and therefore the error rate of the code is reduced.
In one embodiment, the check module 904 is used to determine a uniform resource locator in the interface code; performing word segmentation processing on the uniform resource locator to obtain a target word; checking the part of speech of the target word to obtain a resource locator checking result; when the resource locator check result is a second resource locator check result, determining an operation instruction corresponding to the uniform resource locator, wherein the second resource locator check result is error information related to the part of speech including verbs; and when the operation instruction is not the preset operation instruction, generating a verification report according to the first resource locator verification result and the second resource locator verification result, wherein the verification report comprises the first resource locator verification result and the second resource locator verification result, and the first resource locator verification result is error information which is related to the parts of speech which are not the nouns.
The code checking device obtains the target word by determining the uniform resource locator in the interface code and performing word segmentation processing on the uniform resource locator, checks the part of speech of the target word to obtain the resource location checking result, can check whether the uniform resource locator accords with the preset style or not, and the checking report comprises the first resource locator checking result and the second resource locator checking result, in general, the check result displayed in the code check report is an error result, and both the first resource locator check result and the second resource locator check result are error information, the check report containing the error result can be displayed, so that the check result has readability, therefore, the error rate of the code is reduced, the code is enabled to be more in line with the writing specification, the error rate of the code is reduced, the manual checking work is reduced, and the checking accuracy is improved.
In one embodiment, the checking module 904 is configured to obtain each reference parameter identifier and reference parameter description in the database; detecting a target parameter identification and a corresponding target parameter description in an interface code; and determining a first similarity between the target parameter identifier and each reference parameter identifier, and determining a second similarity between the target parameter description and each corresponding reference parameter description to obtain a parameter similarity checking result. The second display module 906 is configured to display a verification report, where the verification report is generated according to a parameter similarity verification result, where the verification report includes a first parameter similarity verification result, and the first parameter similarity verification result includes error information that is related to a similarity threshold value reached by both the first similarity and the corresponding second similarity.
The code checking device determines a first similarity between the target parameter identifier and each reference parameter identifier, and determines a second similarity between the target parameter description and each corresponding reference parameter description to obtain a parameter similarity checking result, wherein the checking result displayed in the checking report is an error result under a general condition; since the first similarity and the corresponding second similarity both reach the similarity threshold, that is, it is indicated that the target parameter identifier and the target parameter description may be the same identifier and the same description as a certain reference parameter identifier and a certain reference parameter description in the database, that is, there is actually a correct identifier and description in the database, and there may be slight errors in the target parameter identifier, an error result may be displayed in the verification report, so that the parameter similarity verification result has readability, thereby also reducing the error rate of the parameter identifier and the parameter description.
In one embodiment, the check module 904 is configured to detect the target parameter identification in the interface code; and checking the target parameter identification according to the words in the dictionary library to obtain a parameter word checking result. The second display module 906 is configured to display a verification report, where the verification report is generated according to a parameter word verification result, where the verification report includes a first parameter word verification result, and the first parameter word verification result is error information related to a spelling error of the target parameter identifier.
The code checking device detects the target parameter identification in the interface code, checks the target parameter identification according to words in the dictionary library, checks whether spelling of the target parameter identification is wrong or not, obtains a parameter word checking result, generates a checking report according to the parameter word checking result, displays the checking report, and displays the checking report, wherein the displayed checking report comprises a first parameter word checking result which is error information related to spelling errors of the target parameter identification, namely the checking report comprises the spelling error information of the parameters, so that the parameter word checking result has readability, and the error rate of the parameter identification is reduced.
In one embodiment, the check module 904 is configured to determine a read interface related instruction in the interface code; acquiring a reference paging parameter identifier; and verifying the related instruction of the read interface according to the reference paging parameter identifier to obtain a paging verification result. The second display module 906 is configured to display a verification report, where the verification report is generated according to a paging verification result, where the verification report includes a first paging verification result, and the first paging verification result is error information that is related to the instruction related to the read interface and does not include the reference paging parameter identifier.
According to the code checking device, the reading interface related instruction in the interface code is determined, the reference paging parameter identifier is obtained, the reading interface related instruction is checked according to the reference paging parameter identifier, a paging checking result is obtained, the checking report comprises error information which is related to the reading interface related instruction and does not contain the reference paging parameter identifier, and the error information corresponding to the reading interface related instruction can be displayed more visually, so that the error rate of the reading interface related instruction is reduced, the interface code is more easily called, and the calling efficiency is also improved.
In one embodiment, the checking module 904 is configured to obtain a historical version number and a target version number corresponding to the interface code; and carrying out version verification on the target version number according to the historical version number to obtain a version number verification result. The second display module 906 is configured to display a verification report, where the verification report is generated according to a version number verification result, where the verification report includes a first version number verification result, and the first version number verification result is error information related to version number conflict.
The code checking device acquires the historical version number and the target version number corresponding to the interface code, carries out version checking on the target version number according to the historical version number, and can display the error information related to the version number more intuitively because the displayed checking report comprises the error information related to the version number conflict, thereby reducing the error rate of the version number.
In one embodiment, the code verification apparatus further comprises a review module. The evaluation module is used for sending the interface code to a target terminal where the account with evaluation authority is located when the check report does not contain error information; receiving a review result returned by the target terminal, wherein the review result is obtained after the interface code is reviewed; and when the evaluation result is that the interface code passes, generating an interface code file corresponding to the interface code.
According to the code checking device, when the checking report does not contain error information, the interface code is sent to the target terminal where the account with the checking authority is located, the checking result returned by the target terminal is received, wherein the checking result is obtained after the interface code is checked, and when the checking result is passed, the interface code file corresponding to the interface code is generated, so that the interface code can be further checked, and the error rate of the interface code is reduced.
In one embodiment, the trigger operation includes a merge request to merge the interface code with the code of the source branch.
The code checking device has the advantages that the triggering operation comprises a merging request, the merging request is used for merging the interface code and the code of the source branch, namely, the code style check is carried out when the interface code is submitted, the error rate of the interface code can be reduced, and the reviewing efficiency is improved.
In one embodiment, the check report includes error information corresponding to the interface code, the error information including at least one of an error name, a non-compliant style check rule, an error path, and an illegal value.
According to the code checking device, the checking report comprises the error information corresponding to the interface code, the error information comprises at least one of the error name, the inconsistent style checking rule, the error path and the illegal value, the error information can be displayed more visually, the follow-up code modification is facilitated, and the code modification efficiency is improved.
For the specific definition of the code verification device, reference may be made to the above definition of the code verification method, which is not described herein again. The modules in the code checking device can be wholly or partially realized by software, hardware and a combination thereof. The modules can be embedded in a hardware form or independent from a processor in the computer device, and can also be stored in a memory in the computer device in a software form, so that the processor can call and execute operations corresponding to the modules.
In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as shown in fig. 10. The computer device includes a processor, a memory, a communication interface, a display screen, and an input device connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The communication interface of the computer device is used for carrying out wired or wireless communication with an external terminal, and the wireless communication can be realized through WIFI, an operator network, NFC (near field communication) or other technologies. The computer program is executed by a processor to implement a code checking method. The display screen of the computer equipment can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer equipment can be a touch layer covered on the display screen, a key, a track ball or a touch pad arranged on the shell of the computer equipment, an external keyboard, a touch pad or a mouse and the like.
Those skilled in the art will appreciate that the architecture shown in fig. 10 is merely a block diagram of some of the structures associated with the disclosed aspects and is not intended to limit the computing devices to which the disclosed aspects apply, as particular computing devices may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.
In one embodiment, a computer device is further provided, which includes a memory and a processor, the memory stores a computer program, and the processor implements the steps of the above method embodiments when executing the computer program.
In an embodiment, a computer-readable storage medium is provided, in which a computer program is stored which, when being executed by a processor, carries out the steps of the above-mentioned method embodiments.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, database or other medium used in the embodiments provided herein can include at least one of non-volatile and volatile memory. Non-volatile Memory may include Read-Only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical storage, or the like. Volatile Memory can include Random Access Memory (RAM) or external cache Memory. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM), among others.
The technical features of the above embodiments can be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the above embodiments are not described, but should be considered as the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above-mentioned embodiments only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present patent shall be subject to the appended claims.

Claims (15)

1. A method for code verification, the method comprising:
displaying an interface code on an interface;
responding to the trigger operation of the interface code, and carrying out code style verification on the interface code according to a preset style verification rule to obtain a verification result;
and displaying a verification report, wherein the verification report is generated according to the verification result.
2. The method according to claim 1, wherein the code style checking the interface code according to a preset style checking rule to obtain a checking result comprises:
and performing at least one of uniform resource locator verification, parameter verification, paging verification and version verification on the interface code according to a preset style verification rule to obtain a verification result.
3. The method of claim 2, wherein performing uniform resource locator check on the interface code according to a preset style check rule to obtain a check result, comprising:
determining a uniform resource locator in the interface code;
performing word segmentation processing on the uniform resource locator to obtain a target word;
and checking the part of speech of the target word to obtain a resource locator checking result.
4. The method of claim 3, wherein the verification report is generated according to the verification result, and comprises:
the verification report is generated according to the resource locator verification result, wherein the verification report comprises a first resource locator verification result, and the first resource locator verification result is error information which is not related to the part of speech but is not a noun.
5. The method of claim 3, wherein the verification report is generated according to the verification result, and comprises:
when the resource locator check result is a second resource locator check result, determining an operation instruction corresponding to the uniform resource locator, wherein the second resource locator check result is error information related to verbs contained in the parts of speech;
and when the operation instruction is not a preset operation instruction, generating a verification report according to the second resource locator verification result, wherein the verification report comprises the second resource locator verification result.
6. The method of claim 2, wherein performing a parameter check on the interface code according to a predetermined style check rule comprises:
acquiring reference parameter identifications and reference parameter descriptions in a database;
detecting a target parameter identification and a corresponding target parameter description in the interface code;
determining a first similarity between the target parameter identifier and each reference parameter identifier, and determining a second similarity between the target parameter description and each corresponding reference parameter description to obtain a parameter similarity check result;
the verification report is generated according to the verification result and comprises:
the verification report is generated according to the parameter similarity verification result, wherein the verification report includes a first parameter similarity verification result, and the first parameter similarity verification result includes error information related to the similarity threshold reached by both the first similarity and the corresponding second similarity.
7. The method of claim 2, wherein performing a parameter check on the interface code according to a predetermined style check rule comprises:
detecting a target parameter identification in the interface code;
verifying the target parameter identification according to words in a dictionary library to obtain a parameter word verification result;
the verification report is generated according to the verification result and comprises:
the verification report is generated according to the parameter word verification result, wherein the verification report comprises a first parameter word verification result, and the first parameter word verification result is error information related to the target parameter identification spelling error.
8. The method of claim 2, wherein performing a paging check on the interface code according to a predetermined style check rule comprises:
determining a read interface related instruction in the interface code;
acquiring a reference paging parameter identifier;
verifying the read interface related instruction according to the reference paging parameter identifier to obtain a paging verification result;
the verification report is generated according to the verification result and comprises:
the check report is generated according to the paging check result, wherein the check report includes a first paging check result, and the first paging check result is error information that is not related to the reference paging parameter identifier in the instruction related to the read interface.
9. The method of claim 2, wherein performing a version check on the interface code according to a predetermined style check rule comprises:
acquiring a history version number and a target version number corresponding to the interface code;
performing version verification on the target version number according to the historical version number to obtain a version number verification result;
the verification report is generated according to the verification result and comprises:
the check report is generated according to the check result of the version number, wherein the check report comprises a check result of a first version number, and the check result of the first version number is error information related to version number conflict.
10. The method according to any one of claims 1 to 9, further comprising:
when the check report does not contain error information, sending the interface code to a target terminal where an account with the evaluation authority is located;
receiving a review result returned by the target terminal, wherein the review result is obtained after the interface code is reviewed;
and when the evaluation result is that the interface code passes, generating an interface code file corresponding to the interface code.
11. The method of any of claims 1 to 9, wherein the trigger operation comprises a merge request for merging the interface code with code of a source branch.
12. The method of any one of claims 1 to 9, wherein the check report includes error information corresponding to the interface code, and the error information includes at least one of an error name, a non-compliant style check rule, an error path, and an illegal value.
13. A code verification apparatus, comprising:
the first display module is used for displaying the interface code on the interface;
the checking module is used for responding to the triggering operation of the interface code and carrying out code style checking on the interface code according to a preset style checking rule to obtain a checking result;
and the second display module is used for displaying a verification report, and the verification report is generated according to the verification result.
14. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor, when executing the computer program, implements the steps of the method of any of claims 1 to 12.
15. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the steps of the method according to any one of claims 1 to 12.
CN202010264603.8A 2020-04-07 2020-04-07 Code checking method and device, computer equipment and storage medium Pending CN113495835A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010264603.8A CN113495835A (en) 2020-04-07 2020-04-07 Code checking method and device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010264603.8A CN113495835A (en) 2020-04-07 2020-04-07 Code checking method and device, computer equipment and storage medium

Publications (1)

Publication Number Publication Date
CN113495835A true CN113495835A (en) 2021-10-12

Family

ID=77995208

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010264603.8A Pending CN113495835A (en) 2020-04-07 2020-04-07 Code checking method and device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113495835A (en)

Similar Documents

Publication Publication Date Title
CN111274782B (en) Text auditing method and device, computer equipment and readable storage medium
US10423709B1 (en) Systems, devices, and methods for automated and programmatic creation and deployment of remediations to non-compliant web pages or user interfaces
Pandita et al. {WHYPER}: Towards automating risk assessment of mobile applications
US8983935B2 (en) Methods for utilizing a javascript emulator in a web content proxy server and devices thereof
US11120213B2 (en) Intelligent verification of presentation of a user interface
CN111176996A (en) Test case generation method and device, computer equipment and storage medium
CN111507086B (en) Automatic discovery of translated text locations in localized applications
CN112015430A (en) JavaScript code translation method and device, computer equipment and storage medium
CN111026319B (en) Intelligent text processing method and device, electronic equipment and storage medium
US11620444B2 (en) Providing action associated with event detected within communication
CN113076104A (en) Page generation method, device, equipment and storage medium
US11860955B2 (en) Method and system for providing alternative result for an online search previously with no result
JP7254925B2 (en) Transliteration of data records for improved data matching
CN111159016A (en) Standard detection method and device
US10255249B1 (en) Previewing electronic book content within third-party websites
CN111475700A (en) Data extraction method and related equipment
CN115328759A (en) Form verification method and device
US20180314683A1 (en) Method and device for processing natural language
RU2632149C2 (en) System, method and constant machine-readable medium for validation of web pages
US11562121B2 (en) AI driven content correction built on personas
US11630805B2 (en) Method and device to automatically identify themes and based thereon derive path designator proxy indicia
CN113495835A (en) Code checking method and device, computer equipment and storage medium
CN111400623B (en) Method and device for searching information
US20150324333A1 (en) Systems and methods for automatically generating hyperlinks
Ou et al. Viopolicy-detector: An automated approach to detecting GDPR suspected compliance violations in websites

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