The quantitative analysis method of a kind of software quality evaluation device and software quality evaluation
Technical field
The present invention relates to software quality assurance technology in the field of software engineering, relate in particular to the quantitative analysis method of a kind of software quality evaluation device and software quality evaluation.
Background technology
Flourish along with infotech, computing machine is applied in all trades and professions more and more widely.As the soul of infotech, the scale of software is also enlarging day by day, and this has not only caused the raising of program complexity, has also reduced the reliability of software self.Therefore, guaranteeing software quality, is the major issue that extends through the whole software life cycle, and it then is a kind of important means that guarantees software quality that software quality is carried out estimating effectively quantitatively.
Because software product has complicacy, abstractness, uncertainty and is difficult to characteristics such as tolerance, and people are to the limitation and the non-systemic of software quality understanding, the evaluation of software quality is fuzzy and uncertain often, and this makes that software quality evaluation is difficult problem in the software quality assurance always.For many years, the various countries researchist has carried out intensive research to it.1976, people such as Boehm proposed the model of quantitative evaluation software quality, and they are divided into three aspects to the quality of software product: portability, workability, maintainability, thus obtain the overall evaluation of software quality.1978, people such as McCall proposed the quality metric model of tri-layer: quality factor-interpretational criteria-tolerance.And defined 11 quality factors and 23 interpretational criterias and come respectively these quality factors being described, thereby the quality of reflection product.These two kinds of models all are the reticulate texture models, and they measure from the angle of product, do not consider from the angle of user's request.And the reticulate texture of their complexity, in the process of tolerance, also be difficult for realizing quantification.1991, by ISO (International Standards Organization) (ISO, InternationalOrganization for Standardization) and (IEC of International Electrotechnical Commission, InternationalElectrotechnical Commission) unites and formulated ISO/IEC 9126 software product evaluation criterions, first software quality evaluation is determined with the form of standard, this standard has been considered 6 qualitative factors of software from user's angle, and has stipulated its corresponding 21 quality standards.Its software quality metric model is a tree structure, is divided into 3 layers: qualitative factor-quality standard-metric, as shown in Figure 1.Though 9126 standards and not mentioned concrete evaluation method still have important directive function for the quality assessment of software.
Through application enhancements constantly, ISO/IEC 9126 standards have now become the main reference foundation of software quality evaluation.Software quality evaluation instrument based on this standard has also occurred much, but can not adapt to actual demand fully mostly, has defective at aspects such as versatility and dirigibilities.The measurement facility that for example has can only be measured the software of certain language compilation, is subjected to the restriction of language version, and versatility is not enough; There is limitation in the measurement facility that has on metric, can not adapt to the various tolerance demands of user neatly.Though some researchists have proposed corresponding improvement measures, such as with the tolerance middleware being core or based on the software architecture of knowledge base etc., all belong to the solution under the perfect condition, complex structure is difficult to realize in reality.
Evaluation method research at present for software quality is many, and concrete implementation also has their own characteristics each.As a whole, the method for having announced at present can not be made accurately quantitative evaluation to software quality.Such as: the evaluation method that has adopts 0~1 discrimination standard on metric, that is to say, if the value of metric drops in the given interval, then judge value is 1, if drop on interval outside, then judge value is 0.This method of discrimination is too general to the quality discrimination of present software.And other evaluation methods only provide the measured value of each metric of software code, and do not do further quantitative test, can't carry out estimating to software quality objective and accurately.
The current technical scheme that has a kind of software source code automatic Evaluation of Quality, but this technical scheme in following deficiency: one, the required equipment of software quality evaluation has been described, as keyboard, display, internal memory etc. from hardware point of view.These equipment all be current general-purpose computing system must have, can not play directive function to the specific implementation of software quality evaluation system; Two, the evaluation method of Ti Chuing does not have the quantitative test function, can't obtain the evaluation result of software code quality quantification.In sum, the technical scheme of a kind of software quality evaluation of current needs.
Summary of the invention
Technical matters to be solved by this invention provides the quantitative analysis method of a kind of software quality evaluation device and software quality evaluation, solved the problem that current method for evaluating software quality is difficult to software quality is made quantitative test, this software quality evaluation device is started with from source code, according to grammer and semanteme, the structure of routine analyzer and key feature, thereby the abstract syntax tree of generator program (Abstract Syntax Tree, abbreviate AST as), and, finally obtain the software quality evaluation result by evaluation rule and algorithm; Simultaneously, the present invention can also submit to the user with the form of form and image with the quality analysis result and examines and assess.
In order to address the above problem, the invention provides a kind of software quality evaluation device,
Comprise code analysis module, metric analysis module, evaluation rule library module, wherein,
The code analysis module is used for the source program code of software of input is carried out morphology, grammatical analysis, therefrom information extraction, and after this information represented by the form of abstract syntax tree, the data that generate are sent to the metric analysis module;
The evaluation rule library module is used to the metric analysis module that program code quality assessment rule and algorithm are provided;
The metric analysis module, be used for program code quality assessment rule and algorithm according to the evaluation rule library module, traversal code analysis module sends the abstract syntax tree of data, calculate corresponding metric value and also thus the quality of software is analyzed, generate the data of the quality evaluation result of this software.
Further, above-mentioned software quality evaluation device also can comprise, result treatment module, Subscriber Interface Module SIM, wherein,
The result treatment module, the data that are used for quality evaluation result that the metric analysis module is sent are handled, and generate various documents and preserve, and the document is sent to Subscriber Interface Module SIM;
Subscriber Interface Module SIM is used for source files of program and/or project file input code parsing module; Also be used for user-defined rule input evaluation rule library module; The document that the reception result processing module generates offers the user and checks.
Further, above-mentioned software quality evaluation device also can comprise, described code analysis module also is used for the source program code of distinct program design language is carried out scanning analysis, supports parsing project project file, obtains whole source program code information in the project file;
Described evaluation rule library module also is used to the user that the function of custom rule is provided, and the user makes amendment to program code quality assessment rule according to the diversity of software code under the varying environment and complicacy or expands;
The metric analysis module also is used for calculating corresponding metric value according to the metric that the user selects voluntarily and also thus the quality of software is analyzed, and generates the data of the quality evaluation result of this software.
Further, above-mentioned software quality evaluation device can comprise that also program code quality assessment rule that described evaluation rule library module provides and algorithm are based on ISO (International Standards Organization)/IEC model;
The various documents that described result treatment module generates comprise appraisal report or various analysis view;
Wherein, described analysis view comprises, the tabulation displayed map of the displayed map of source program code structure, metric numeric results, the statistical graph of various metric.
The present invention also provides a kind of quantitative analysis method of software quality evaluation, may further comprise the steps,
A, the source program code of software of input is carried out morphology, grammatical analysis, therefrom information extraction, and generate data, in the data of this generation the information of extracting is represented by the form of abstract syntax tree;
B, program code read quality assessment rule and algorithm, according to program code quality assessment rule and algorithm, traversal generates the abstract syntax tree of data, calculates corresponding metric value and also thus the quality of software is analyzed, and generates the data of the quality evaluation result of this software.
Further, above-mentioned quantitative analysis method also can comprise, also comprise among the described step a,
The software project project file that a11, the needs that the user is configured carry out quality assessment, or source code directory or programming language or header file catalogue importing hardware platform;
A12, the source program code of input is carried out pre-service,, be substituted in the source program code on the corresponding position header file and grand the untiing that has defined in the program;
A13, each pretreated source program code is carried out morphology and grammatical analysis, after through grand parsing and header file processing, adopt the bottom-up parse method to carry out morphology and resolve, generate related data, the data of this generation are represented by the form of abstract syntax tree.
Further, above-mentioned quantitative analysis method also can comprise, described step a13 further comprises,
A131, the type of source file of input is scanned filtration, extract required source program code according to extension name;
A132, the source program code that extracts is carried out precompile handle, all header file information and grand information in the analysis program code, and it is unlock in the file of appointment;
A133, carry out lexical analysis, source program code is converted to the syntax of bottom-up description;
A134, carry out grammatical analysis, the result of lexical analysis is changed the generation related data, the data of this generation are represented by the form of abstract syntax tree.
Further, above-mentioned quantitative analysis method also can comprise, also comprise among the described step b,
B1, read rule file, resolve the associated storage rule, obtain needed program code quality assessment rule and algorithm;
B2, program code read quality assessment rule, traversal generates the abstract syntax tree of data, source program code is carried out preanalysis, if obtain the evaluation analysis result of software quality, then with the evaluation analysis result's that obtains data storage in internal memory, it is carried out readableization processing, and the data storage of the evaluation analysis result after will handling is at local disk.
Further, above-mentioned quantitative analysis method also can comprise, among the described step b2, if after source program code carried out preanalysis, do not obtain the evaluation analysis result of software quality, and is then further comprising the steps of,
B21, according to program code quality assessment rule and algorithm, traversal generates the abstract syntax tree of data, seeks and obtain the required metric sequence of software quality evaluation;
B22, according to each specified in program code quality assessment rule metric distributed area, according to the principle of normal distribution, calculate the standard branch of each metric;
B23, according to the mapping formula of each quality standard, by the expert algorithm predetermined weight factor, linchpin metric value is weighted and sues for peace, obtain the evaluation of estimate of respective quality standard;
B24, basis are distributed to the weights of standard that qualitative factor is had jurisdiction over, the weighted mean value of the evaluation of estimate of calculating standard that factor is had jurisdiction over, thereby the evaluation of estimate of the factor of acquisition;
B25, according to the weights of distributing to factor in the program code quality assessment rule, calculate the weighted mean value of factor evaluation value, thereby obtain software quality comprehensive evaluation analysis result's data;
B26, evaluation analysis result's data storage is carried out readableization processing to it in internal memory, and with the data storage of result at local disk.
Compared with prior art, the present invention adopts abstract syntax tree that the source code of various programming languages is unified to describe and analyze, and has realized the independence of software quality evaluation and programming language; Simultaneously, also provide quality assessment rule customization function, the user can carry out self-defined and modification to software quality evaluation model, rule, makes quality assessment work more be adapted to the software actual conditions.In addition, the present invention has also determined the metric quantized value according to the normal distribution principle, adopts expert algorithm to obtain weighting factor, thereby solved the problem that existing method is difficult to software quality is carried out quantitative analysis, have directly efficiently, objective and accurate, characteristics such as applied range.
Description of drawings
Fig. 1 is the software quality metric illustraton of model;
Fig. 2 is the structural drawing of software quality evaluation device of the present invention;
Fig. 3 is the process flow diagram of the quantitative analysis method of software quality evaluation of the present invention;
Fig. 4 is code analysis process flow diagram in the method for evaluating software quality of the present invention;
Fig. 5 is quantitative Analysis process flow diagram in the method for evaluating software quality of the present invention;
Fig. 6 implements to test applicating flow chart for the present invention.
Embodiment
The invention will be further described below in conjunction with the drawings and specific embodiments.
As shown in Figure 2, a kind of software quality evaluation device comprises code analysis module, metric analysis module, evaluation rule library module, result treatment module, Subscriber Interface Module SIM, wherein,
The code analysis module, be used to receive the source files of program and/or the project file of the software of Subscriber Interface Module SIM input, source program code is carried out morphology, grammatical analysis, therefrom extract abundant information, and after this information represented by the form of abstract syntax tree, the data that generate are sent to the metric analysis module; This module can also be supported to resolve the project project file, obtains whole source program code information in the project file;
The code analysis module is in the front end of system, is made up of parts such as file analysis, lexical analysis and grammatical analyses, realizes following function: can carry out scanning analysis to the source program code of distinct program design language; Collect the information of relevant computation measure index; In analytic process, construct abstract syntax tree.
Because software often comprises the multiple source program, these source programs always utilize project file to manage, so the code analysis module needs to resolve project file.
The metric analysis module, be used for program code quality assessment rule and algorithm according to the evaluation rule library module, traversal code analysis module sends the abstract syntax tree of data, calculating corresponding metric value also analyzes the quality of software thus, data with the quality evaluation result that generates send to the result treatment module at last, also are used for calculating corresponding metric value and thus the quality of software being analyzed according to the metric that the user selects voluntarily;
The metric analysis module comprises Buffer Pool as a result, this as a result Buffer Pool be used to preserve the data of the quality evaluation result of generation.
The evaluation rule library module is used to the metric analysis module that program code quality assessment rule and algorithm are provided; The function of custom rule also is provided for the user simultaneously, and the user can make amendment to program code quality assessment rule or expands according to the diversity of software code under the varying environment and complicacy;
Wherein, program code quality assessment rule and algorithm are based on the ISO/IEC master pattern.
The result treatment module, the data that are used for quality evaluation result that the metric analysis module is sent are handled, and generate various documents (comprising appraisal report or various analysis views etc.), preserve the various documents that generate simultaneously, and document is sent to Subscriber Interface Module SIM;
The result treatment module can be handled with the tolerance result who analyze to produce statistics in the mode of various analysis views, comprising: the displayed map of (1) source program code structure, has a graph of a relation between the class that message transmits mutually at class hierarchy figure; (2) tabulation of metric numeric results shows, makes things convenient for metric to carry out lateral comparison; (3) statistical graph of various metric is as histogram, pie chart or Kiviat figure etc.; By these numerals or graphic result, can make intuitively software quality and judging, simultaneously, the result treatment module can also generate various documents automatically and be used for preserving and analyzing.
Subscriber Interface Module SIM is used for source files of program and/or project file input code parsing module; Also can be used for user-defined rule input evaluation rule library module; The document that the reception result processing module generates offers the user and checks, the user can be made intuitively software quality judge.
As shown in Figure 3, a kind of quantitative analysis method of software quality evaluation may further comprise the steps:
The software project project file that step 100, the needs that the user is configured carry out quality assessment, or source code directory or programming language or header file catalogue etc. import hardware platform;
Step 110, the source program code of input is carried out pre-service,, be substituted in the source program code on the corresponding position header file and grand the untiing that has defined in the program;
Step 120, each pretreated source program code is carried out morphology and grammatical analysis, after through grand parsing and header file processing, adopt the bottom-up parse method to carry out morphology and resolve, generate related data, the data of this generation are represented by the form of abstract syntax tree;
Described step 120 further comprises following content of operation:
Step 1201, the type of source file of input is scanned filtration, extract required source program code according to extension name;
Step 1202, the source program code that extracts is carried out precompile handle, all header file information and grand information in the analysis program code, and it is unlock in the file of appointment;
Step 1203, carry out lexical analysis, source program code is converted to the syntax of bottom-up description;
Step 1204, carry out grammatical analysis, the result of lexical analysis is changed the generation related data, the data of this generation are represented by the form of abstract syntax tree.
Step 130, read rule file, resolve the associated storage rule, obtain needed program code quality assessment rule and algorithm;
Step 140, program code read quality assessment rule, traversal generates the abstract syntax tree of data, source program code to the target project file carries out preanalysis, if find to need not to analyse in depth the evaluation analysis result that just can obtain software quality, then with the evaluation analysis result's that obtains data storage in internal memory, execution in step 160; Otherwise, execution in step 150;
Step 150, according to program code quality assessment rule and algorithm, the abstract syntax tree that generates data is done further to analyze, comprise metric calculating, quality standard is calculated, qualitative factor is calculated, finally obtain software quality comprehensive evaluation analysis result's data, and each stage Calculation results is stored in the internal memory;
Described step 150 further comprises following content of operation:
Step 1501, according to program code quality assessment rule and algorithm, traversal generates the abstract syntax tree of data, seeks and obtain the required metric sequence of software quality evaluation;
Step 1502, according to each specified in program code quality assessment rule metric distributed area, according to the principle of normal distribution, calculate the standard branch of each metric;
Step 1503, according to the mapping formula of each quality standard, by the expert algorithm predetermined weight factor, linchpin metric value is weighted and sues for peace, obtain the evaluation of estimate of respective quality standard;
Step 1504, in like manner, according to the weights of distributing to standard that qualitative factor is had jurisdiction over, the weighted mean value of the evaluation of estimate of calculating standard that factor is had jurisdiction over, thereby the evaluation of estimate of the factor of acquisition;
Step 1505, according to the weights of distributing to factor in the program code quality assessment rule, calculate the weighted mean value of factor evaluation value, thereby obtain software quality comprehensive evaluation analysis result's data;
Step 1506, with evaluation analysis result's data storage in internal memory.
Step 160, the data that will be stored in the evaluation analysis result in the internal memory are taken out, and it is carried out readableization processing, and the data storage of the evaluation analysis result after will handling is used for the user at local disk and checks.
Apparatus and method of the present invention can adopt automatic compiler Core Generator of Lex/Yacc and C language to be achieved.It is pointed out that the present invention is not limited to any concrete hardware platform and operating system, has versatility more widely.
The invention will be further described below in conjunction with instantiation.
In this example, the main treatment step of method for evaluating software quality flow process has been described:
(1) needs that the user is configured carry out software source code catalogue, programming language, the header file catalogue importing software quality evaluation device of quality assessment;
(2) source code to input carries out pre-service, with header file and grand the untiing that has defined in the program, is substituted in the source code on the corresponding position;
(3) each pretreated source file is carried out morphology/syntax parsing, after through grand parsing and header file processing, carry out the syntax and resolve, source code is resolved to bottom-up LR describe grammatical described data, after this resolve to the AST syntax tree of standard;
This step can be subdivided into following each concrete operations content (as shown in Figure 4):
(3.1) code analysis module elder generation filters the type of the source file of input, extracts required source code according to extension name;
(3.2) source code that extracts is carried out pre-service, all header file information and grand information in the resolving code, and it is unlock in the file of appointment;
(3.3) carry out lexical analysis, source code is converted to the bottom-up description syntax;
(3.4) carry out grammatical analysis, convert the result of syntax analysis to abstract syntax tree.
(4) read rule file, resolve the employed expandable mark language XML file of storage rule, obtain needed quality assessment rule;
(5) reading quality evaluation rule, traversal AST syntax tree carries out preanalysis to target engineering source code, just can obtain the software quality result if find to need not to analyse in depth, then directly analysis result is stored into and specify in the corresponding data list of Buffer Pool execution in step (7); Otherwise, abstract syntax tree is for further processing execution in step (6) with algorithm according to the quality assessment rule;
(6) be algorithm according to the quality assessment rule, the AST syntax tree is done further to analyze, comprise metric calculating, the quality standard evaluation, the qualitative factor evaluation finally obtains the software quality evaluation result, and Calculation results is sent into the result treatment module;
This step can be subdivided into following each concrete operations content (as shown in Figure 5):
(6.1) at first by computation analysis module traversal AST syntax tree, seek and obtain the required metric sequence of software quality evaluation;
(6.2) according to each specified in quality assessment rule metric distributed area,, calculate the quantized value of each metric according to the principle of normal distribution;
Computation measure index S TMT for example, the quantity of executable statement in this index expression function, the STMT metric is of great use for the complicacy of weighing function.The higher limit of setting it in the evaluation rule is 50, and lower limit is 0, is 25 by population mean in the normal distyribution function that calculates STMT as can be known, and population standard deviation is 9.69, and when the actual value of STMT was 25, the desired value of gained was up to 1.
(6.3) according to the mapping formula of each quality standard, affiliated metric value is weighted and sues for peace by predetermined weighting factor, obtain the evaluation of estimate of respective quality standard;
Stable function_STABILITY quality standard evaluation rule with function is example: function_STABILITY=NBCALLING+RETU+DRCT_CALLS+PARA, formula shows, this quality standard is determined by four metric, be NBCALLING, RETU, DRCT_CALLS, PARA, each metric weight that expert algorithm is set is 1.The top score of this quality standard 4 minutes, promptly when the value of four metric that constitute this quality standard was 1, this quality standard must be divided into 4 fens, by that analogy.
(6.4) in like manner,, affiliated standard is weighted summation, obtains the evaluation of estimate of respective quality factor by predetermined weighting factor according to the mapping formula of each qualitative factor;
(6.5) by the calculating of above-mentioned each layer, obtain the software quality comprehensive evaluation value at last,, can judge the residing grade of this program code quality according to concrete score;
(6.6) the assay result is stored in the corresponding data list of appointment Buffer Pool, make things convenient for next step use.
(7) after software quality evaluation finishes, the analysis result that is stored in the Buffer Pool is as a result taken out, be stored in local disk, and submit to the user and check.
Fig. 6 is that the present invention implements to test applicating flow chart.The enterprises and individuals who carries out software development can measure history item by the present invention, obtains the predicted value of each software metrics index; In new software project performance history, use the present invention estimate completed source code, obtains the software code quality evaluation result, and itself and predicted value are contrasted, thereby further control and improve the quality of software, improves software process capability.
The above; only for the preferable embodiment of the present invention, but protection scope of the present invention is not limited thereto, and anyly is familiar with the people of this technology in the disclosed technical scope of the present invention; the variation that can expect easily or replacement all should be encompassed within protection scope of the present invention.Therefore, protection scope of the present invention should be as the criterion with the protection domain of claim.