Sonarqube use cases Helping you make your code
Sonarqube use cases Helping you make your code better
Simple – developer runs Sonarqube • A developer can run the analysis to find issues before they commit Developer checks out the code and makes changes Developer runs the Sonarqube static code analysis Developer reads the analysis looking for issues that she can fix or any code that she can improve Developer fixes the code
Simple – developer self check (cont) • Allows developers to self correct • Gives immediate feedback • Provides a sanity check • Benefits • Finding issues here means that others have more confidence in the code they are reviewing later on • Issues fixed here are the easiest to address
Build server runs Sonarqube • A build server/CI server (Jenkins for example) runs the static code analysis for each change CI server checks out the code CI server runs the Sonarqube static code analysis CI server emails the results (including any new violations or drops in quality) to the team/s Developers/team leads/delivery manager can inspect the results and apply any further corrective actions
Build server runs Sonarqube (cont) • Benefits • Allows the team to be involved in managing quality • Makes managing code quality more enforceable (all the code is being checked) • Considerations • Can be stressful for developers that may feel they are being attacked if the culture doesn’t lend to feedback loops • Feedback is more delayed
Build server runs tests • The CI/Build server runs tests and static code analysis CI server checks out the code CI server builds the code (a BAR file) CI server runs unit tests and records test coverage, then runs Sonarqube static code analysis (with test coverage) The team can decide how much testing is enough
Build server runs tests (cont) • Benefits • With tests to support them, teams can refactor any issues found with the knowledge that tests can help prevent them from introducing bugs – encourages refactoring and reducing technical debt. • Running the tests all the time means that the team gets immediate feedback when there is an issue with the logic – not when testing starts a few weeks/months later • Business users can use tests to help describe the requirements (BDD) • Considerations • Writing tests is often harder then development
Full CI/CD • Teams can use Sonarqube as the quality gate that determines if code can go into an environment (test or production). If the tests pass, and the coverage is good and there are no critical issues (good code quality) then teams can deploy. CI server checks out the code (tag or branch) CI server runs unit tests and records test coverage CI server runs the Sonarqube static code analysis (with test coverage) and checks against minimum quality thresholds CI builds (BAR files) that are good can be stored for deployment CI server deploys BAR file to test / production
Full CI/CD (cont) • The holy grail – good quality code can be deployed often and safely allowing teams to maximise value for the business (and customers) • Developers can get quicker feed back in shared environments (for integration testing) • Testers/business can get quicker feedback from the test or UAT environments
Where does MB-Precise fit in ? • MB-Precise is a Sonarqube plugin • From Sonarqube it provides violations (warnings on bad code) and test coverage • Violations and test coverage can be used to determine if a deployment Full CI/CD (BAR file in the case of WMB/IIB) should be deployed/installed • Passing tests, low violations (or maybe even 0) and good test coverage are the pre-requisites on whether code can go to production
MB-Precise benefits • Provides code duplication checking for ESQL • Provides test coverage for WMB/IIB • Using “tracing” – easier and less invasive Provides coverage of ESQL files • http: //bettercodingtools. com/message-broker-test-coverage-using-tracing/ • • Using “instrumentation” Provides coverage for ESQL, Messageflows, Java and XSL • http: //bettercodingtools. com/message-broker-test-coverage/ • • Currently has 280+ rules for WMB/IIB • Currently has 20+ rules for DP (XSL) • http: //bettercodingtools. com/mb-rules-complete/
More features • Diagram generation: • http: //bettercodingtools. com/gallery-images/
Find out more • Our website contains more information: • http: //bettercodingtools. com/ • Demos, tutorials and presentations: • http: //bettercodingtools. com/gallery-videos/ • You can contact us via our website • http: //bettercodingtools. com/contact/ • Or email • Richard@bettercodingtools. com •
- Slides: 13