CN102193859B - Code analysis method and system - Google Patents

Code analysis method and system Download PDF

Info

Publication number
CN102193859B
CN102193859B CN201010118401.9A CN201010118401A CN102193859B CN 102193859 B CN102193859 B CN 102193859B CN 201010118401 A CN201010118401 A CN 201010118401A CN 102193859 B CN102193859 B CN 102193859B
Authority
CN
China
Prior art keywords
code
search engine
program
analysis
code analysis
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201010118401.9A
Other languages
Chinese (zh)
Other versions
CN102193859A (en
Inventor
白广元
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Shiji Guangsu Information Technology Co Ltd
Original Assignee
Shenzhen Shiji Guangsu Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Shiji Guangsu Information Technology Co Ltd filed Critical Shenzhen Shiji Guangsu Information Technology Co Ltd
Priority to CN201010118401.9A priority Critical patent/CN102193859B/en
Publication of CN102193859A publication Critical patent/CN102193859A/en
Application granted granted Critical
Publication of CN102193859B publication Critical patent/CN102193859B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Abstract

The invention is suitable for the field of computer software and provides a code analysis method and system. The method comprises the following steps of: collecting code information and establishing an index database; according to a configured checking rule, querying the index database, thereby acquiring a query result; and performing code analysis on the query result and outputting a code analysis result. According to the method, the code is collected, the index is established and the code query result is analyzed, so that code reading is separated from code analysis, the efficiency and flexibility of code analysis are greatly increased, the enterprise-level codes are analyzed and managed, and code collection and the index can be realized by utilizing a search engine.

Description

A kind of code analysis methods and system
Technical field
The invention belongs to computer software fields, relate in particular to a kind of code analysis methods and system.
Background technology
Code analysis claims again code scans or code check, mainly checks that source program code is to the degree of following of standard, readable height, the correctness of code logic expression, the aspects such as rationality of code structure.By code analysis, run counter to the problem of programming standard in can discovery procedure, and dangerous, indefinite and fuzzy part in program, find out and in program, repeat or portable part not.Code analysis comprises the contents such as variable inspection, name and type examination, programmed logic examination, program syntax inspection and program structure inspection.
At present, the instrument of code analysis has a lot, the technical method adopting is similar, as shown in Figure 1, generally be divided into fetch program, analyzer and form and show three parts, most of instrument can self-defined inspections rule, and main difference concentrates on the regular formulation of inspection and the difference of analyzer algorithm.
There is following shortcoming in existing code analysis tool:
(1) low, the consuming time length of analysis efficiency, cannot be competent at the code administration of enterprise-level;
(2) code reads and analysis is coupled, and after checking that rule changes, code reads with code analysis need of work and again does;
(3) as the code change of analyzing, can only be again execution analyzer from the beginning, be therefore difficult to the analysis of code while frequently changing;
(4) statistical study of more applicable single or a small amount of code file, in the face of huge code library, cannot do the comparative analysis between file and file, such as function call situation, duplicated code rate, code reuse situation, Module Division situation etc.
Summary of the invention
The object of the embodiment of the present invention is to provide a kind of code analysis methods, is intended to solve that existing code analysis efficiency is low, flexibility ratio is poor, is not suitable with the problem of enterprise-level code analysis.
The embodiment of the present invention is achieved in that a kind of code analysis methods, and described method comprises the steps:
Collect code information, set up index database;
According to the inspection rule of configuration, inquire about described index database, obtain Query Result;
Described Query Result is carried out to code analysis, output code analysis result.
Another object of the embodiment of the present invention is to provide a kind of code analysis system, and described system comprises:
Indexing units, for collecting code information, sets up index database, and query interface is provided;
Code profiler, for according to the inspection rule of configuration, inquires about described index database by described query interface, obtains Query Result, Query Result is carried out to code analysis, output code analysis result; And
Code analysis display unit, for the code analysis result of code profiler output described in output display.
The embodiment of the present invention is collected code, set up index, for symbol lookup result, analyze, having realized code reads with code analysis and is separated, efficiency and the flexibility ratio of code analysis have greatly been promoted, can realize the analysis management of enterprise-level code, code is collected with index and can be realized by search engine.
Accompanying drawing explanation
Fig. 1 is the schematic diagram of realizing of the code analysis that provides of prior art;
Fig. 2 is the realization flow figure of the code analysis methods that provides of the embodiment of the present invention;
Fig. 3 is the structural drawing of the code analysis system that provides of the embodiment of the present invention.
Embodiment
In order to make object of the present invention, technical scheme and advantage clearer, below in conjunction with drawings and Examples, the present invention is further elaborated.Should be appreciated that specific embodiment described herein, only in order to explain the present invention, is not intended to limit the present invention.
The embodiment of the present invention is collected processing to code, sets up index database, utilizes high speed query interface to inquire about, and Query Result is carried out to code analysis, can greatly improve efficiency and the flexibility ratio of code analysis, realizes the analysis management of enterprise-level code.
Fig. 2 shows the realization flow of the code analysis methods that the embodiment of the present invention provides, and details are as follows:
In step S101, collect code information, set up index database;
As one embodiment of the present of invention, utilize search engine to collect code information, set up index database.Search engine can utilize existing search engine, also can self-developing.Search engine can be collected code information according to certain strategy, and after code information is organized and processed, the code information after output is processed, for rear end code analysis provides retrieval service.
Search engine in the embodiment of the present invention is full-text search engine, extracts the code information in each software program, sets up index data base, and can retrieve the record matching with querying condition, by certain putting in order, returns to Query Result, and detailed process is as follows:
1, the code information in capture program
Search engine has corresponding code capture program (Web Crawler), can from huge enterprise-level program code storehouse, capture continuously the code information in each program.
2, process the code capturing, set up index database
Search engine is caught after code information, do a large amount of pre-service work, and most important is exactly the keyword extracting in code information, sets up index database.
As one embodiment of the present of invention, search engine can monitor the code variations situation of target program easily, even if code changes, only need to again read and analyze the code section of variation, therefore can adapt to the code analysis under the frequent change conditions of code.
In step S102, according to the inspection rule of configuration, search index storehouse, obtains Query Result;
In embodiments of the present invention, during code analysis, directly code is not analyzed, but the query interface providing based on search engine, according to the inspection rule input inquiry condition of configuration, search index storehouse, the Query Result that search engine is returned carries out statistical study, can greatly promote the efficiency of statistics and comparative analysis.
In step S103, Query Result is analyzed to output analysis result.
In embodiments of the present invention, according to the Query Result of search engine, can realize the comparative analysis between code in huge source code library, such as finding out in whole project or enterprise the called situation of certain function etc., can also do high-rise logic analysis to code, such as duplicated code rate, code reuse situation, Module Division situation etc.
The embodiment of the present invention is by carrying out combination by search engine and two kinds of proven technique of code profiler, the ability of utilizing search engine to collect text message is collected code information, preserve the necessary information in code, according to keywords create index, so just possessed the full-text search ability to code library.During code analysis, directly code is not analyzed, but the query interface providing based on search engine, Query Result is carried out to statistical study, can greatly promote the efficiency of statistics and comparative analysis, for example can first retrieve the code file that comprises certain function definition, again these code files are analyzed, judge that whether these function inside are also identical, to find out quickly and easily duplicated code.
Fig. 3 shows the structure of the code analysis system that the embodiment of the present invention provides, and for convenience of explanation, only shows the part relevant to the embodiment of the present invention.
Indexing units 1 is collected code information, sets up index database, and query interface is provided.
As one embodiment of the present of invention, using search engine as indexing units, search engine can utilize existing search engine, also can self-developing.
Code information in searcher 11 discoveries and acquisition program.
Index 12 is processed the code information that searcher 11 searches, and therefrom extracts index entry, according to keywords creates index.
The index that index database 13 storage indexs 12 create, for example concordance list.
Searcher 14 provides query interface to code profiler 2, the querying condition search index storehouse 13 providing according to code profiler 2, output Query Result.
Code profiler 2 is regular according to the inspection of configuration, the query interface providing by indexing units 1, and search index storehouse, obtains Query Result, and Query Result is carried out to code analysis, output code analysis result.
In embodiments of the present invention, during code profiler 2 code analysis, directly code is not analyzed, but the query interface providing based on indexing units 1, according to the inspection rule input inquiry condition of configuration, search index storehouse, the Query Result that indexing units 1 is returned carries out statistical study, can greatly promote the efficiency of statistics and comparative analysis.
As one embodiment of the present of invention, symbol lookup logic 21 is according to the inspection rule of configuration, and the query interface input inquiry condition that generates and provide to code search engine 1, receives the Query Result that code search engine 1 returns.
22 pairs of Query Results of code analysis logic carry out code analysis, output code analysis result.
In embodiments of the present invention, code analysis logic 22 is according to the Query Result of search engine, can realize the comparative analysis between code in huge source code library, such as finding out in whole project or enterprise the called situation of certain function etc., can also do high-rise logic analysis to code, such as duplicated code rate, code reuse situation, Module Division situation etc.
The code analysis result of code analysis display unit 3 output display code profiler 2 outputs.
The embodiment of the present invention is collected code, set up index, for symbol lookup result, analyze, having realized code reads with code analysis and is separated, efficiency and the flexibility ratio of code analysis have greatly been promoted, can realize the analysis management of enterprise-level code, code is collected with index and can be realized by search engine.
Particularly, the embodiment of the present invention has the following advantages:
(1) huge code library can be analyzed, the analysis management of enterprise-level code can be realized;
(2) code is read separated with code analysis, if check rule change, only need again do code analysis.Meanwhile, based on search inquiry interface at a high speed, make code analysis efficient, rapid;
(3) can conveniently monitor the change conditions of object code, even if code changes, only need to again read and analyze changing unit, the analysis while can code frequently changing;
(4) expand the scope of application of code analysis, be particularly useful for the mega project that code quantity is huge, or analysis and monitoring to the whole codes of whole enterprise, can also realize spanned item destination code compare of analysis.
The foregoing is only preferred embodiment of the present invention, not in order to limit the present invention, all any modifications of doing within the spirit and principles in the present invention, be equal to and replace and improvement etc., within all should being included in protection scope of the present invention.

Claims (4)

1. a code analysis methods, is characterized in that, described method comprises the steps:
Code capture program by search engine captures continuously the code information in each program from enterprise-level program code storehouse, and extracts the keyword in described code information, based on described keyword, sets up index database;
The step that the described code capture program by search engine captures continuously the code information in each program from enterprise-level program code storehouse comprises: by search engine, monitor the program that whether has code variations, if exist, the code capture program by search engine captures the code information in the program of described code variations;
According to the inspection rule input inquiry condition of configuration, the query interface providing by search engine based on described querying condition is inquired about described index database, obtains Query Result;
The query interface providing by search engine carries out code analysis to described Query Result, output code analysis result.
2. the method for claim 1, is characterized in that, described search engine is full-text search engine.
3. a code analysis system, is characterized in that, described system comprises:
Indexing units, captures the code information each program for the code capture program by search engine continuously from enterprise-level program code storehouse, and extracts the keyword in described code information, based on described keyword, sets up index database; Described indexing units is also specifically for monitor the program that whether has code variations by search engine, if exist, the code capture program by search engine captures the code information in the program of described code variations;
Query unit, for according to the inspection rule input inquiry condition of configuration, the query interface providing by search engine based on described querying condition is inquired about described index database, obtains Query Result;
Result output unit, carries out code analysis for the query interface providing by search engine to described Query Result, output code analysis result.
4. system as claimed in claim 3, is characterized in that, described search engine is full-text search engine.
CN201010118401.9A 2010-03-03 2010-03-03 Code analysis method and system Active CN102193859B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201010118401.9A CN102193859B (en) 2010-03-03 2010-03-03 Code analysis method and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201010118401.9A CN102193859B (en) 2010-03-03 2010-03-03 Code analysis method and system

Publications (2)

Publication Number Publication Date
CN102193859A CN102193859A (en) 2011-09-21
CN102193859B true CN102193859B (en) 2014-09-10

Family

ID=44601957

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201010118401.9A Active CN102193859B (en) 2010-03-03 2010-03-03 Code analysis method and system

Country Status (1)

Country Link
CN (1) CN102193859B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103268354B (en) * 2013-06-04 2019-04-02 百度在线网络技术(北京)有限公司 In search engine between correlation strategy the degree of coupling analysis method and device
CN106575225B (en) * 2014-12-11 2019-07-02 株式会社日立制作所 Module divides auxiliary device, method and storage medium
CN104991909B (en) * 2015-06-19 2018-02-27 扬州大学 A kind of dictionary method for auto constructing for specific software history codes storehouse
CN108446213B (en) * 2017-02-15 2021-08-17 西门子公司 Static code quality analysis method and device

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101017458A (en) * 2007-03-02 2007-08-15 北京邮电大学 Software safety code analyzer based on static analysis of source code and testing method therefor
CN101599047A (en) * 2008-06-05 2009-12-09 埃森哲环球服务有限公司 Software upgrade analysis system

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050081106A1 (en) * 2003-10-08 2005-04-14 Henry Chang Software testing
US7836433B2 (en) * 2006-01-26 2010-11-16 Microsoft Corporation Analyzing binary code

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101017458A (en) * 2007-03-02 2007-08-15 北京邮电大学 Software safety code analyzer based on static analysis of source code and testing method therefor
CN101599047A (en) * 2008-06-05 2009-12-09 埃森哲环球服务有限公司 Software upgrade analysis system

Also Published As

Publication number Publication date
CN102193859A (en) 2011-09-21

Similar Documents

Publication Publication Date Title
CN109684352B (en) Data analysis system, data analysis method, storage medium, and electronic device
CN107886238B (en) Business process management system and method based on mass data analysis
Linares-Vásquez et al. Triaging incoming change requests: Bug or commit history, or code authorship?
US20170132638A1 (en) Relevant information acquisition method and apparatus, and storage medium
CN102542061B (en) Intelligent product classification method
US8463811B2 (en) Automated correlation discovery for semi-structured processes
CN108694221B (en) Data real-time analysis method, module, equipment and device
CN104216948A (en) Difference control method of data model
GB2499079A (en) Semantic and contextual searching of archives of project records documenting knowledge assets e.g. contracts, specifications, etc.
CN102193859B (en) Code analysis method and system
CN110399377A (en) Optimization method, device, electronic equipment and the computer readable storage medium of SQL
US20230325368A1 (en) Automatic data store architecture detection
CN113312377A (en) Automatic-association SQL query statement processing method and device and electronic equipment
CN112100149A (en) Automatic log analysis system
CN101425070A (en) Deadlock positioning method, deadlock positioning device and data system
CN103842973A (en) Monitoring stored procedure execution
CN104462461B (en) The method and device of investigation processing empty value is carried out to list
CN105677723A (en) Method for establishing and searching data labels for industrial signal source
KR20220069482A (en) Big data intelligent collecting system
US10223529B2 (en) Indexing apparatus and method for search of security monitoring data
Breuker et al. Graph theory and model collection management: conceptual framework and runtime analysis of selected graph algorithms
CN112347314B (en) Data resource management system based on graph database
CN108108441A (en) A kind of database table structure analysis method and system
CN107729518A (en) The text searching method and device of a kind of relevant database
CN113722296A (en) Agricultural information processing method and device, electronic equipment and storage medium

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
ASS Succession or assignment of patent right

Owner name: SHENZHEN SHIJI LIGHT SPEED INFORMATION TECHNOLOGY

Free format text: FORMER OWNER: TENGXUN SCI-TECH (SHENZHEN) CO., LTD.

Effective date: 20131101

C41 Transfer of patent application or patent right or utility model
COR Change of bibliographic data

Free format text: CORRECT: ADDRESS; FROM: 518044 SHENZHEN, GUANGDONG PROVINCE TO: 518057 SHENZHEN, GUANGDONG PROVINCE

TA01 Transfer of patent application right

Effective date of registration: 20131101

Address after: A Tencent Building in Shenzhen Nanshan District City, Guangdong streets in Guangdong province science and technology 518057 16

Applicant after: Shenzhen Shiji Guangsu Information Technology Co., Ltd.

Address before: Shenzhen Futian District City, Guangdong province 518044 Zhenxing Road, SEG Science Park 2 East Room 403

Applicant before: Tencent Technology (Shenzhen) Co., Ltd.

C14 Grant of patent or utility model
GR01 Patent grant