SLIDE 1 End to End Quality
with the
Sonar Ecosystem
and the
Water Leak Metaphor
@GAnnCampbell | ann.campbell@SonarSource.com @SonarLint | @SonarQube | @SonarSource
SLIDE 2
SonarLint Leak Period Quality Gate
SLIDE 3
20+ Languages
SLIDE 4
The <3 of the ecosystem
Static Analysis
SLIDE 5
What is Static Analysis?
Analyzing code, without executing it!
SLIDE 6
Detecting Bugs, Vulnerabilities, and Code Smells
A Means to an End
SLIDE 7 Why use Static Analysis
Catch new problems ASAP
- the longer it takes to catch a bug, the more it costs
- no one writes perfect code every time
- rule description and precise issue location cut
research time
SLIDE 8 Why use Static Analysis
Changing A might have added bugs in B
- peer review misses new issues in untouched code
- static analysis is machine-assisted code review; it
looks at every file every time
SLIDE 9 Why use Static Analysis
Provide coaching
- language best practices
- team coding style
SLIDE 10
SonarSource’s Toolbox
SLIDE 11
Lexical Analysis
Only two things are infinite, the universe and human stupidity, and I am not sure about the former.
SLIDE 12
Only two things are infinite, the universe and human stupidity, and I am not sure about the former.
Syntactic Analysis
Albert E.
Subjects Verbs
SLIDE 13
Semantic Analysis
Albert E. Only two things are infinite, the universe and human stupidity, and I am not sure about the former.
SLIDE 14
Semantic Analysis
Albert E. Only two things are infinite, the universe and human stupidity, and I am not sure about the former.
SLIDE 15
Beyond Semantic: Symbolic Execution
Object myObject = new Object(); if(a) { myObject = null; } ... if( !a ) { ... } else { myObject.toString(); }
SLIDE 16
Beyond Semantic: Symbolic Execution
Object myObject = new Object(); if(a) { myObject = null; } ... if( !a ) { ... } else { myObject.toString(); } //NPE
SLIDE 17 Beyond Semantic: Symbolic Execution
Object myObject = new Object(); if(a) { myObject = null; } ... if( !a ) { ... } else { myObject.toString(); } //NPE
Program State#0 myObject != null
SLIDE 18 Beyond Semantic: Symbolic Execution
Object myObject = new Object(); if(a) { myObject = null; } ... if( !a ) { ... } else { myObject.toString(); } //NPE
Program State#0 myObject != null Program State#1 myObject != null a = false Program State#2 myObject = null a = true
SLIDE 19 Beyond Semantic: Symbolic Execution
... if( !a ) { ... } else { myObject.toString(); // NPE }
Program State#1 myObject != null a = false Program State#2 myObject = null a = true
SLIDE 20 Beyond Semantic: Symbolic Execution
... if( !a ) { ... } else { myObject.toString(); // NPE }
Program State#1 myObject != null a = false Program State#2 myObject = null a = true
SLIDE 21 Beyond Semantic: Symbolic Execution
... if( !a ) { ... } else { myObject.toString(); // NPE }
Program State#1 myObject != null a = false Program State#2 myObject = null a = true Program State#4 myObject = null a = true
SLIDE 22
SonarAnalyzer for Java and JavaScript
Cross-Procedural Analysis
SLIDE 23
What is Static Analysis ?
Analyzing code, without executing it. by (symbolically) executing all possible paths!
SLIDE 24
Symbolic Execution Almost Everywhere
▪ SonarAnalyzers for C#, C/C++, Java, and JS ○ Dereferences of Null Pointers ○ Unconditionally True/False (sub)conditions ○ Division by zero ○ Resource leaks
■ Unclosed resources (Java) ■ Unreleased memory (C/C++)
○ Double free (C/C++)
SLIDE 25
Fewer slides, more code!
SLIDE 26 Full Cycle
SonarQube IDE Full Analysis
SLIDE 27 Full Cycle
SonarQube IDE
SLIDE 28
SonarLint Leak Period Quality Gate
Fix the Leak
SLIDE 29
Reimbursing the Debt
SLIDE 30
▪ Total amount of Technical Debt can be depressing ▪ How to get a budget to fix old Technical Debt? ▪ Risk of injecting functional regression ▪ This is not fun!
This is Hard
SLIDE 31
SLIDE 32
Project Homepage
SLIDE 33
Project Homepage: Leak Period
SLIDE 34
SonarLint Leak Period Quality Gate
Fix the Leak
SLIDE 35
Quality Gate
SLIDE 36
Project Homepage: Quality Gate
SLIDE 37
Quality Gate
SLIDE 38
SonarLint Leak Period Quality Gate
Fix the Leak
SLIDE 39 Thanks!
@GAnnCampbell | ann.campbell@SonarSource.com @SonarLint | @SonarQube | @SonarSource