Top Banner
Would Static Analysis Tools Help Developers with Code Reviews? Sebastiano Panichella Venera Arnaoudova Massimiliano Di Penta Giuliano Antoniol
61

Would Static Analysis Tools Help Developers with Code Reviews?

Jul 31, 2015

Download

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Would Static Analysis Tools Help Developers with Code Reviews?

Would Static Analysis Tools Help Developers with Code Reviews?

Sebastiano Panichella Venera Arnaoudova Massimiliano Di Penta Giuliano Antoniol

Page 2: Would Static Analysis Tools Help Developers with Code Reviews?

OUTLINE

Context: Code Reviews.

Case Study: Code Reviews of 6 Open Source Projects.

Results: Warnings Resolved by Developers During Reviews.

Page 3: Would Static Analysis Tools Help Developers with Code Reviews?

CODE REVIEWSWhy, What, How?

Page 4: Would Static Analysis Tools Help Developers with Code Reviews?

CODE REVIEWSWhy?

Page 5: Would Static Analysis Tools Help Developers with Code Reviews?

CODE REVIEWSWhy: concrete benefits…

Improved  Code  Quality

Fewer  defects  in  Code

Improved  Knowledge  Transfer

Education  of  Junior  Programmers

Benefits

“Expectations, Outcomes, and Challenges of Modern Code Review” Alberto Bacchelli and Christian Bird - ICSE 2013

“Common Outcomes of Code Review”

Page 6: Would Static Analysis Tools Help Developers with Code Reviews?

CODE REVIEWSWhat: types of peer code reviews?

Formal  Inspection  Process

Over  The  Shoulder  Reviews

Email  Pass  Around  Interviews

Tool  assisted  reviews

Pair  Programming

Page 7: Would Static Analysis Tools Help Developers with Code Reviews?

CODE REVIEWSWhat: types of peer code reviews?

Over  The  Shoulder  Reviews

Email  Pass  Around  Interviews

Tool  assisted  reviews

Pair  Programming

“Modern code review is a form of code inspection which has the qualities of being informal, tool-based

and frequent.”

“Expectations, Outcomes, and Challenges of Modern Code Review” Alberto Bacchelli and Christian Bird - ICSE 2013

Formal  Inspection  Process

Page 8: Would Static Analysis Tools Help Developers with Code Reviews?

MODERN CODE REVIEWS

“Modern code review is a form of code inspection which has the qualities of

being informal, tool-based and frequent.”

“Expectations, Outcomes, and Challenges of Modern Code Review” Alberto Bacchelli and Christian Bird - ICSE 2013

Page 9: Would Static Analysis Tools Help Developers with Code Reviews?

MODERN CODE REVIEWS: TOOLS(I)

Code Reviews Management

Page 10: Would Static Analysis Tools Help Developers with Code Reviews?

GERRIT: a Tool to Conduct and Manage Code Reviews

Page 11: Would Static Analysis Tools Help Developers with Code Reviews?

GERRIT: a Tool to Conduct and Manage Code Reviews

Page 12: Would Static Analysis Tools Help Developers with Code Reviews?

GERRIT: a Tool to Conduct and Manage Code Reviews

Page 13: Would Static Analysis Tools Help Developers with Code Reviews?

GERRIT: a Tool to Conduct and Manage Code Reviews

Page 14: Would Static Analysis Tools Help Developers with Code Reviews?

GERRIT: a Tool to Conduct and Manage Code Reviews

Page 15: Would Static Analysis Tools Help Developers with Code Reviews?

MODERN CODE REVIEWS(I)

Code Reviews Management

Page 16: Would Static Analysis Tools Help Developers with Code Reviews?

MODERN CODE REVIEWS(I)

Code Reviews Management

(II) Bugs/Issues

Detection

Page 17: Would Static Analysis Tools Help Developers with Code Reviews?

MODERN CODE REVIEWS(I)

Code Reviews Management

(II) Bugs/Issues

Detection

LIMITATION:provide a too extensive list

of recommendations

Page 18: Would Static Analysis Tools Help Developers with Code Reviews?

Past Work

Kim et al. - FSE 2007

Only10%, of suggestedwarnings are removed

by bug fix changes

Page 19: Would Static Analysis Tools Help Developers with Code Reviews?

To What Extend Static Analysis Tools Help Developers During Code Reviews?

Page 20: Would Static Analysis Tools Help Developers with Code Reviews?

To What Extent Static Analysis Tools Help Developers During Code Reviews?

Project History

Page 21: Would Static Analysis Tools Help Developers with Code Reviews?

To What Extent Static Analysis Tools Help Developers During Code Reviews?

Project History

During Code Reviews

We argue that the Use ofStatic Analysis Tools

Would be Highly Beneficial During Code Reviews…

Page 22: Would Static Analysis Tools Help Developers with Code Reviews?

CASE STUDY

Code Reviews of 6 Open Source Projects.

Page 23: Would Static Analysis Tools Help Developers with Code Reviews?

Goal: understanding how static analysis tools could have helped in dealing with warnings developers solved during code reviews.

Quality focus: reducing developers’ effort during the code review task.

Perspective: develop tool to support the configuration of static analysis tools towards warnings that are considered relevant by developers.

CASE STUDY

Page 24: Would Static Analysis Tools Help Developers with Code Reviews?

RESEARCH QUESTIONS

RQ1: To what extent warnings detected by static analysis tools are removed during code reviews?

RQ2: What kinds of warnings detected by static analysis tool are mainly considered during code reviews?

Page 25: Would Static Analysis Tools Help Developers with Code Reviews?

Projects Observe Period KLOC # of Reviews Analysed

Uses Checkstylee

Uses PDM

Eclipse CDT 2013-11-29 - 2014-09-22

1,500–1,550

309

Eclipse Platform UI

2013-06-24 - 2014-09-09

2,092–2,305

16

Eclipse JDT Core

2013-05-23 - 2014-09-24

2,736–2,554

113

OpenDaylight Controller

2013-01-01 - 2014-09-24

149–171 161

Motech 2013-07-24 - 2014-09-24

586–1,909 209

Vaadin 2013-06-01 - 2014-09-24

6,174–6,114

180

CONTEXTObject:

Tools Experimented:

Page 26: Would Static Analysis Tools Help Developers with Code Reviews?

STUDY PROCEDURE

Page 27: Would Static Analysis Tools Help Developers with Code Reviews?

PATCH SETS COMPARISON…

Given a Code Review

Page 28: Would Static Analysis Tools Help Developers with Code Reviews?

PATCH SETS COMPARISON…

Given a Code Review

We use…

Page 29: Would Static Analysis Tools Help Developers with Code Reviews?

PATCH SETS COMPARISON…

Given a Code Review

We use... to compare warnings density

variation between…

First patch

Last patch

Page 30: Would Static Analysis Tools Help Developers with Code Reviews?
Page 31: Would Static Analysis Tools Help Developers with Code Reviews?

RQ1To what extent warnings detected by

static analysis tools are removed during code reviews?

Page 32: Would Static Analysis Tools Help Developers with Code Reviews?

ProjectsDensity of Warnings

[P-value]# of Warning

[P-value]Density of Warnings

[P-value]# of Warning

[P-value]

Eclipse CDT 0.074 0.025 0.028 <001

Eclipse JDT Core 0.450 0.919 0.351 0.624

Eclipse Platform UI

0.132 0.857 0.011 0.2

OpenDaylight Controller

0.080 <0.01 0.614 <0.01

Motech >0.01 <0.01 0.205 <0.01

Vaadin NA NA 0.148 0.209

Changes of Warnings Density (and Absolute Number) During Code Reviews.

Page 33: Would Static Analysis Tools Help Developers with Code Reviews?

ProjectsDensity of Wornings

[P-value]# of Warning

[P-value]Density of Wornings

[P-value]# of Warning

[P-value]

Eclipse CDT 0.074 0.025 0.028 <001

Eclipse JDT Core 0.450 0.919 0.351 0.624

Eclipse Platform UI

0.132 0.857 0.011 0.2

OpenDaylight Controller

0.080 <0.01 0.614 <0.01

Motech >0.01 <0.01 0.205 <0.01

Vaadin NA NA 0.148 0.209

Changes of Warnings Density (and Absolute Number) During Code Reviews.

Page 34: Would Static Analysis Tools Help Developers with Code Reviews?

ProjectsDensity of Wornings

[P-value]# of Warning

[P-value]Density of Wornings

[P-value]# of Warning

[P-value]

Eclipse CDT 0.074 0.025 0.028 <001

Eclipse JDT Core 0.450 0.919 0.351 0.624

Eclipse Platform UI

0.132 0.857 0.011 0.2

OpenDaylight Controller

0.080 <0.01 0.614 <0.01

Motech >0.01 <0.01 0.205 <0.01

Vaadin NA NA 0.148 0.209

Changes of Warnings Density (and Absolute Number) During Code Reviews.

Page 35: Would Static Analysis Tools Help Developers with Code Reviews?

Cumulative Percentage of Removed Warnings

Projects Uses Checkstyle

Uses PDM

% of Resolved Warnings % of Resolved Warnings

Eclipse CDT 11% 11%Eclipse

Platform UI 5% 7%Eclipse JDT

Core 11% 9%OpenDaylight

Controller 15% 15%

Motech 23% 13%

Vaadin - 13%

Page 36: Would Static Analysis Tools Help Developers with Code Reviews?

Cumulative Percentage of Removed Warnings

Projects Uses Checkstyle

Uses PDM

% of Resolved Warnings % of Resolved Warnings

Eclipse CDT 11% 11%Eclipse

Platform UI 5% 7%Eclipse JDT

Core 11% 9%OpenDaylight

Controller 15% 15%

Motech 23% 13%

Vaadin - 13%

Page 37: Would Static Analysis Tools Help Developers with Code Reviews?

RQ2What kinds of warnings detected by

static analysis tool are mainly considered during code reviews?

Page 38: Would Static Analysis Tools Help Developers with Code Reviews?

Qualitative Analysis

Page 39: Would Static Analysis Tools Help Developers with Code Reviews?

Qualitative Analysis

Page 40: Would Static Analysis Tools Help Developers with Code Reviews?

Qualitative Analysis

Page 41: Would Static Analysis Tools Help Developers with Code Reviews?

Qualitative Analysis

“We randomly sampled 10% of code reviews that resolved at least one warning”

Page 42: Would Static Analysis Tools Help Developers with Code Reviews?

Qualitative AnalysisQualitative Analysis

“Warning that Developers Fix During Code Reviews:”

Page 43: Would Static Analysis Tools Help Developers with Code Reviews?

Qualitative Analysis

“Warning that Developers Fix During Code Reviews:”

Type Resolution

Page 44: Would Static Analysis Tools Help Developers with Code Reviews?

Qualitative Analysis

“Warning that Developers Fix During Code Reviews:”

Unused code

Type Resolution

Page 45: Would Static Analysis Tools Help Developers with Code Reviews?

Qualitative Analysis

“Warning that Developers Fix During Code Reviews:”

Imports

Regular Expression

Type Resolution

Unused code

Page 46: Would Static Analysis Tools Help Developers with Code Reviews?

Qualitative Analysis

“Warning that Developers Fix During Code Reviews:”

Imports

Regular Expression

Type Resolution

Unused code

Page 47: Would Static Analysis Tools Help Developers with Code Reviews?

Eclipse CDT: Percentage of PDM’ Resolved Warnings

Warning Types % Resolved Warnings

Type Resolution 100% Import 100%Basic 75%

Sunsecure 67%Codesize 59%

Unusedcode 58%Logging-java 51%

j2ee 47%

Design 42%

junit 38%

Empty 33%Javabeans 26%

Naming 14%

Braces 14%

…. …..

Page 48: Would Static Analysis Tools Help Developers with Code Reviews?

Eclipse CDT: Percentage of PDM’ Resolved Warnings

Warning Types % Resolved Warnings

Type Resolution 100% Import 100%Basic 75%

Sunsecure 67%Codesize 59%

Unusedcode 58%Logging-java 51%

j2ee 47%

Design 42%

junit 38%

Empty 33%Javabeans 26%

Naming 14%

Braces 14%

…. …..

“Quantitative Analisys Confirms Findings of the Qualitative analysis..”

Page 49: Would Static Analysis Tools Help Developers with Code Reviews?

OpenDaylight Controller: Percentage of Checkstyle’ Resolved Warnings

Warning Types % Resolved Warnings

Regular Expressions 100% Modifiers 100%

Metrics 100%import 53%

Whitespace 48%Class Design 47%

Annotations 40%Naming 16%Coding 15%

%Javadoc Comments 12%

Size Violations 11%Javabeans 26%

Block Checks 10%

Miscellaneous 8%

…. …..

“Similar Results for Checkstyle Warnings..”

Page 50: Would Static Analysis Tools Help Developers with Code Reviews?

OpenDaylight Controller: Percentage of Checkstyle’ Resolved Warnings

Warning Types % Resolved Warnings

Regular Expressions 100% Modifiers 100%

Metrics 100%import 53%

Whitespace 48%Class Design 47%Annotations 40%

Naming 16%Coding 15%

%Javadoc Comments 12%Size Violations 11%

Javabeans 26%

Block Checks 10%Miscellaneous 8%

…. …..

Developers Fix also Warnings related to:

1) naming convention

2) code formatting

3) code comments

Page 51: Would Static Analysis Tools Help Developers with Code Reviews?

By implication…

“Enforcing the removal of certain warnings before submitting a patch..”

Page 52: Would Static Analysis Tools Help Developers with Code Reviews?
Page 53: Would Static Analysis Tools Help Developers with Code Reviews?
Page 54: Would Static Analysis Tools Help Developers with Code Reviews?
Page 55: Would Static Analysis Tools Help Developers with Code Reviews?
Page 56: Would Static Analysis Tools Help Developers with Code Reviews?
Page 57: Would Static Analysis Tools Help Developers with Code Reviews?
Page 58: Would Static Analysis Tools Help Developers with Code Reviews?
Page 59: Would Static Analysis Tools Help Developers with Code Reviews?
Page 60: Would Static Analysis Tools Help Developers with Code Reviews?
Page 61: Would Static Analysis Tools Help Developers with Code Reviews?