SOFTWARE COMMIT RISK LEVEL

Information

  • Patent Application
  • 20160239402
  • Publication Number
    20160239402
  • Date Filed
    October 30, 2013
    11 years ago
  • Date Published
    August 18, 2016
    8 years ago
Abstract
A risk level of a software commit is assessed through the use of a classifier. The classifier may be generated based on attributes pertaining to previous commits and used to determine a risk level for deployment of a software commit into a production environment based on attributes extracted from the software commit
Description
BACKGROUND

With the advent of on-line services, executable software often is available 24 hours per day, every day. Any changes or improvements to the software should function correctly when released into the production version of the software. The continuous availability of software code creates a stress point on the ability to test the code.





BRIEF DESCRIPTION OF THE DRAWINGS

For a detailed description of various examples, reference will now be made to the accompanying drawings in which:



FIG. 1 illustrates a software generation cycle in accordance with an example;



FIG. 2 shows a system for generating a classifier for use in assessing a risk level of a software commit in accordance with an example;



FIG. 3 illustrates a data structure in accordance with an example;



FIG. 4 illustrates another system for generating a classifier for use in assessing a risk level of a software commit in accordance with an example;



FIG. 5 shows a method for generating the classifier in accordance with an example;



FIG. 6 illustrates a system for assessing a risk level of a software commit in accordance with an example;



FIG. 7 illustrates another system for assessing a risk level of a software commit in accordance with an example;



FIG. 8 illustrates a method for assessing risk in accordance with an example; and



FIG. 9 illustrates another method for assessing risk in accordance with an example.





DETAILED DESCRIPTION

As used herein, the term “code” refers to all files related to an executable application. For example, code may be executable software itself (e.g., source or object code) as well as various files used by the executable code such as images, documentation, etc.


A model of a software code's creation cycle is illustrated in FIG. 1. The code is developed by software programmers during a software development stage. Then, the code is “committed” which means that the software programmer releases the code for testing. A “software commit” (or simply “commit”) refers to code that has been written by a programmer, but has not yet been inserted into a production environment. The testing phase can be quite time consuming. After the code is tested and all, if any, bugs are fixed, the code is released into production. If the code is a patch or an enhancement of a feature to an existing program (e.g., a new feature provided to an on-line service), releasing the code into production includes inserting the new code into the existing program and making it available to the end users.


As noted above, the testing portion of the cycle can be very intensive and time consuming. The examples described herein provide a technique by which the testing phase may be eliminated in at least some situations (as indicated by the “X” in FIG. 1 through the testing phase).


The disclosed technique involves the use of a supervised machine learning approach to generate a classifier which predicts a risk level with merging the software commit in to the production environment. The disclosed machine learning approach assumes that there is a common denominator to a “bad” commit, that is, a commit that introduces a bug into the production environment. The common denominator can be learned by generating a classifier based on prior commits. If the classifier deems a particular commit to be a good commit (e.g., a commit that does not introduce a bug), then the testing phase may be skipped and the commit released into production. However, if the classifier deems a particular commit to be a bad commit, further testing may be performed to fix any bugs. The classifier generates a risk level for each commit to designate the likelihood that a commit is good (bug free) or bad (likely contains a bug).


Testing may be skipped for good commits and only performed for bad commits, thereby generally reducing the amount of testing needing to be performed.


As used herein, referring to a commit as “good” means the commit is bug-free. Referring to a commit as “bad” means the commit contains a bug. The term “risk level” may indicate whether the commit is risky or not risky. That is, in some implementations, a risk level only contains two levels (risky, not risky). In other implementations, more than two risk levels are provided.



FIG. 2 illustrates a system that includes a data structure 100 which includes a plurality of software commits 102. Each commit has already been deemed to be good (bug free) or bad (contains a bug) based on prior actual usage of the commit in the production environment. A classifier engine 110 accesses the data structure to generate a classifier 120 based on the software commits from the data structure 100. The classifier is generated based on prior commits known to be good or bad and thus the classifier is usable to classify future commits as good or bad before such commits are actually released into production and known to be good or bad.



FIG. 3 provides an example of the data structure 100. As shown in FIG. 3, the data structure 100 comprises a table that includes a plurality of entries (e.g., rows). Each entry is used to store information about a separate software commit. Commits 1, 2, 3, . . . , n are illustrated in FIG. 3. Each software commit represents a piece of code that has been written by a software developer. The commits included in the data structure 100 have been previously released into production. As a result, it has been determined whether a given commit was good or not. For example, a commit for which a bug was later detected in the production environment may be deemed to have been bad while a commit for which no bug was detected may be deemed to have been good. A label 106 is assigned to each commit to indicate the success level of that commit. The label 106 may be designated as good or bad, 1 (e.g., good) or 0 (bad), or any other type of designation to indicate the success level of the commit as being good or bad. In some implementations, the label 106 may be one of three values +1, −1, or 0. The label value +1 indicates a good commit. The label value −1 indicates a bad commit. The label value 0 indicates a commit for which a technical problem prevented an assessment of the commit as being good or bad. The labels may be ascertained for a commit after its release into production and enough time has elapsed to allow an assessment of the commit as good or bad.


The commits in a given data structure 100 may be commits that pertain to different software projects. In other implementations, however, the data structure 100 may contain commits that al pertain to the same software project. For example, an on-line web service may have undergone multiple software updates. The various updates (commits) for the on-line web service are all stored in one data structure for subsequent use in estimating the risk level of a future commit for the same project. In such implementations, a separate data structure of software commits may be provided for each software project.


Each commit in the data structure 100 includes a plurality of attributes 104. The attributes include at least one attribute about the software commit. In at least some implementations, the attributes 104 do not pertain to the functionality or logic implemented by the code itself. Instead, the attributes characterize the environment associated with the software commit. Any number of attributes 104 is possible.


In some implementations, the attributes may be categorized in three classes. A first class of attributes includes attributes based on the commit itself without considering the entire project history (source control). Source control attributes include, for example, the number of days that have elapsed since the last commit for the project (project age). In general, there may be a correlation between the frequency with which a software project is updated and the likelihood of a bug. A software project that has not needed an update in a long time is generally less likely to experience a bug when an update is made as compared to a software project that has experienced a higher frequency of software updates. Another example of a source control attribute is the time of day when the commit was made. In general, commits made during normal business hours may be more reliable than commits made during off-hours.


A second class of attributes includes attributes based on the labels of the prior commits (previous labels). As explained above, a “label” is a characterization as to whether a software commit proved to be, for example, good (bug free) or bad (had a bug). The previous labels attributes include attributes pertaining to labels of prior commits such as, for example, whether the last commit had a “good” or “bad” label (label of last 1 commits), the average of the last three commits (label of last 3 commits), the minimum number of days that have elapsed since the last “good” commit of each file in the commit (last good commit days min), etc.


A third class of attributes includes attributes pertaining to the complexity of the committed code (code complexity). In general, a modification made to more complex code is more likely to result in a bug than a modification made to simpler code. Any of a variety of techniques for measuring code complexity may be used. One suitable complexity attribute, for example, is the number of lines of source code (SLOG). Other complexity metrics may include the cyclomatic complexity, Halstead complexity measures, and maintainability metrics. Cyclomatic complexity measures the number of linearly independent paths through the source code. Cyclomatic complexity may be computed using a control flow graph of the source code whose nodes correspond to indivisible groups of commands and whose directed edges connect two nodes if the second command might be executed immediately after the first command. Halstead complexity produces a difficulty measure that is related to the difficulty of the program to write or understand. The maintainability index is computed based on lines of code measures, Halstead complexity measures and possibly different or other measures. Additional or different complexity metrics are possible as well.


Table I below provides examples of various attributes, some of which are discussed above. Other implementations may use a different set of attributes.











TABLE I





Attribute
Description
Type







project age
Days passed since the last commit
source




control


time of day
The hour when the commit was made.
source


sin
Because we want it to be circular,
control



calculated as: sin(hour × 2 × Pi/23),



where hour is an integer between 0 and 23


time of day
The hour when the commit was made.
source


cos
Because we want it to be circular,
control



calculated as: cos(hour × 2 × Pi/23),



where hour is an integer between 0 and 23


day of week
The day of the week when the commit was
source


sin
made. Because we want it to be circular,
control



calculated as: sin(day × 2 × Pi/6), where



day is an integer between 0 and 6


day of week
The day of the week when the commit was
source


cos
made. Because we want it to be circular,
control



calculated as: cos(day × 2 × Pi/6), where



day is an integer between 0 and 6


lines added
How many lines were added in total
source




control


lines removed
How many lines were removed in total
source




control


minimal added
Out of all the files in the commit, what is
source


lines
the minimal number of lines added
control


maximal added
Out of all the files in the commit, what is
source


lines
the maximal number of lines added
control


average added
Out of all the files in the commit, what is
source


lines
the average number of lines added
control


maximal
Out of all the files in the commit, what is
source


removed lines
the minimal number of lines removed
control


minimal
Out of all the files in the commit, what is
source


removed lines
the maximal number of lines removed
control


average
Out of all the files in the commit, what is
source


removed lines
the average number of lines removed
control


number of files
How many files were changed in this
source



commit
control


number of
How many files in this commit are in the
source


sensitive files
“usual suspect” list
control


minimal age
How old (in days) is the newest file in the
source



commit
control


maximal age
How old (in days) is the oldest file in the
source



commit
control


average age
What the average age (in days) of the files
source



in the commit
control


minimal times
How many changes were made to the file
source


changed
that changed the least
control


maximal times
How many changes were made to the file
source


changed
that changed the most
control


average times
How many changes on average were
source


changed
made to the files in this commit
control


minimal
What is the lowest change frequency in
source


changed
this commit. Change frequency is
control


frequency
calculated as: timesTheFileChanged/



fileAge


maximal
What is the highest change frequency in
source


changed
this commit. Change frequency is
control


frequency
calculated as: timesTheFileChanged/



fileAge


average
What is the average change frequency in
source


changed
this commit. Change frequency is
control


frequency
calculated as: timesTheFileChanged/



fileAge


length of
How many characters in the comment for
source


comment
this commit
control


days since last
How many days past since the last commit
source


commit
to this project
control


label of last 1
Was the last commit labeled as “Good” or
previous


commits
“Bad”
labels


label of last 3
What is the average of the labels of the
previous


commits
last 3 commits
labels


label of last 5
What is the average of the labels of the
previous


commits
last 5 commits
labels


last good
Calculate how many days past since the
previous


commit days
last “Good” commit of each file in this
labels


min
commit, and return the minimum


last good
Calculate how many days past since the
previous


commit days
last “Good” commit of each file in this
labels


max
commit, and return the maximum


last good
Calculate how many days past since the
previous


commit days
last “Good” commit of each file in this
labels


avg
commit, and return the average


last good
Calculate how many commits past since
previous


commit count
the last “Good” commit of each file in this
labels


min
commit, and return the minimum


last good
Calculate how many commits past since
previous


commit count
the last “Good” commit of each file in this
labels


max
commit, and return the maximum


last good
Calculate how many commits past since
previous


commit count
the last “Good” commit of each file in this
labels


avg
commit, and return the average


last bad
Calculate how many days past since the
previous


commit days
last “Bad” commit of each file in this
labels


min,
commit, and return the minimum


last bad
Calculate how many days past since the
previous


commit days
last “Bad” commit of each file in this
labels


max
commit, and return the maximum


last bad
Calculate how many days past since the
previous


commit days
last “Bad” commit of each file in this
labels


avg
commit, and return the average


last bad
Calculate how many commits past since
previous


commit count
the last “Bad” commit of each file in this
labels


min
commit, and return the minimum


last bad
Calculate how many commits past since
previous


commit count
the last “Bad” commit of each file in this
labels


max
commit, and return the maximum


last bad
Calculate how many commits past since
previous


commit count
the last “Bad” commit of each file in this
labels


avg
commit, and return the average


label streak,
If the label of the last commit is X, how
previous



many commits past since the last time the
labels



label wasn't X


dependency
The number of modules that depend on
Code


graph
the modules that were changed
complexity


SLOCP total
Total number of source lines of code in all
Code



modules of a commit
complexity


SLOCP avg
Average number of source lines of code
Code



among the modules of a commit
complexity


SLOCP max
Max number of source lines of code in a
Code



module of a commit
complexity


SLOCL total
Total number of source lines of code in all
Code



modules of a commit
complexity


SLOCL avg
Average number of source lines of code
Code



among the modules of a commit
complexity


SLOCL max
Max number of source lines of code in a
Code



module of a commit
complexity


JSHINT total
Run a code analysis tool, see how many
Code



errors it finds
complexity


JSHINT avg
Run a code analysis tool, see how many
Code



errors it finds on average
complexity


JSHINT max
Run a code analysis tool, see what's the
Code



maximal number of errors it finds
complexity


cyclomatic (M)
Total for all modules of commit,
Code


total
computed as (number of edges of control
complexity



flow graph) − (number of nodes of



graph) + (2)(number of connected



components); connected points are exit



nodes of the graph


cyclomatic (M)
Average cyclomatic measure across the
Code


avg
modules of the commit.
complexity


cyclomatic ( )
Maximum cyclomatic measure across the
Code


max
modules of the commit.
complexity


Halstead length
Total number of operators + total number
Code


(N) total
of operands for all modules of commit
complexity


Halstead length
Average length across the modules of the
Code


(N)_avg
commit.
complexity


Halstead length
Maximum length across the modules of
Code


(N) max
the commit.
complexity


Halstead
Total number of distinct operators and
Code


vocabulary (η)
distinct operands in all modules of commit
complexity


total


Halstead
Average number of distinct operators and
Code


vocabulary (η)
distinct operands across the modules of
complexity


avg
commit


Halstead
Maximum number of distinct operators
Code


vocabulary (η)
and distinct operands across the modules
complexity


max
of commit


Halstead
Difficulty measure for all modules of
Code


difficulty (D)
commit computed as (total number of
complexity


total
distinct operators)/2 × (total number of



operands)/(total number of distinct



operands)


Halstead
Average difficulty measure across the
Code


difficulty (D)
modules of commit
complexity


avg


Halstead
Maximum difficulty measure across the
Code


difficulty (D)
modules of the commit
complexity


max


Halstead
Program length (total number of operators
Code


volume (V)
and operands) X log2(program vocabulary)
complexity


total
computed for all modules of commit


Halstead
Average volume across the modules of
Code


volume (V)
the commit.
complexity


avg


Halstead
Maximum volume across the modules of
Code


volume (V)
the commit.
complexity


max


Halstead (E)
Difficulty metric X Volume, computed for
Code


effort total
all modules of commit.
complexity


Halstead effort
Average Effort computed across the
Code


(E) avg
modules of the commit.
complexity


Halstead effort
Maximum Effort computed across the
Code


(E) max,
modules of the commit.
complexity


Halstead bugs
Effort2/3/3000 or V/3000
Code


(B) total

complexity


Halstead bugs
Average number bugs across the modules
Code


(B) avg
of the commit
complexity


Halstead bugs
Maximum number bugs across the
Code


B) max
modules of the commit
complexity


Halstead time
E/18 seconds
Code


(T) total,

complexity


Halstead time
Average Time (T) across the modules of
Code


(T) avg
the commit
complexity


Halstead time
Maximum Time (T) across the modules of
Code


(T) max
the commit
complexity


maintainability
Total maintainability metric computed for
Code


total
all modules of the commit.
complexity


maintainability
Average maintainability metric across
Code


avg
the modules of the commit.
complexity


maintainability
Maximum maintainability metric across
Code


max
the modules of the commit.
complexity










FIG. 4 is an illustrative implementation of the system of FIG. 2. FIG. 4 includes a processor 130 coupled to a non-transitory computer-readable storage device 140. The storage device 140 includes any suitable type of non-volatile storage such as random access memory (RAM), compact disk read only memory (CDROM), a hard disk drive, etc. The storage device 140 includes a classifier module 142 that includes code that is executable by the processor 130 to implement the functionality of the classifier engine 110 of FIG. 2. The storage device 140 also includes the data structure 100 in which the attributes of about software commits 144 are stored for analysis by the classifier module 142. Any functionality described herein attributed to the classifier module 142 is applicable as well to the classifier engine 110, and vice versa.



FIG. 5 illustrates a method that may be implemented by the system of FIGS. 2, 4. At 150, the method includes adding attributes for a software commit to a data structure (e.g., data structure 100). The attributes to be added may be any or all of the attributes listed in Table I or different attributes as desired. For each commit whose attributes are added to the data structure, the method also includes adding a label for the commit. The label may be, for example, good (e.g., 1) or bad (e.g., 0) indicating whether or not the commit had a bug. Attributes for any number of commits can be added to the data structure.


At 154, the method includes generating a classifier based on the commits' attributes and corresponding labels in the data structure. In some examples, operation 154 is implemented as an off-line learning operation in which the data structure with the commits' attributes and labels are provided to the classifier engine 110. The classifier engine 110 may implement any suitable classifier technique such as a “leave-1-out” cross validation to generate the classifier 120. For example, for each commit in the data structure, the method removes that commit from the data structure, calculates the classifier on the remaining commits, run the newly computed classifier on the commit that was removed, and compare the risk level label returned by the classifier to the actual label of the removed commit.


Once the classifier 120 is generated, the classifier 120 can be used to assess a risk level for a given commit. The generated classifier 120 is usable to classify a new commit (i.e., a commit that is not already in the data structure or for which a label has not already been determined) as good or bad. FIG. 6 illustrates an example of a system for risk assessment of a commit. The system includes an attribute extraction engine 160 and a risk assessment engine 162. Attributes about a new commit to be analyzed are extracted by the attribute extraction engine. The extracted attributes may include at least some or all of the attributes listed in Table I. The extracted attributes are then provided to the risk assessment engine 162 which runs the previously generated classifier on the newly extracted attributes to classify the new software commit (e.g., as good or bad).



FIG. 7 is an example of an implementation of the system of FIG. 6. FIG. 7 shows a processor 170 coupled to a non-transitory computer-readable storage device 172. The storage device 172 includes any suitable type of non-volatile storage such as random access memory (RAM), compact disk read only memory (CDROM), a hard disk drive, etc. The storage device 172 includes an attribute extraction module 174 and a risk assessment module that comprise code that is executable by the processor 170 to implement the functionality of the attribute extraction engine 160 and risk assessment engine 162, respectively, of FIG. 6. The storage device 172 also includes a data structure 178 in which the attributes of software commits 180 are stored for use by the risk assessment module 176 to classify a new commit. Any functionality attributed to the attribute extraction module 174 and risk assessment module 176 is applicable as well to the corresponding attribute extraction engine 160 and risk assessment engine 162, and vice versa.



FIG. 8 shows an example of a method for assessing the risk level of a software commit. The method shown includes extracting attributes from a software commit (190). For example, some or all of the attributes listed in Table I can be extracted. At 192, the method further comprises determining a risk level of a software commit based on the extracted attributes. The classifier generated per the method of FIG. 5 may be run on the newly extracted attributes to generate the risk level.



FIG. 9 shows another method in which attributes for a software commit are extracted (200) as explained above. The attributes are provided at 202 to a classifier (e.g., the classifier generated in FIG. 5). At 204, the classifier is run on the newly extracted attributes to assess the risk level for the software commit.


The above discussion is meant to be illustrative of the principles and various embodiments of the present invention. Numerous variations and modifications will become apparent to those skilled in the art once the above disclosure is fully appreciated. It is intended that the following claims be interpreted to embrace all such variations and modifications.

Claims
  • 1. A method, comprising: extracting, by a feature extraction engine, a plurality of attributes pertaining to a software commit; anddetermining, by a risk assessment engine, a risk level for deployment of the software commit into a production environment based on the extracted attributes.
  • 2. The method of claim 1 wherein the attributes include an attribute that provides information about the software commit, an attribute that provides information about a label for the software commit, and an attribute indicative of the code complexity of the software commit for which the risk level is determined.
  • 3. The method of claim 1 wherein determining the risk level includes providing the attributes to a classification engine.
  • 4. The method of claim 1 further comprising generating a classifier based on previous software commits, providing the attributes to the classifier, and wherein determining the risk level comprising running the classifier.
  • 5. The method of claim 4 wherein the risk level includes a plurality of levels.
  • 6. A non-transitory computer-readable storage device containing software that, when executed by a processor, causes the processor to: determine a plurality of attributes pertaining to a software commit;provide the attributes to a classifier; anduse the classifier to classify a risk level for deployment of the software commit into a production environment.
  • 7. The non-transitory computer-readable storage device of claim 6 wherein, when executed, the software causes the processor to generate the classifier based on previous commits.
  • 8. The non-transitory computer-readable storage device of claim 7 wherein, when executed, the software causes the processor to generate the classifier based on leave-1-out cross validation.
  • 9. The non-transitory computer-readable storage device of claim 6 wherein the attributes include an attribute that provides information about the software commit and an attribute that provides information about a label for the software commit.
  • 10. The non-transitory computer-readable storage device of claim 6 wherein the attributes include an attribute indicative of code complexity of the software commit for which the risk level is determined.
  • 11. The non-transitory computer-readable storage device of claim 6 wherein the software commit includes an update to an existing software application.
  • 12. The non-transitory computer-readable storage device of claim 6 further comprising a data structure to include a plurality of entries, each entry to correspond to a separate software commit and to include attributes specific to that software commit, each entry also to include a label that specifies whether the corresponding software commit was good or bad.
  • 13. A system, comprising: a data structure to include a plurality of software commits, each software commit to include a plurality of attributes and a label, the attributes including at least one attribute about the software commit and the label indicating a success level of the software commit;a classifier engine to generate a classifier based on the software commits from the data structure.
  • 14. The system of claim 13 wherein the features include a plurality of attributes including a source control feature based on the software commit and a previous labels feature indicative of a label of a previous commit.
  • 15. The system of claim 14, wherein the attributes also include a measure of code complexity of the software commit for which the risk level is determined
PCT Information
Filing Document Filing Date Country Kind
PCT/US2013/067488 10/30/2013 WO 00