66
The Impact of Code Review Coverage and Participation on Software Quality Shane McIntosh Ahmed E. Hassan Bram Adams Yasutaka Kamei @shane_mcintosh [email protected]

The Impact of Code Review Coverage and Participation on Software Quality

Embed Size (px)

DESCRIPTION

Software code review, i.e., the practice of having third-party team members critique changes to a software system, is a well-established best practice in both open source and proprietary software domains. Prior work has shown that the formal code inspections of the past tend to improve the quality of software delivered by students and small teams. However, the formal code inspection process mandates strict review criteria (e.g., in-person meetings and reviewer checklists) to ensure a base level of review quality, while the modern, lightweight code reviewing process does not. Although recent work explores the modern code review process qualitatively, little research quantitatively explores the relationship between properties of the modern code review process and software quality. Hence, in this paper, we study the relationship between software quality and: (1) code review coverage, i.e., the proportion of changes that have been code reviewed, and (2) code review participation, i.e., the degree of reviewer involvement in the code review process. Through a case study of the Qt, VTK, and ITK projects, we find that both code review coverage and participation share a significant link with software quality. Low code review coverage and participation are estimated to produce components with up to two and five additional post-release defects respectively. Our results empirically confirm the intuition that poorly reviewed code has a negative impact on software quality in large systems using modern reviewing tools.

Citation preview

Page 1: The Impact of Code Review Coverage and Participation on Software Quality

The Impact of Code Review Coverage and Participation

on Software Quality

Shane McIntosh

Ahmed E. Hassan

Bram Adams

Yasutaka Kamei

@[email protected]

Page 2: The Impact of Code Review Coverage and Participation on Software Quality

Patch

+ + - -Patch

+ + - -

2

The modern, tool-supported code review process

GerritShane

Bram

Yasu

Page 3: The Impact of Code Review Coverage and Participation on Software Quality

Patch

+ + - -

Patch

+ + - -

2

The modern, tool-supported code review process

GerritShane

Bram

Yasu

Page 4: The Impact of Code Review Coverage and Participation on Software Quality

Patch

+ + - -

Patch

+ + - -

2

The modern, tool-supported code review process

Gerrit

Request review

Shane

Bram

Yasu

Page 5: The Impact of Code Review Coverage and Participation on Software Quality

Patch

+ + - -

Patch

+ + - -

2

The modern, tool-supported code review process

Gerrit

Watch about NULL values at line 3!

Shane

Bram

Yasu

Page 6: The Impact of Code Review Coverage and Participation on Software Quality

Patch

+ + - -

Patch

+ + - -

2

The modern, tool-supported code review process

Gerrit

Your code sucks!

Watch about NULL values at line 3!

Shane

Bram

Yasu

Page 7: The Impact of Code Review Coverage and Participation on Software Quality

Patch

+ + - - Patch

+ + - -

2

The modern, tool-supported code review process

Gerrit

Your code sucks!

Watch about NULL values at line 3!

Shane

Bram

Yasu

Page 8: The Impact of Code Review Coverage and Participation on Software Quality

The modern, tool-supported code review process

3

GerritShane

Bram

Yasu

Page 9: The Impact of Code Review Coverage and Participation on Software Quality

The modern, tool-supported code review process

3

GerritShane

Bram

Yasu

Page 10: The Impact of Code Review Coverage and Participation on Software Quality

The modern, tool-supported code review process

3

Upstream

GerritShane

Bram

Yasu

Page 11: The Impact of Code Review Coverage and Participation on Software Quality

The modern, tool-supported code review process

3

Upstream

GerritShane

Bram

Yasu

Changes are automatically integrated after review

criteria are satisfied

Page 12: The Impact of Code Review Coverage and Participation on Software Quality
Page 13: The Impact of Code Review Coverage and Participation on Software Quality

Traditional!Code Inspections

Mandated reviewer checklists and in-person

meetings

Page 14: The Impact of Code Review Coverage and Participation on Software Quality

Traditional!Code Inspections

Mandated reviewer checklists and in-person

meetings

Measurably!improves!software!quality

Page 15: The Impact of Code Review Coverage and Participation on Software Quality

Traditional!Code Inspections

Mandated reviewer checklists and in-person

meetings

Modern!Code Review

Lightweight, tool-supported

Measurably!improves!software!quality

Page 16: The Impact of Code Review Coverage and Participation on Software Quality

Traditional!Code Inspections

Mandated reviewer checklists and in-person

meetings

Modern!Code Review

Lightweight, tool-supported

Measurably!improves!software!quality

???

Page 17: The Impact of Code Review Coverage and Participation on Software Quality

Do lax reviewing practices have an impact on software quality?

Expert code!reviewer

Page 18: The Impact of Code Review Coverage and Participation on Software Quality

6

Upstream

Development

Feature developmentDefect repairing

Commit types

Reviews can be linked to commits in version control systems

Page 19: The Impact of Code Review Coverage and Participation on Software Quality

6

Upstream

Development

Feature developmentDefect repairing

Commit types

Reviews can be linked to commits in version control systems

Page 20: The Impact of Code Review Coverage and Participation on Software Quality

7

commit b5b46f398c1a04ab443bf22ec08c5efbf72c161e Author: Alan Alpert <[email protected]> Date: Thu Mar 1 20:09:52 2012 +1000 ! Add a hidden XandYAxis enum value For Qt 5 XandYAxis is being renamed to XAndYAxis to more consistently follow capitalization rules. Add an undocumented XandYAxis variable to ease porting. Change-Id: Id9e41dd5578373f5f557937da889a9326ff12e53 Reviewed-by: Martin Jones <[email protected]>

Gerrit

Upstream

Reviews can be linked to commits in version control systems

Page 21: The Impact of Code Review Coverage and Participation on Software Quality

7

commit b5b46f398c1a04ab443bf22ec08c5efbf72c161e Author: Alan Alpert <[email protected]> Date: Thu Mar 1 20:09:52 2012 +1000 ! Add a hidden XandYAxis enum value For Qt 5 XandYAxis is being renamed to XAndYAxis to more consistently follow capitalization rules. Add an undocumented XandYAxis variable to ease porting. Change-Id: Id9e41dd5578373f5f557937da889a9326ff12e53 Reviewed-by: Martin Jones <[email protected]>

Gerrit

Upstream

Reviews can be linked to commits in version control systems

Page 22: The Impact of Code Review Coverage and Participation on Software Quality

7

commit b5b46f398c1a04ab443bf22ec08c5efbf72c161e Author: Alan Alpert <[email protected]> Date: Thu Mar 1 20:09:52 2012 +1000 ! Add a hidden XandYAxis enum value For Qt 5 XandYAxis is being renamed to XAndYAxis to more consistently follow capitalization rules. Add an undocumented XandYAxis variable to ease porting. Change-Id: Id9e41dd5578373f5f557937da889a9326ff12e53 Reviewed-by: Martin Jones <[email protected]>

Gerrit

Upstream

Reviews can be linked to commits in version control systems

Page 23: The Impact of Code Review Coverage and Participation on Software Quality

7

commit b5b46f398c1a04ab443bf22ec08c5efbf72c161e Author: Alan Alpert <[email protected]> Date: Thu Mar 1 20:09:52 2012 +1000 ! Add a hidden XandYAxis enum value For Qt 5 XandYAxis is being renamed to XAndYAxis to more consistently follow capitalization rules. Add an undocumented XandYAxis variable to ease porting. Change-Id: Id9e41dd5578373f5f557937da889a9326ff12e53 Reviewed-by: Martin Jones <[email protected]>

Gerrit

Upstream

Reviews can be linked to commits in version control systems

Page 24: The Impact of Code Review Coverage and Participation on Software Quality

8

The Baseline

Page 25: The Impact of Code Review Coverage and Participation on Software Quality

8

Product Metrics

The Baseline

Page 26: The Impact of Code Review Coverage and Participation on Software Quality

8

Product Metrics

e.g., SLOC, complexity

The Baseline

Page 27: The Impact of Code Review Coverage and Participation on Software Quality

8

Product Metrics

Process Metrics e.g., SLOC, complexity

The Baseline

Page 28: The Impact of Code Review Coverage and Participation on Software Quality

8

Product Metrics

Process Metrics e.g., SLOC, complexity

e.g., Prior defects, churn

The Baseline

Page 29: The Impact of Code Review Coverage and Participation on Software Quality

8

Product Metrics

Process Metrics

Human Factor Metrics

e.g., SLOC, complexity

e.g., Prior defects, churn

The Baseline

Page 30: The Impact of Code Review Coverage and Participation on Software Quality

8

Product Metrics

Process Metrics

Human Factor Metrics

e.g., SLOC, complexity

e.g., Prior defects, churn

e.g., # Minor contributors

The Baseline

Page 31: The Impact of Code Review Coverage and Participation on Software Quality

9

The Context

Page 32: The Impact of Code Review Coverage and Participation on Software Quality

The Context

1,339 components254 defect-prone

v5.0.0

218 components24 defect-prone

v4.3.0170 components15 defect-prone

v5.10.0

1,337 components187 defect-prone

v5.1.0

10

Page 33: The Impact of Code Review Coverage and Participation on Software Quality

ParticipationCoverage

Do lax reviewing practices have an impact on software quality?

Page 34: The Impact of Code Review Coverage and Participation on Software Quality

ParticipationCoverage

Do lax reviewing practices have an impact on software quality?

Page 35: The Impact of Code Review Coverage and Participation on Software Quality

13

Measuring review coverage using the proportion of reviewed changes

13

Upstream Development

Page 36: The Impact of Code Review Coverage and Participation on Software Quality

13

Measuring review coverage using the proportion of reviewed changes

13

Upstream Development

Gerrit

Page 37: The Impact of Code Review Coverage and Participation on Software Quality

13

Measuring review coverage using the proportion of reviewed changes

13

Upstream Development

Gerrit

7 out of 10 changes are!linked to code reviews

Page 38: The Impact of Code Review Coverage and Participation on Software Quality

14

Concrete Predicted Defect Count

Defect Model

Create artificial component setting explanatory variables to median values

Artificial Comp.

500SLOC

Explanatory!Variable Value

Reviewed changes 100%

Churn 150

Page 39: The Impact of Code Review Coverage and Participation on Software Quality

15

Defect Model

Calculate number of predicted defects

Artificial Comp.

500SLOC

Explanatory!Variable Value

Reviewed changes

Churn 150

Reviewed changes

Pred

icte

d D

efec

t Cou

nt

Concrete Predicted Defect Count

100%

Page 40: The Impact of Code Review Coverage and Participation on Software Quality

15

Defect Model

Calculate number of predicted defects

Artificial Comp.

500SLOC

Explanatory!Variable Value

Reviewed changes

Churn 150

Reviewed changes

0

Pred

icte

d D

efec

t Cou

nt

Concrete Predicted Defect Count

100%

Page 41: The Impact of Code Review Coverage and Participation on Software Quality

15

Defect Model

Calculate number of predicted defects

Artificial Comp.

500SLOC

Explanatory!Variable Value

Reviewed changes

Churn 150

Reviewed changes

0

Pred

icte

d D

efec

t Cou

nt

Concrete Predicted Defect Count

100%

Page 42: The Impact of Code Review Coverage and Participation on Software Quality

16

Defect Model

Artificial Comp.

500SLOC

Explanatory!Variable Value

Reviewed changes 90%

Churn 150

Modify variable under test while keeping other explanatory variables constant

Reviewed changes

Pred

icte

d D

efec

t Cou

nt

Concrete Predicted Defect Count

Page 43: The Impact of Code Review Coverage and Participation on Software Quality

16

Defect Model

Artificial Comp.

500SLOC

Explanatory!Variable Value

Reviewed changes 90%

Churn 150

Modify variable under test while keeping other explanatory variables constant

Reviewed changes

Pred

icte

d D

efec

t Cou

nt

Concrete Predicted Defect Count

Page 44: The Impact of Code Review Coverage and Participation on Software Quality

16

Defect Model

Artificial Comp.

500SLOC

Explanatory!Variable Value

Reviewed changes 90%

Churn 150

1

Modify variable under test while keeping other explanatory variables constant

Reviewed changes

Pred

icte

d D

efec

t Cou

nt

Concrete Predicted Defect Count

Page 45: The Impact of Code Review Coverage and Participation on Software Quality

16

Defect Model

Artificial Comp.

500SLOC

Explanatory!Variable Value

Reviewed changes 90%

Churn 150

1

Modify variable under test while keeping other explanatory variables constant

Reviewed changes

Pred

icte

d D

efec

t Cou

nt

Concrete Predicted Defect Count

Page 46: The Impact of Code Review Coverage and Participation on Software Quality

● ●

● ● ● ● ● ● ● ●

● ● ● ● ● ● ●0

1

2

0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0Proportion of Reviewed Changes

Con

cret

e Pr

edic

ted

Def

ect C

ount

● Qt 5.0.0VTK 5.10.0

17

Review coverage doesn’t tell the whole story

Page 47: The Impact of Code Review Coverage and Participation on Software Quality

● ●

● ● ● ● ● ● ● ●

● ● ● ● ● ● ●0

1

2

0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0Proportion of Reviewed Changes

Con

cret

e Pr

edic

ted

Def

ect C

ount

● Qt 5.0.0VTK 5.10.0

17

Review coverage doesn’t tell the whole story

Not a significant factor for Qt 5.1.0 or ITK

Page 48: The Impact of Code Review Coverage and Participation on Software Quality

ParticipationCoverage

Do lax reviewing practices have an impact on software quality?

Page 49: The Impact of Code Review Coverage and Participation on Software Quality

ParticipationCoverage

Do lax reviewing practices have an impact on software quality?

!Coverage is linked to

quality in two of the four studied systems, yet it doesn’t tell the whole

story

Page 50: The Impact of Code Review Coverage and Participation on Software Quality

ParticipationCoverage

Do lax reviewing practices have an impact on software quality?

!Coverage is linked to

quality in two of the four studied systems, yet it doesn’t tell the whole

story

Page 51: The Impact of Code Review Coverage and Participation on Software Quality

20

Measuring review participation using proportions of lax reviews

I❤️ Me

Self-approved changes

Page 52: The Impact of Code Review Coverage and Participation on Software Quality

20

Measuring review participation using proportions of lax reviews

I❤️ Me

Self-approved changes

Hastily-reviewed changes

Page 53: The Impact of Code Review Coverage and Participation on Software Quality

20

Measuring review participation using proportions of lax reviews

I❤️ Me

Self-approved changes

Hastily-reviewed changes

Changes without discussion

Page 54: The Impact of Code Review Coverage and Participation on Software Quality

21

Measuring review participation using proportions of lax reviews

I❤️ Me

Self-approved changes

Hastily-reviewed changes

Changes without discussion

Page 55: The Impact of Code Review Coverage and Participation on Software Quality

● ● ●

● ●

● ● ●

● ● ●

● ● ●

● ● ●

0

1

2

3

4

5

0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0Proportion of Self−Approved Changes

Con

cret

e Pr

edic

ted

Def

ect C

ount

22

Lax participation leads to many post-release defects in our models

Page 56: The Impact of Code Review Coverage and Participation on Software Quality

● ● ●

● ●

● ● ●

● ● ●

● ● ●

● ● ●

0

1

2

3

4

5

0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0Proportion of Self−Approved Changes

Con

cret

e Pr

edic

ted

Def

ect C

ount

22

5 additional post-release defects

Lax participation leads to many post-release defects in our models

Page 57: The Impact of Code Review Coverage and Participation on Software Quality

● ● ●

● ●

● ● ●

● ● ●

● ● ●

● ● ●

0

1

2

3

4

5

0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0Proportion of Self−Approved Changes

Con

cret

e Pr

edic

ted

Def

ect C

ount

22

5 additional post-release defects

Small increase leads to defects

Lax participation leads to many post-release defects in our models

Page 58: The Impact of Code Review Coverage and Participation on Software Quality

ParticipationCoverage

Do lax reviewing practices have an impact on software quality?

!Coverage is linked to

quality in two of the four studied systems, yet it doesn’t tell the whole

story

Page 59: The Impact of Code Review Coverage and Participation on Software Quality

ParticipationCoverage

Do lax reviewing practices have an impact on software quality?

!Coverage is linked to

quality in two of the four studied systems, yet it doesn’t tell the whole

story

!Components w/ lax

review participation are estimated to have several additional post-release

defects

Page 60: The Impact of Code Review Coverage and Participation on Software Quality
Page 61: The Impact of Code Review Coverage and Participation on Software Quality
Page 62: The Impact of Code Review Coverage and Participation on Software Quality
Page 63: The Impact of Code Review Coverage and Participation on Software Quality
Page 64: The Impact of Code Review Coverage and Participation on Software Quality
Page 65: The Impact of Code Review Coverage and Participation on Software Quality
Page 66: The Impact of Code Review Coverage and Participation on Software Quality