CN110309050A - Detection method, device, server and the storage medium of code specification - Google Patents

Detection method, device, server and the storage medium of code specification Download PDF

Info

Publication number
CN110309050A
CN110309050A CN201910426750.8A CN201910426750A CN110309050A CN 110309050 A CN110309050 A CN 110309050A CN 201910426750 A CN201910426750 A CN 201910426750A CN 110309050 A CN110309050 A CN 110309050A
Authority
CN
China
Prior art keywords
code
preset
name
logical
annotated
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
CN201910426750.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.)
OneConnect Financial Technology Co Ltd Shanghai
Original Assignee
OneConnect Financial Technology Co Ltd Shanghai
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 OneConnect Financial Technology Co Ltd Shanghai filed Critical OneConnect Financial Technology Co Ltd Shanghai
Priority to CN201910426750.8A priority Critical patent/CN110309050A/en
Publication of CN110309050A publication Critical patent/CN110309050A/en
Pending legal-status Critical Current

Links

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

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)
  • Storage Device Security (AREA)

Abstract

The present invention relates to the service management fields of software development, disclose a kind of detection method of code specification, and the detection method of the code specification includes: the scanning information for obtaining code file;Based on the scanning information is detected, preset key character in the scanning information is obtained;When getting the preset key character, the corresponding name of code of the preset key character, annotated code, logical code are read;When determining that the name of code, the annotated code, the logical code are unsatisfactory for preset normality condition, marks the name of code, the annotated code, the logical code and be abnormality code and generate prompt file.The invention also discloses a kind of device, server and storage mediums.The present invention, which realizes, can not only quickly detect abnormality code, and can be reduced and write duration and save code review human cost and effectively evade common BUG, be exposed before operation.

Description

Detection method, device, server and the storage medium of code specification
Technical field
The present invention relates to the service management field of software development more particularly to a kind of detection methods of code specification, dress It sets, server and computer readable storage medium.
Background technique
With Software Industry fast development and software requirement it is growing, how quickly to develop specification stable generation Code becomes the problem that all research staff face.Quick exploitation code is conducive to meet user demand rapidly, shortens the R&D cycle, Reduce research and development cost;The code of specification reduces the reading and modification difficulty of code, convenient for the change requirement exploitation of code and dimension Protect cost;And stable code is conducive to improve user satisfaction, improves the quality of product.
During actual code development, code coding specification is abided by with substantially needing to rely on employee's consciousness, Habit is write due to writer, cause code specification degree be also it is irregular, it is such to depend on the employees such as developer The mode that oneself is held, due to lacking automat real-time monitoring, so as to cause the code of writer in practical application Specification effect is less desirable, and execution efficiency is relatively low.
Summary of the invention
The main purpose of the present invention is to provide a kind of detection methods of code specification, it is intended to solve in the prior art by Write habit in writer, cause code specification degree be also it is irregular, cannot be to code that writer writes text The technical issues of part is detected automatically and generates prompt file.
To achieve the above object, the present invention provides a kind of detection method of code specification, the detection of the code specification Method includes:
Obtain the scanning information of code file;
Based on the scanning information is detected, preset key character in the scanning information is obtained;
When getting the preset key character, the corresponding name of code of the preset key character, annotation generation are read Code, logical code;
When determining that the name of code, the annotated code, the logical code are unsatisfactory for preset normality condition, mark The name of code, the annotated code, the logical code are abnormality code and generate prompt file.
Optionally, described when getting the preset key character, read the corresponding code of the preset key character Title, annotated code, logical code, wherein the preset key character includes preset keyword and preset key symbol includes:
When the preset keyword is package or class, the package or the class corresponding generation are read Code title;
When the preset key symbol is "/* " or " // ", "/* " or " // " corresponding annotation generation described in reading Code;
When the preset keyword be inf, if, who or for, read described inf, if, who or for corresponding logic generation Code.
Optionally, described when the preset keyword is package or class, read the package or described After the corresponding name of code of class, further includes:
When reading the name of code, the prefix code of the package or class are obtained, wherein name of code Including prefix code and package or class;
Judge whether the prefix code meets preset normality condition, wherein preset normality condition includes that preset name is big Write rule;
When the initial of the prefix title is unsatisfactory for the preset name capitalization rule, the name of code is determined not Meet the preset normality condition.
Optionally, described when the preset key symbol is "/* " or " // ", "/* " or " // " described in reading is right After the annotated code answered, further includes:
When getting the annotated code, character quantity or " // " between "/* " and " */" described in acquisition when Capable character quantity, wherein between "/the * " and " */" or " // " is when behavior annotated code;
When getting the character quantity of the annotated code, judge whether the character quantity meets preset specification item Part;
When the character quantity is greater than preset threshold value, determine that the annotated code is unsatisfactory for the preset normality condition.
Optionally, described to work as the preset keyword for inf, if, who or for, read described inf, if, who or for After corresponding logical code, further includes:
When getting the logical code, logical code in symbol " { } " is obtained after described inf, if, who or for Logical condition, wherein the logical condition of logical code is in the symbol " { } " after inf, if, who or for;
When getting the logical condition of the logical code, judge whether the logical condition meets preset specification item Part;
When the logical condition is unsatisfactory for preset syntactic analysis format and morphological analysis format, the logic generation is determined Code is unsatisfactory for the preset logic normality condition.
Optionally, when the judgement name of code, the annotated code, the logical code are unsatisfactory for the preset specification When condition, marks the name of code, the annotated code, the logical code and be abnormality code and generate prompt file, wrap It includes:
When the judgement name of code, the annotated code or the logical code are unsatisfactory for the preset normality condition When, marking the annotated code, the name of code or the logical code is abnormality code;
It, will be described when marking the name of code, the annotated code or the logical code is the abnormality code Abnormality code generates prompt file.
Optionally, when the judgement name of code, the annotated code, the logical code are unsatisfactory for the preset specification When condition, mark the name of code, the annotated code, the logical code be abnormality code and generate prompt file it Afterwards, further includes:
When generating the prompt file, the mailbox message or phone information of preset addressee are obtained;
When obtaining the mailbox message or phone information of the preset addressee, mail or short message are edited, by the prompt File is sent to the addressee.
In addition, to achieve the above object, the present invention also provides a kind of detection device of code specification, the code specification The detection device of property includes:
First acquisition unit, for obtaining the scanning information of code file;
Second acquisition unit, for obtaining preset key character in the scanning information based on the scanning information is detected;
Reading unit, for when getting the preset key character, reading the preset key character corresponding generation Code title, annotated code, logical code;
Generation unit is marked, for that ought determine that it is pre- that the name of code, the annotated code, the logical code are unsatisfactory for When setting normality condition, marks the name of code, the annotated code, the logical code and be abnormality code and generate prompt text Part.
Optionally, the reading unit, further includes:
When the preset keyword is package or class, the package or the class corresponding generation are read Code title;
When the preset key symbol is "/* " or " // ", "/* " or " // " corresponding annotation generation described in reading Code;
When the preset keyword be inf, if, who or for, read described inf, if, who or for corresponding logic generation Code.
Optionally, the detection device of the code specification, further includes:
Third acquiring unit, for obtaining the prefix code of package or class when reading name of code, In, name of code includes prefix code and package or class;
First judging unit, for judging whether prefix code meets preset normality condition, wherein preset normality condition packet Include preset name capitalization rule;
First judging unit, for when the initial of prefix title is unsatisfactory for preset name capitalization rule, described in judgement Name of code is unsatisfactory for the preset normality condition.
Optionally, the detection device of the code specification, further includes:
4th acquiring unit obtains the character quantity between "/* " and " */" for when reading annotated code, or " // " is when capable character quantity, wherein between "/* " and " */" or " // " is when behavior annotated code;
Second judgment unit, for when getting the character quantity of the annotated code, judging that the character quantity is It is no to meet preset normality condition;
Second judging unit, for determining that the annotated code is unsatisfactory for when the character quantity is greater than preset threshold value The preset normality condition.
Optionally, the detection device of the code specification, further includes:
5th acquiring unit obtains after inf, if, who or in symbol " { } " for when reading logical code The logical condition of logical code, wherein the logical condition of logical code is in the symbol " { } " after inf, if, who or for;
Third judging unit, for when getting the logical condition of the logical code, judging that the logical condition is It is no to meet preset normality condition;
Third determines subelement, for being unsatisfactory for preset syntactic analysis format and morphological analysis lattice when the logical condition When formula, determine that the logical code is unsatisfactory for the preset logic normality condition.
Optionally, the mark generation unit is specifically used for:
When the judgement name of code, the annotated code or the logical code are unsatisfactory for the preset normality condition When, marking the annotated code, the name of code or the logical code is abnormality code;
It, will be described when marking the name of code, the annotated code or the logical code is the abnormality code Abnormality code generates prompt file.
Optionally, the detection device of the code specification, further includes:
6th acquiring unit, for obtaining the mailbox message or phone of preset addressee when generating the prompt file Information;
Transmission unit, for editing mail or short when obtaining the mailbox message or phone information of the preset addressee Letter, is sent to the addressee for the prompt file.
In addition, to achieve the above object, the present invention also provides a kind of server, the server includes: memory, processing Device and the detection program for being stored in the code specification that can be run on the memory and on the processor, the code rule The step of as above inventing the detection method of the code specification is realized when the detection program of plasticity is executed by the processor.
In addition, to achieve the above object, the present invention also provides a kind of computer readable storage medium, the computer can The detection program that code specification is stored on storage medium is read, when the detection program of the code specification is executed by processor The step of realizing the detection method for the code specification that as above invention is described.
It the detection method of a kind of code specification that the embodiment of the present invention proposes, device, server and computer-readable deposits Storage media, by the scanning information for obtaining code file;Based on the scanning information is detected, obtain preset in the scanning information Key character;When getting the preset key character, the corresponding name of code of the preset key character, annotation generation are read Code, logical code;When determining that the name of code, the annotated code, the logical code are unsatisfactory for preset normality condition, It marks the name of code, the annotated code, the logical code to be abnormality code and generate prompt file, realize not only It can quickly detect abnormality code, and can be reduced and write duration and save code review human cost and effectively evade common BUG is exposed before operation.
Detailed description of the invention
Fig. 1 is the server architecture schematic diagram for the hardware running environment that the embodiment of the present invention is related to;
Fig. 2 is the flow diagram of the detection method first embodiment of code specification of the present invention;
Fig. 3 is the flow diagram of the detection method second embodiment of code specification of the present invention;
Fig. 4 is the flow diagram of the detection method 3rd embodiment of code specification of the present invention;
Fig. 5 is the flow diagram of the detection method fourth embodiment of code specification of the present invention;
Fig. 6 is the flow diagram of the 5th embodiment of detection method of code specification of the present invention;
Fig. 7 is the flow diagram of the detection method sixth embodiment of code specification of the present invention;
Fig. 8 is the flow diagram of the 7th embodiment of detection method of code specification of the present invention.
Specific embodiment
It should be appreciated that the specific embodiments described herein are merely illustrative of the present invention, it is not intended to limit the present invention.
The primary solutions of the embodiment of the present invention are: obtaining the scanning information of code file;Based on the detection scanning Information obtains preset key character in the scanning information;When getting the preset key character, the preset pass is read The corresponding name of code of key characters, annotated code, logical code;When determining the name of code, the annotated code, described patrol When volume code is unsatisfactory for preset normality condition, the name of code, the annotated code, the logical code are marked as abnormal generation Code simultaneously generates prompt file.
Since the prior art writes habit due to writer, cause code specification degree be also it is irregular, cannot The technical issues of code file that writer writes is detected automatically and generates prompt file.
The present invention provides a solution, can not only quickly detect abnormality code, but can be reduced write duration and It saves code review human cost and effectively evades common BUG, be exposed before operation.
As shown in FIG. 1, FIG. 1 is the server architecture schematic diagrames for the hardware running environment that the embodiment of the present invention is related to.
The terminal of that embodiment of the invention is server.
As shown in Figure 1, the terminal may include: processor 1001, such as CPU, network interface 1004, user interface 1003, memory 1005, communication bus 1002.Wherein, communication bus 1002 is for realizing the connection communication between these components. User interface 1003 may include display screen (Display), input unit such as keyboard (Keyboard), optional user interface 1003 can also include standard wireline interface and wireless interface.Network interface 1004 optionally may include that the wired of standard connects Mouth, wireless interface (such as WI-FI interface).Memory 1005 can be high speed RAM memory, be also possible to stable memory (non-volatile memory), such as magnetic disk storage.Memory 1005 optionally can also be independently of aforementioned processor 1001 storage device.
It will be understood by those skilled in the art that the restriction of the not structure paired terminal of terminal structure shown in Fig. 1, can wrap It includes than illustrating more or fewer components, perhaps combines certain components or different component layouts.
As shown in Figure 1, as may include that operating system, network are logical in a kind of memory 1005 of computer storage medium Believe module, the detection program of Subscriber Interface Module SIM and code specification.
In terminal shown in Fig. 1, network interface 1004 is mainly used for connecting background server, carries out with background server Data communication;User interface 1003 is mainly used for connecting client (user terminal), carries out data communication with client;And processor 1001 can be used for calling the detection program of the code specification stored in memory 1005, and execute following operation:
Obtain the scanning information of code file;
Based on detection scanning information, preset key character in scanning information is obtained;
When getting preset key character, the corresponding name of code of preset key character, annotated code, logic generation are read Code;
When determining that name of code, annotated code, logical code are unsatisfactory for preset normality condition, mark name of code, note Release code, logical code is abnormality code and generates prompt file.
Further, processor 1001 can call the detection program of the code specification stored in memory 1005, also Execute following operation:
When preset keyword is package or class, the corresponding name of code of package or class is read;
When preset key symbol is "/* " or " // ", "/* " or " // " corresponding annotated code are read;
When preset keyword is inf, if, who or for, the corresponding logical code of reading inf, if, who or for.
Further, processor 1001 can call the detection program of the code specification stored in memory 1005, also Execute following operation:
When reading the name of code, the prefix code of the package or class are obtained, wherein name of code Including prefix code and package or class;
Judge whether the prefix code meets preset normality condition, wherein preset normality condition includes that preset name is big Write rule;
When the initial of the prefix title is unsatisfactory for the preset name capitalization rule, determine that name of code is unsatisfactory for Preset normality condition.
Further, processor 1001 can call the detection program of the code specification stored in memory 1005, also Execute following operation:
When reading the annotated code, character quantity or " // " between "/* " and " */" described in acquisition when Capable character quantity, wherein between "/the * " and " */" or " // " is when behavior annotated code;
In the character quantity for getting annotated code, judge whether character quantity meets preset normality condition;
When character quantity is greater than preset threshold value, determine that annotated code is unsatisfactory for preset normality condition.
Further, processor 1001 can call the detection program of the code specification stored in memory 1005, also Execute following operation:
When reading logical code, the logic item of logical code in symbol " { } " after inf, if, who or for is obtained Part, wherein the logical condition of logical code is in the symbol " { } " after inf, if, who or for;
In the logical condition for getting logical code, whether decision logic condition meets preset normality condition;
When logical condition is unsatisfactory for preset syntactic analysis format and morphological analysis format, decision logic code is unsatisfactory for The preset logic normality condition.
Further, processor 1001 can call the detection program of the code specification stored in memory 1005, also Execute following operation:
When determining that name of code, annotated code or logical code are unsatisfactory for the preset normality condition, marker annotations generation Code, name of code or logical code are abnormality code;
When marker code title, annotated code or logical code are abnormality code, abnormality code is generated into prompt file.
Further, processor 1001 can call the detection program of the code specification stored in memory 1005, also Execute following operation:
When generating prompt file, the mailbox message or phone information of preset addressee are obtained;
When obtaining the mailbox message or phone information of preset addressee, mail or short message are edited, will be prompted to file transmission To the addressee.
It is the detection method first embodiment of code specification of the present invention, the detection side of code specification referring to Fig. 2, Fig. 2 Method method includes:
Step S10 obtains the scanning information of code file;
Server is scanned the code file received when receiving the code file of terminal transmission.Scanning Mode can be real time scan or timing scan, specifically, when server receives the code file of terminal transmission, server The code file received is scanned in real time.Alternatively, when server receives the code file of terminal transmission, server According to preset time period or moment, when the duration or moment for receiving code file meet preset time period or moment, to code text Part is scanned.When server is scanned code file, the code file information scanned is read.
Step S20 obtains preset key character in scanning information based on detection scanning information;
Step S30 reads the corresponding name of code of preset key character, annotation generation when getting preset key character Code, logical code;
When server reads the scanning information of code file, the scanning file read is detected.Work as detection When including preset keyword into scanning file, the corresponding code information of the keyword is obtained.And code information includes code name Claim information, annotated code information and logical code information etc..Wherein, name of code information includes packet name code, class name generation again Name of code information, the annotated code information such as code, interface name code, method name code, variable name code, constant name code include Uniline annotation or multirow annotation, wherein uniline annotation with " // " indicate, multirow annotation with "/* " indicate, and not only multirow annotation Start code is indicated with "/* ", and end code is also indicated with "/* ".Logical code information generally uses inf, if, who, for etc. It indicates.When using the symbol of name of code information, annotated code information or logical code information as when preset keyword, server When detecting code file, the corresponding code information of preset keyword can be got by preset keyword.For example, when that will wrap When package in name code title is as preset keyword, when server detects in scanning information comprising package, The name information and name information of packet name code can be got by package.Alternatively, by the symbol of annotated code The preset keyword of " // " or "/* " as annotated code, when server detects in scanning information comprising symbol " // " or "/* " When, get symbol " // " or "/* " corresponding annotated code information.Alternatively, making by inf, if, who, for of logical code For preset keyword, when server detects in scanning information comprising inf, if, who, for, get inf, if, who, The corresponding logical code information of for.
Step S40 marks code when determining that name of code, annotated code, logical code are unsatisfactory for preset normality condition Title, annotated code, logical code are abnormality code and generate prompt file.
When server determines that the code information got is unsatisfactory for pre-set normality condition, by the code information mark Note is abnormality code, and the abnormality code of mark is generated file, reminds writer.The form of mark can be with color either Change the modes such as the format of font to be labeled.It, can be with red for example, when User Colors are to be labeled abnormality code The colors such as color, blue are labeled more deeply, or, change the font format of abnormality code to be labeled, by abnormal generation Font amplification of code etc. is labeled.
In the present embodiment, server is in scan code file, reads the scanning information in code file, when scanning When detecting preset keyword in information, the corresponding code information of preset keyword is obtained, it is discontented in the code information got When the preset normality condition of foot, code information is labeled as abnormality code information side and generates prompt file, can not only quickly be detected Abnormality code out, and can be reduced and write duration and save code review human cost and effectively evade common BUG, it is sudden and violent before proposing survey Expose.
Further, it is the detection method second embodiment of code specification of the present invention referring to Fig. 3, Fig. 3, is based on above-mentioned figure Embodiment shown in 2, step S30, comprising:
Step S31 reads the corresponding code name of package or class when preset keyword is package or class Claim;
Step S32 reads "/* " or " // " corresponding annotation generation when preset key symbol is "/* " or " // " Code;
Step S33, when preset keyword is inf, if, who or for, reading inf, if, who or for corresponding logic generation Code.
When server, which detects in the scanning information of code file, preset keyword package or class, so that it may The name information and name information that packet name code is got by package, get class name name of code letter by class Breath and name information, for example, the programming language of code file is java, for java language, Bao Minghui is with package key Word beginning, class name can be started with class keyword.When there is preset crucial symbol in the scanning information that server detects code file When number " // " or "/* ", preset key symbol " // " or "/* " corresponding annotated code are read, wherein uniline annotation symbol is used " // ", indicates that multirow annotation symbol is indicated with "/* ", and not only the beginning code of multirow annotation is indicated with "/* ", end code It is indicated with "/* ".For example, obtaining the generation between two preset key symbols "/* " when getting preset key symbol "/* " Code information, the code between two preset key symbols "/* " is annotated code, when getting preset key symbol is " // ", Reading preset key symbol is the code information after " // ", and the code after preset key symbol " // " is annotated code.When Get preset keyword be inf, if, who or for when, get the corresponding logical code information of inf, if, who, for. For example, obtaining the corresponding logical condition of inf code when getting inf code, usual logical condition indicates in " { } ", and After inf code.
In the present embodiment, server get preset keyword be package or class when, read package or The corresponding name of code of class;When preset key symbol is "/* " or " // ", "/* " or " // " corresponding annotation are read Code;When preset keyword is inf, if, who or for, the corresponding logical code of reading inf, if, who or for, by preset Different key characters can quickly read the corresponding code information of kinds of characters.
It is the detection method 3rd embodiment of code specification of the present invention referring to Fig. 4, Fig. 4, is based on above-mentioned reality shown in Fig. 2 Example is applied, after step S30, before step S40, further includes:
Step S50 obtains the prefix code of package or class when reading name of code;
Step S60, judges whether prefix code meets preset normality condition;
Step S70, when the initial of prefix title is unsatisfactory for preset name capitalization rule, judgement name of code is unsatisfactory for institute State preset normality condition.
When server is when getting code information is name of code, name of code corresponding name of code letter is got Breath.Name of code includes packet name code, class name code, interface name code, method name code, variable name code, constant name code Equal name of code.For example, getting the corresponding packet name code name of package when the preset keyword detected is package Claim, alternatively, getting the corresponding class name name of code of class when detecting preset keyword is class.Getting packet Any one name of code such as name code, class name code, interface name code, method name code, variable name code, constant name code When, obtain the name information of name of code.In the name information for getting name of code, the name information of name of code is judged Whether preset normality condition is met.When the name information of name of code is unsatisfactory for the name of the program language in preset normality condition When format, determine that the name information of name of code is unsatisfactory for preset normality condition.Wherein, programming language is server scan code When file, the project file title of scan code file.When getting the suffix name in project file title, according to getting Suffix name, determine the program language of code in code file.In the program language for getting code file, according to program word Speech gets the capitalization rule of the program language in preset normality condition, and the code prefix of usual name of code is by groups such as letters At, and initial regulation will be capitalized.For example, determining that the programming language of code is as the entitled class of the suffix got Java, for java language, Bao Minghui can be using class keyword as name of code with the beginning of package keyword, class name Suffix etc..
In the present embodiment, when the code information that server is got is name of code, the name of Huqiu name of code Information determines whether the name information of name of code meets preset normality condition in the name information for getting name of code, When the name information of name of code is unsatisfactory for the name format of the program language in preset normality condition, the life of name of code is determined Name information is unsatisfactory for preset normality condition.It, can be to the code that writer writes by the name format of preset code title Automatically it is detected, can be reduced and write duration and save code review human cost and effectively evade common BUG, it is sudden and violent before proposing survey Expose.
It is the detection method fourth embodiment of code specification of the present invention referring to Fig. 5, Fig. 5, is based on above-mentioned reality shown in Fig. 3 Example is applied, after step S30, before step S40, further includes:
Step S80 obtains the character quantity between "/* " and " */", or " // " when capable when reading annotated code Character quantity;
Step S90 judges whether character quantity meets preset specification item in the character quantity for getting annotated code Part;
Step S100 determines that annotated code is unsatisfactory for preset normality condition when character quantity is greater than preset threshold value.
It is " // " or "/* " when server gets preset keyword, obtains the annotated code information in " // " or "/* ". Annotated code is programmed in " // " or "/* " in code file, when getting annotated code, obtains annotated code in " // " Character quantity between capable character quantity or "/* " and " */".When getting the character quantity of annotated code, judgement Whether the character quantity of annotated code meets preset normality condition.When the character quantity of annotated code is greater than preset threshold value, sentence Determine annotated code and is unsatisfactory for preset normality condition.For example, when the character quantity for getting annotated code is 25, and preset threshold value When being also 25, determine that the character quantity of annotated code meets preset normality condition, when the character quantity for getting annotated code is When 26, the character quantity 26 of annotated code is greater than preset threshold value 25, determines that the character quantity of annotated code is unsatisfactory for preset specification Condition.
In the present embodiment, when the code information that server is got is annotated code, the character of annotated code is obtained Quantity judges whether the character quantity of annotated code meets preset specification item in the character quantity for getting annotated code Part.When the character quantity of annotated code is greater than preset threshold value, determine that annotated code is unsatisfactory for preset normality condition.By to note It releases character quantity in code and carries out preset, the code that writer writes can be detected automatically, be can be reduced when writing Long and saving code review human cost simultaneously effectively evades common BUG, is exposed before proposing survey.
It is the 5th embodiment of detection method of code specification of the present invention referring to Fig. 6, Fig. 6, is based on above-mentioned reality shown in Fig. 3 Example is applied, after step S30, before step S40, further includes:
Step S110, when reading logical code, logical code in symbol " { } " after acquisition inf, if, who or for Logical condition;
Step S120, when the logical condition of logical code is stated in acquisition, whether decision logic condition meets preset specification item Part;
Step S130, when logical condition is unsatisfactory for preset syntactic analysis format and morphological analysis format, decision logic Code is unsatisfactory for preset logic normality condition.
When the code information that server is got is for, according to pre-set logical code, judge for whether be Logical code, pre-set logical code include inf, if, who, for etc..When getting inf code, inf code is obtained Corresponding logical condition, the expression in " { } " of usual logical condition, and after inf code.When reading the logic in " { } " When condition, judge whether the logical condition read meets preset normality condition.When logic language in the logical condition read Sentence when, according in preset normality condition morphological analysis format and syntactic analysis format in logical condition logical statement carry out Analysis.Specifically, morphological analysis is that the character string in logical statement is converted to the process of word sequence.Syntactic analysis be Word sequence is combined into all kinds of grammatical phrases on the basis of morphological analysis.When passing through syntactic analysis and morphological analysis, do not obtain When getting the grammatical phrases in logical condition, decision logic code is unsatisfactory for preset logic normality condition.
In the present embodiment, when the code information that server is got is logical code, the logic of logical code is obtained Condition, when getting the logical condition of logical code, whether the logical condition of decision logic code meets preset specification item Part, when the logical condition got is unsatisfactory for preset syntactic analysis format and morphological analysis format, decision logic code is discontented The preset normality condition of foot.It is automatically analyzed by the logical condition to logical code, can be reduced and write duration and save code Evaluation human cost simultaneously effectively evades common BUG, is exposed before proposing survey.
It is the detection method sixth embodiment of code specification of the present invention referring to Fig. 7, Fig. 7, is based on above-mentioned reality shown in Fig. 2 Example is applied, step S40 includes:
Step S41, when determining that name of code, annotated code or logical code are unsatisfactory for preset normality condition, label note Releasing code, name of code or logical code is abnormality code;
Step S42 generates abnormality code when marker code title, annotated code or logical code are abnormality code Prompt file.
When server determines that name of code, annotated code or logical code are unsatisfactory for preset normality condition, by code Title, annotated code or logical code are labeled as abnormality code, and the abnormality code of mark is generated file, reminds writer. The form of mark can either change the modes such as the format of font with color and be labeled.For example, working as with color come to exception When code is labeled, abnormality code title can be labeled as to red, abnormal annotated code is labeled as blue, will be patrolled extremely It collects code and is labeled as yellow, or, change the font format of abnormality code to be labeled, the font of abnormality code is amplified Etc. being labeled.
In the present embodiment, when server determines that name of code, annotated code or logical code are unsatisfactory for preset specification When condition, name of code, annotated code or logical code are labeled as abnormality code, the abnormality code of mark is generated into file. Abnormality code is effectively marked to and generated prompt file, achievees the effect that prompting.
It is the 7th embodiment of detection method of code specification of the present invention referring to Fig. 8, Fig. 8, is based on above-mentioned reality shown in Fig. 2 Example is applied, after step S40, further includes:
Step S140 obtains the mailbox message or phone information of preset addressee when generating prompt file;
Step S150 edits mail or short message, will be prompted to when obtaining the mailbox message or phone information of preset addressee File is sent to addressee.
When server generates the prompt file of abnormality code, preset addressee information, addressee information packet are got Include phone information or e-mail messages etc..When server gets addressee's phone information or e-mail messages, pass through the shape of mail Formula will be prompted to file and be sent to addressee or will be prompted to file by way of short message be sent to addressee.
In the present embodiment, server obtains the mailbox letter of preset addressee when generating the prompt file of abnormality code Breath or phone information edit mail or short message, will be prompted to file and be sent to addressee.Abnormality code is generated into prompt file, hair Addressee is sent, common BUG can be effectively evaded, is exposed before proposing survey.
In addition, the embodiment of the present invention also proposes that a kind of server, server include: memory, processor and be stored in On reservoir and the detection program of code specification that can run on a processor, the detection program of code specification are held by processor The step of detection method of the code specification of embodiment as above is realized when row.
In addition, the embodiment of the present invention also proposes a kind of computer readable storage medium, deposited on computer readable storage medium The detection program of code specification is contained, the detection program of code specification realizes the generation of embodiment as above when being executed by processor The step of detection method of code normalization.
It should be noted that, in this document, the terms "include", "comprise" or its any other variant are intended to non-row His property includes, so that the process, method, article or the system that include a series of elements not only include those elements, and And further include other elements that are not explicitly listed, or further include for this process, method, article or system institute it is intrinsic Element.In the absence of more restrictions, the element limited by sentence "including a ...", it is not excluded that including being somebody's turn to do There is also other identical elements in the process, method of element, article or system.
The serial number of the above embodiments of the invention is only for description, does not represent the advantages or disadvantages of the embodiments.
Through the above description of the embodiments, those skilled in the art can be understood that above-described embodiment side Method can be realized by means of software and necessary general hardware platform, naturally it is also possible to by hardware, but in many cases The former is more preferably embodiment.Based on this understanding, technical solution of the present invention substantially in other words does the prior art The part contributed out can be embodied in the form of software products, which is stored in one as described above In storage medium (such as ROM/RAM, magnetic disk, CD), including some instructions are used so that terminal device (it can be mobile phone, Computer, server, air conditioner or network equipment etc.) execute method described in each embodiment of the present invention.
The above is only a preferred embodiment of the present invention, is not intended to limit the scope of the invention, all to utilize this hair Equivalent structure or equivalent flow shift made by bright specification and accompanying drawing content is applied directly or indirectly in other relevant skills Art field, is included within the scope of the present invention.

Claims (10)

1. a kind of detection method of code specification, which is characterized in that the detection method of the code specification includes:
Obtain the scanning information of code file;
Based on the scanning information is detected, preset key character in the scanning information is obtained;
When getting the preset key character, reads the corresponding name of code of the preset key character, annotated code, patrols Collect code;
When determining that the name of code, the annotated code, the logical code are unsatisfactory for preset normality condition, described in mark Name of code, the annotated code, the logical code are abnormality code and generate prompt file.
2. the detection method of code specification as described in claim 1, which is characterized in that described to get the preset pass When key characters, the corresponding name of code of the preset key character, annotated code, logical code are read, wherein the preset pass Key characters include preset keyword and preset key symbol includes:
When the preset keyword is package or class, the package or the corresponding code name of the class are read Claim;
When the preset key symbol is "/* " or " // ", "/* " or " // " corresponding annotated code described in reading;
When the preset keyword be inf, if, who or for, read the corresponding logical code of described inf, if, who or for.
3. the detection method of code specification as claimed in claim 2, which is characterized in that described when the preset keyword is When package or class, after reading the package or the corresponding name of code of the class, further includes:
When reading the name of code, the prefix code of the package or class are obtained, wherein name of code includes Prefix code and package or class;
Judge whether the prefix code meets preset normality condition, wherein preset normality condition includes preset name capitalization rule Then;
When the initial of the prefix title is unsatisfactory for the preset name capitalization rule, determine that the name of code is unsatisfactory for The preset normality condition.
4. the detection method of code specification as claimed in claim 2, which is characterized in that described to work as the preset key symbol When for "/* " or " // ", after "/* " or " // " corresponding annotated code described in reading, further includes:
When reading the annotated code, the character quantity or " // " between "/* " and " */" described in acquisition are when capable Character quantity, wherein between "/the * " and " */" or " // " is when behavior annotated code;
When getting the character quantity of the annotated code, judge whether the character quantity meets preset normality condition;
When the character quantity is greater than preset threshold value, determine that the annotated code is unsatisfactory for the preset normality condition.
5. the detection method of code specification as claimed in claim 2, which is characterized in that described when the preset keyword is Inf, if, who or for, after reading the corresponding logical code of described inf, if, who or for, further includes:
When reading the logical code, patrolling for logical code in symbol " { } " is obtained after described inf, if, who or for The condition of collecting, wherein the logical condition of logical code is in the symbol " { } " after inf, if, who or for;
When getting the logical condition of the logical code, judge whether the logical condition meets preset normality condition;
When the logical condition is unsatisfactory for preset syntactic analysis format and morphological analysis format, the logical code is determined not Meet the preset logic normality condition.
6. the detection method of the code specification as described in claim 3-5, which is characterized in that described when the judgement code name When title, the annotated code, the logical code are unsatisfactory for the preset normality condition, the name of code, the note are marked Release code, the logical code is abnormality code and generates prompt file, comprising:
When determining that the name of code, the annotated code or the logical code are unsatisfactory for the preset normality condition, mark Remember that the annotated code, the name of code or the logical code are abnormality code;
When marking the name of code, the annotated code or the logical code is the abnormality code, by the exception Code building prompts file.
7. the detection method of code specification as described in claim 1, which is characterized in that described when the judgement code name When title, the annotated code, the logical code are unsatisfactory for the preset normality condition, the name of code, the note are marked Release code, the logical code be abnormality code and generate prompt file after, further includes:
When generating the prompt file, the mailbox message or phone information of preset addressee are obtained;
When obtaining the mailbox message or phone information of the preset addressee, mail or short message are edited, by the prompt file It is sent to the addressee.
8. a kind of detection device of code specification, which is characterized in that the detection device of the code specification includes:
First acquisition unit, for obtaining the scanning information of code file;
Second acquisition unit, for obtaining preset key character in the scanning information based on the scanning information is detected;
Reading unit, for when getting the preset key character, reading the corresponding code name of the preset key character Title, annotated code, logical code;
Generation unit is marked, for being unsatisfactory for preset rule when the judgement name of code, the annotated code, the logical code When model condition, marks the name of code, the annotated code, the logical code and be abnormality code and generate prompt file.
9. a kind of server, which is characterized in that the server includes: memory, processor and is stored on the memory And the detection program for the code specification that can be run on the processor, the detection program of the code specification is by the place It manages and is realized when device executes as described in any one of claims 1 to 7 the step of the detection method of code specification.
10. a kind of computer readable storage medium, which is characterized in that be stored with code rule on the computer readable storage medium The detection program of plasticity is realized when the detection program of the code specification is executed by processor as any in claim 1 to 7 The step of detection method of code specification described in.
CN201910426750.8A 2019-05-22 2019-05-22 Detection method, device, server and the storage medium of code specification Pending CN110309050A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910426750.8A CN110309050A (en) 2019-05-22 2019-05-22 Detection method, device, server and the storage medium of code specification

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910426750.8A CN110309050A (en) 2019-05-22 2019-05-22 Detection method, device, server and the storage medium of code specification

Publications (1)

Publication Number Publication Date
CN110309050A true CN110309050A (en) 2019-10-08

Family

ID=68075469

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910426750.8A Pending CN110309050A (en) 2019-05-22 2019-05-22 Detection method, device, server and the storage medium of code specification

Country Status (1)

Country Link
CN (1) CN110309050A (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111061488A (en) * 2019-12-18 2020-04-24 深圳前海环融联易信息科技服务有限公司 Method and device for detecting quality of front-end code, computer equipment and storage medium
CN112276263A (en) * 2020-10-14 2021-01-29 宁波市博虹机械制造开发有限公司 G code-based special motion control method for electric spark forming machine
CN112651213A (en) * 2020-12-25 2021-04-13 军工保密资格审查认证中心 Safety examination method and device for numerical control program
CN116483377A (en) * 2023-06-15 2023-07-25 太平金融科技服务(上海)有限公司深圳分公司 Code detection method and device, electronic equipment and storage medium
CN118333020A (en) * 2024-06-12 2024-07-12 中科航迈数控软件(深圳)有限公司 Code labeling method, equipment and computer readable storage medium

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2010140407A (en) * 2008-12-15 2010-06-24 Nomura Research Institute Ltd Source code inspection device
WO2013139216A1 (en) * 2012-03-21 2013-09-26 北京奇虎科技有限公司 Method and device for extracting characteristic code of apk virus
CN103678118A (en) * 2013-10-18 2014-03-26 北京奇虎测腾科技有限公司 Method and device for compliance detection of Java source code
CN106227668A (en) * 2016-07-29 2016-12-14 腾讯科技(深圳)有限公司 Data processing method and device
CN106371997A (en) * 2016-09-07 2017-02-01 网易(杭州)网络有限公司 Code checking method and device
CN106648467A (en) * 2016-12-28 2017-05-10 税友软件集团股份有限公司 Log generation method and system
CN108205493A (en) * 2016-12-20 2018-06-26 腾讯科技(深圳)有限公司 A kind of code detection method, terminal, server and system
CN108549538A (en) * 2018-04-11 2018-09-18 深圳市腾讯网络信息技术有限公司 A kind of code detection method, device, storage medium and test terminal
CN108614707A (en) * 2018-04-27 2018-10-02 深圳市腾讯网络信息技术有限公司 Static code inspection method, device, storage medium and computer equipment
CN109491884A (en) * 2018-09-26 2019-03-19 平安普惠企业管理有限公司 Code method for testing performance, device, computer equipment and medium

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2010140407A (en) * 2008-12-15 2010-06-24 Nomura Research Institute Ltd Source code inspection device
WO2013139216A1 (en) * 2012-03-21 2013-09-26 北京奇虎科技有限公司 Method and device for extracting characteristic code of apk virus
CN103678118A (en) * 2013-10-18 2014-03-26 北京奇虎测腾科技有限公司 Method and device for compliance detection of Java source code
CN106227668A (en) * 2016-07-29 2016-12-14 腾讯科技(深圳)有限公司 Data processing method and device
CN106371997A (en) * 2016-09-07 2017-02-01 网易(杭州)网络有限公司 Code checking method and device
CN108205493A (en) * 2016-12-20 2018-06-26 腾讯科技(深圳)有限公司 A kind of code detection method, terminal, server and system
CN106648467A (en) * 2016-12-28 2017-05-10 税友软件集团股份有限公司 Log generation method and system
CN108549538A (en) * 2018-04-11 2018-09-18 深圳市腾讯网络信息技术有限公司 A kind of code detection method, device, storage medium and test terminal
CN108614707A (en) * 2018-04-27 2018-10-02 深圳市腾讯网络信息技术有限公司 Static code inspection method, device, storage medium and computer equipment
CN109491884A (en) * 2018-09-26 2019-03-19 平安普惠企业管理有限公司 Code method for testing performance, device, computer equipment and medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
刘竹林;: "对C语言编码规范的探讨", 山西电子技术, no. 01, 15 February 2011 (2011-02-15) *

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111061488A (en) * 2019-12-18 2020-04-24 深圳前海环融联易信息科技服务有限公司 Method and device for detecting quality of front-end code, computer equipment and storage medium
CN112276263A (en) * 2020-10-14 2021-01-29 宁波市博虹机械制造开发有限公司 G code-based special motion control method for electric spark forming machine
CN112651213A (en) * 2020-12-25 2021-04-13 军工保密资格审查认证中心 Safety examination method and device for numerical control program
CN116483377A (en) * 2023-06-15 2023-07-25 太平金融科技服务(上海)有限公司深圳分公司 Code detection method and device, electronic equipment and storage medium
CN116483377B (en) * 2023-06-15 2024-03-01 太平金融科技服务(上海)有限公司深圳分公司 Code detection method and device, electronic equipment and storage medium
CN118333020A (en) * 2024-06-12 2024-07-12 中科航迈数控软件(深圳)有限公司 Code labeling method, equipment and computer readable storage medium

Similar Documents

Publication Publication Date Title
CN110309050A (en) Detection method, device, server and the storage medium of code specification
US7831913B2 (en) Selection-based item tagging
US7251809B2 (en) Dynamic generation of program execution trace files in a standard markup language
CN106528400A (en) MOCK testing method and device
RU2008101465A (en) CONTENT OF NEWSLETTER AND E-MAIL
US20130007749A1 (en) Method and apparatus for managing a working task based on a communication message
CN109101583A (en) A kind of knowledge mapping construction method and system for non-structured text
CN110309039A (en) Automation obtains method, apparatus, equipment and the storage medium of application log
CN110334214A (en) A kind of method of false lawsuit in automatic identification case
CN104320793B (en) A kind of Automated testing method of cell phone short messages and system
CN108804469A (en) A kind of web page identification method and electronic equipment
CN107992545A (en) A kind of searching method, device, terminal and readable storage medium storing program for executing
CN105094824B (en) A kind of notification message methods of exhibiting on smartwatch and a kind of smartwatch
EP1881419A3 (en) Method and arrangement for obtaining an electronic mail service
JP2004233577A (en) Method for forming speech recognition dictionary
JP2008204286A (en) Motivation management device and motivation management system
WO2024055603A1 (en) Method and apparatus for identifying text from minor
CN107590060A (en) A kind of analysis method and device of terminal interim card
CN101201877A (en) System for going over examination papers capable of self-defining mark and implementing method thereof
Ängeslevä et al. EmoteMail
CN109086440A (en) A kind of method and system of knowledge extraction
CN110321271A (en) Method, apparatus, equipment and the storage medium of exception information are obtained based on Monkey
CN113034327A (en) Old people long-term care demand evaluation input system and method
JPH03288226A (en) Software evaluating method
CN109617782A (en) A kind of method for sending information, client, storage medium and equipment

Legal Events

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