1 / 94

Beyond the Basics of SonarQube : Improve Your Java(Script) Code Even Further

Beyond the Basics of SonarQube : Improve Your Java(Script) Code Even Further. Johan Janssen (Info Support). Agenda. SonarQube basic features Analyzing data Code review Hunting bad design and architecture Testing Other languages Plugins Using SonarQube on existing projects

Download Presentation

Beyond the Basics of SonarQube : Improve Your Java(Script) Code Even Further

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Beyond the Basics of SonarQube: Improve Your Java(Script) Code Even Further Johan Janssen (Info Support)

  2. Agenda • SonarQube basic features • Analyzing data • Code review • Hunting bad design and architecture • Testing • Other languages • Plugins • Using SonarQube on existing projects • Tips / summary • Questions

  3. Quality for thousands of years

  4. Quality after years of improvements

  5. Quality for 39 days

  6. Bugs • Microsoft Applications: "about 10 - 20 defects per 1000 lines of code during in-house testing, and 0.5 defect per 1000 lines of code in released product (Dave Moore 1992).“

  7. Bugs • NASA's Spirit rover became unresponsive on January 21, 2004, a few weeks after landing on Mars. (Wikipedia) • In January 2009, Google's search engine erroneously notified users that every web site world wide was potentially malicious, including its own. (Wikipedia)

  8. Find them as fast as possible

  9. Why should I use SonarQube? • I’m told to use it. • We need to achieve certain results (SIG…) • I want to improve my coding standards

  10. SonarQube • Platform to manage code quality • Open source, possible to pay for support and some plugins • Since 2006; now they have 200 customers and SonarQube is used in 15.000 organizations • Active community: support, plugins, books

  11. SonarQube 2013: • 5releases of SonarQube platform • 130 releases of ecosystem products • 75,000 downloads of SonarQube • 13,000+ messages on mailing lists

  12. SonarQubearchitecture

  13. SonarQube basic features

  14. Dashboard with ‘time changes’

  15. Configure dashboards

  16. Configure dashboards

  17. Quality Gates

  18. Notifications

  19. Analysing data

  20. Compare

  21. Measures

  22. Measure Filter as Bubble Chart

  23. Filter Motion Chart

  24. What is good code?

  25. Code review

  26. Roles

  27. Add code review

  28. Why code reviews? “We all need people who will give us feedback. That's how we improve.” - Bill Gates

  29. Hunting bad design andarchitecture

  30. Hunting bad design andarchitecture

  31. Architecturalconstraints

  32. Architecturalconstraints

  33. Package tangle index

  34. Package tangle index

  35. Testing

  36. Now manual execution of unit tests mvn clean installmvnsonar:sonar mvnclean org.jacoco:jacoco-maven- plugin:prepare-agentinstall -Dmaven.test.failure.ignore=truemvnsonar:sonar

  37. Coverage per test

  38. Coverage per test • Configure the POM (see next slide) • Activate profile to get coverage per test information mvnorg.jacoco:jacoco-maven- plugin:prepare-agentclean install -Pcoverage-per-test • Analyze the project mvnsonar:sonar

  39. Coverage per test workspace

  40. Integration testing

  41. Integration testing • Add integration test coverage widget to SonarQube • Download Jacoco agent • Configuration for Tomcat’s catalina.bat: set JACOCO=-javaagent:$path$\lib\jacocoagent.jar,destfile=$resultpath$\jacoco.exec,append=false,includes=com.dockerpi.* set JAVA_OPTS=%JAVA_OPTS% %JACOCO%

  42. Integration testing • Start Tomcat • Execute tests (manual, integration, performance…) • Stop Tomcat and execute SonarQube analysis mvn clean install sonar:sonar -Dsonar.dynamicAnalysis=reuseReports -Dsonar.jacoco.itReportPath= $resultpath$\jacoco.exec

  43. Unit and integration testing combined

  44. PMD rules for unit testing

  45. PMD rules for unit testing

  46. PMD rules for unit testing

More Related