SonarQube is an open source tool that can be used to automate code quality metrics through continuous inspection of codebases to identify issues, aggregate metrics across projects, and provide dashboards and reports. It supports multiple languages including C# and JavaScript, and can be integrated into continuous integration pipelines through plugins. Using SonarQube allows teams to focus QA efforts by prioritizing the most important issues, track improvements over time, and gain insights into code quality trends across an organization.
Jon Gregory –Technical Architect @ MMT Digital
Developer for 15+ Years - worked on all versions of .NET. A hands on Technical Architect at a Digital
Agency using Web Forms, MVC and Kentico CMS.
Code Quality Metrics with SonarQube
A lighting talk on how SonarQube can be used to automate Code Quality Metrics
Introduction
Seven Axis ofCode Quality
Continuous Inspection
Features
o Dashboards, Charts & Drill Down Issue
Analysis.
o Historical views via Timelines, Motion
Charts & Differential Views.
o Multi Language support, C# and JavaScript
analysed in same project.
o Plugins community driven extension library
o Command Line Driven allows integration
into CI / ALM processes.
Aggregation
o Provides anaggregated view of all of the code
in an organisation by project.
o Issues are grouped by severity and
importance
Review
o Automate the review of the coding basics so
can concentrate on the complex.
o Identify training needs
o Provide improvement metrics to management.
Benefits
Efficiency
o Target refactoring effort to areas which will
benefit most.
o Problem areas highlighted and can be
planned into sprint as tasks / bugs /
chores
o Incentive to write cleaner code
o Demonstrates Return on Investment of
Refactoring
o Consistency in applying standards
SonarQube
o Download andUnzip SonarQube
o Run binwindows-x86-
64InstallNTService.bat
o Navigate to http://localhost:9000
Getting Started
Sonar-Runner
o Download and Unzip Sonar-Runner
o Add sonar-runnerbin to path
o Add the sonar properties file to the same
folder as the .sln file.
o Run ‘sonar-runner’ from command line for
each project
Two Components
10.
Analysing a Project
–Lisa Quinlan-Rahman, Head of Digital
sonar-project.properties
Add a sonar-project.properties file to the same level as the .sln file
# must be unique in a given SonarQube instance
sonar.projectKey=com.organisation.project
# this is the name displayed in the SonarQube UI
sonar.projectName=ExampleProjectName
sonar.projectVersion=trunk
# Path is relative to the sonar-project.properties file. Replace "" by "/" on Windows.
sonar.sources=.
sonar.exclusions=**obj**,**Package**,**packages**,**globalize**,**node_modules**,**CMS**
sonar.cs.opencover.reportsPaths=results.xml
11.
Useful Links
– LisaQuinlan-Rahman, Head of Digital
http://www.sonarqube.org/
Demo Site
http://nemo.sonarqube.org/
C# Plugin
http://docs.sonarqube.org/display/PLUG/C%23+Plugin
SonarQube for .NET users setup complete setup guide https://github.com/SonarSource/sonar-.net-
documentation/releases/download/1.1.0/SonarQube-Setup-Guide-For-Net-Users-V-1-1-0.pdf