sonar overview

23
Do Great Code! Samuel Langlois, 17-Jan-2013

Upload: samuel-langlois

Post on 09-May-2015

4.129 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: Sonar Overview

Do Great Code!

Samuel Langlois, 17-Jan-2013

Page 2: Sonar Overview

Sonar

• A platform to manage code quality• Free, open source, LGPL, web-based

portal• Backed by• Aggregates well-known tools– Static analysis (PMD, findbugs, Checkstyle)– Duplicate code (Squid, CPD)– Code coverage (Cobertura, JaCoCo)

(name change soon?)

Page 3: Sonar Overview

Sonar @ Alfresco

• http://sonar.alfresco.com• Open access, LDAP authentication

coming

• Contains the following projects:– Enterprise HEAD (Maven build)– CLOUD1 (Maven build)– Benchmark– Android SDK and App– …

Page 4: Sonar Overview

Sonar portal

Page 5: Sonar Overview

Sonar – Basic statistics

Page 6: Sonar Overview

Drilling down

• Whole project– Project/module

• Java package– Java class

Page 7: Sonar Overview

Sonar – Duplications

Page 8: Sonar Overview

Sonar – Package tangle

Page 9: Sonar Overview

Sonar - Coverage

Page 10: Sonar Overview

Clouds

Page 11: Sonar Overview

Sonar - Violations

Page 12: Sonar Overview

Violation examples

• Impossible cast

Page 13: Sonar Overview

Violation examples

• Dead store

Page 14: Sonar Overview

Violation examples

• Dead store

Page 16: Sonar Overview

Violation examples

• Empty if statement

Page 17: Sonar Overview

Managing violations

• For each violation you can– Comment– Change its severity– Declare it as a false-positive– Assign it to someone– Assign it to an action plan

Page 18: Sonar Overview

Time machine

Page 19: Sonar Overview

Technical debt

• Term coined by Ward Cunningham in 1992

• Work that needs done before a job is complete

• Unwritten tests• Bad design and architecture• Duplicated code• …

• The higher you wait to fix, the more expensive it becomes

Page 20: Sonar Overview

SQALE

• Based on ISO 9126 Quality Model• Computes a Technical Debt, measured in

days

Page 21: Sonar Overview

Code quality

“A well-written program is a program where the cost of implementing a feature is constant throughout the program's lifetime.”

Page 22: Sonar Overview

What now?• What to start with?– Improving test coverage?– Removing duplicate code?– Checking violations?– …

• Where to start?– Most critical projects?– Most « buggy » projects?– Voluntary teams?– …

Try it and tell me!

Page 23: Sonar Overview