Tracking and improving software quality with SonarQube


Published on

Presentation at java day riga 2013, about code quality, technical debt and SonarQube

Published in: Technology

Tracking and improving software quality with SonarQube

  1. 1. Tracking and improving software quality with Sonar(Qube)
  2. 2. SonarQube and me (Patroklos Papapetrou) ● 15 years experience in software engineering ● Agile team leader ● Active member of the SonarQube user and development list ● SonarQube plugins contributor ● Addicted to software quality and Continuous Inspection ● Co-author of SonarQube in Action
  3. 3. Overview ● Code quality (what, why and when) ● The 7 Axes of quality and the Technical Debt ● SonarQube introduction ● SonarQube to the rescue (demo time)
  4. 4. private String _ugly_name; private String ANOTHER_$UGLY___NAME; private static String am_i_static; public void please_work(ArrayList objects){ for (Object object : objects){ if (object == null){ String toString = object.toString(); } else am_i_static = object.toString(); doSomething(object); } } private void doSomething(Object object) throws NullPointerException { throw new NullPointerException(object. toString()); }
  5. 5. What is code quality?
  6. 6. What is code quality? “It’s an indicator about how quickly developers can add business value to a software system”
  7. 7. Why measure? ● Source code is the heart of each system ● Developers don’t write new software. They maintain “legacy” systems ● A system is (almost) never “finished” ● You can’t improve if you don’t measure ● Broken window theory
  8. 8. The broken windows theory
  9. 9. When you should measure? ● From project day #0 ● Continuously ● Prevent vs post-actions ● Prioritize and plan
  10. 10. What you should measure? ● Not just abstract numbers ● Evolution through time ● Metrics? ● Welcome to the 7 deadly sins of devs
  11. 11. The seven axes of quality
  12. 12. Co xi e pl ty Tes t m ver Co age The seven axes of quality l Bugs a otenti P ation up D ment o ati lic ns Docu Architecture & Design Technical Debt Co din g Ru les
  13. 13. Technical Debt “If the debt grows large enough, eventually the company will spend more on servicing its debt than it invests in increasing the value of its other assets” Steve McConnell (author of code complete)
  14. 14. This is your source code when you don’t pay your technical debt
  15. 15. “Good” & “Bad” Technical Debt
  16. 16. How to deal with Technical Debt
  17. 17. What SonarQube is / does ● Free & open source “Code Quality Platform” ● Provides moment-in-time quality snapshots ● Gives trends of lagging and leading indicators ● Tracks developers’ seven deadly sins (seven axes of quality )
  18. 18. How does it work? ● Analyzes source code and byte code ● Computes hundreds of metrics ● Associates metrics with analysis snapshots ● Shows the results in dashboards and widgets accessible by any browser
  19. 19. SonarQube for everything ● Initially developed only for Java projects ● Today supports over twenty languages Commercial : ABAP, C, C++, Cobol, Natural, PL/SQL, Visual Basic Open Source : C++, C#, Flex, Groovy, Android, Javascript, PHP, Python, XML, Web(xhtml, jsp , jsf, )
  20. 20. … and for everyone For developers. Is my code “good”? How can I improve it? For testers / QA staff. Which parts of the system lack unit testing? For architects. Is the initial design “broken”? How about complexity? For managers. Give me the numbers!! Are we going up or down?
  21. 21. Managing code quality ● Dashboards ● Historical data ● Differential views ● Compare service ● Code reviews ● Action plans
  22. 22. Managing code quality DEMO TIME
  23. 23. The big picture ● Track and reduce Technical Debt on an ongoing basis. (Clean up kitchen every day) ● Engage all developers from project day #1 (Not only mums wash the dishes) ● Get alerted when Technical debt is beyond a threshold (when someone is leaving the kitchen in a mess)
  24. 24. I have a dream… ...that one day code quality management will be as much as important and essential is today source code management
  25. 25. Thank you Patroklos Papapetrou @ppapapetrou76