SlideShare uma empresa Scribd logo
1 de 6
Baixar para ler offline
Continuous Inspection in a full stack project
with SonarQube
Pawe?Kozio?
May2016
I am an enthusiast of softwaremeasurement
and codequality. I will introduceyou to oneof our
projectsand describe, why wethink wewill benefit
from usingContinuousInspection in our daily work.
Then I will motivatewhy wedecided to choose
SonarQube. Thearticlewill also cover thedetailed
technical setup of our SonarQube?sdeployment and
our choiceof pluginsand sourcecodemetrics. And
lastly, I will shareour opinion about thetool after the
first week of usein theproject.
I washappy when our client recently said they want
to track metricsfor thesourcecodethat wedeliver,
and I wasassigned with thetask of settingup atool
for that. They needed aproof that thecodewas
reliableand maintainableand that wecan keep its
quality on thesamehigh level throughout the
project.
We?vealready had aCI/CD setup in our project. As
part of our softwaredelivery pipelinewedo code
review, run testsand do staticanalysis. Weuse
Jenkinsand Gerrit for thispurpose. Wehaven?t
however integrated any tool for trackingcode
metricsjust yet.
Toolsfor ContiuousInspection
Thereareafew such toolsavailable, however, most
of them areold and no longer maintained. Examples
aretheQALab and theXRadar, which werelast
updated morethan 7yearsago.
I also knew SonarQubefrom my previousresearch
on ContinuousInspection tools. It isopen source
(LGPL v3license) and it isbacked by the
SonarSourcecompany, so it can beused in arangeof
editionsstartingfrom thefreeCommunity Edition
up to theUltimateEdition with full support from
SonarSource.
ProgrammingLanguagesSupport
SonarQubehassupport for morethan 20
programminglanguagesincludingJava, C#, C/C++
and Javascript. It analyzesthecodeand evaluatesits
maintainability takinginto consideration tests,
documentation, duplications, potential bugs,
complexity and other aspects.
It isvery common to set it up for Javaprojects. This
time, however, wewanted to analyzeafull stack
project with abigpart written in Typescript using
theAngular2framework.
I want to share with you Sparkbit?s approach to software quality assurance and our
first experiences with the SonarQube tool.
At first, I wasworried, if it would bepossible. I saw
that SonarQubehasbuilt in Javascript support,
however, I knew that analyzingTypescript codeas
Javascript would not bepossible. Typescript isa
superset of JS, so JScodeisvalid TScodebut not the
other way around.
Then I found theSonarTsPlugin plugin on Github.
Theauthor saysthat theplugin ispre-alphaand
tested only on Windows, but thiswastheonly thing
available, so I decided to giveit atry.
Actually, thesetup waspainless. It sufficed to install
Node.jsand TsLint, follow thesetup stepslisted on
theplugin websiteand theplugin started to work
right away on our Ubuntu setup.
Hardwareand softwaresetup
Talkingabout thesetup - for start weused a
t2.medium machinefrom Amazon AWScloud which
has4GBof RAM.
I checked that SonarQubeneedsafew GBof
memory. TheRequirementspagesaysthat ?The
SonarQubeserver requiresat least 2GBof RAM to
run efficiently and 1GBof freeRAM for theOS?.
It also usesan SQL databaseand theElasticsearch
engine. My calculation, therefore, wasthat I would
give2GBfor SonarQube, 1GBfor theOSand 1GB
for thedatabaseand Elasticsearch for astart. For
now, thisisenough to support daily work of a10
person project team. If weever need to grow, wecan
easily upgradethemachineto t2.largewith 8BGof
RAM.
Our detailed technical setup isthat wehavea
PostgreSQL databaserunningasserviceand the
SonarQubeinstancerunningin asupervisor process
on an Ubuntu machine. Disk spaceshould not bean
issue. I wasquitesurprised to read on the
above-mentioned Requirementspagethat the?Nemo
thepublicinstanceof SonarQube, hasmorethan 15
million linesof codeunder analysiswith 4yearsof
history. Nemo iscurrently runningon an Amazon
EC2c3.largeinstance, usingabout 10Gb of drive
space?. Therefore, thedefault 80GBavailableby
default with theAWSinstanceshould bemorethan
enough for theSonarQubedataand theOS.
By theway - thereisalso oneother publicinstanceof
SonarQuberunningwith theSonarTsPlugin
availablehere. It scansbigpopular TypeScript
frameworks, includingtheAngular Framework,
Microsoft Visual Studio Codeand theMicrosoft
TypeScript Compiler.
HavingtheSonarQubeup and running, I moved to
theCodeanalysispart. I configured theGit plugin to
accessour repo and aJenkinsjob on our CI server to
trigger theSonar analysisonceaday. It wasalso
interestingto find out that SonarSourceoffersfree
and open sourceSonarLint IDEpluginsavailablefor
Eclipse, IntelliJand Visual Studio.
CodeEvaluation
Thefirst analysisrevealed that our project hasabout
25KLOCof Typescript, Javascript, Javaand XML
code. SonarQubehasfound morethan 800issuesin
our code, most of them beingMinor or Major ones
(about 300issuesin each category).
Thiswasquitesurprisingbecausewerun Findbugs
and TSLint on our codein theCI process, so we
expected amuch better result. Better newswasthat
thewholeTechnical Debt ratio waslessthan 1%and
wegot theSQALE?A?rating, beingthetop of the
scale. Wow! That wasapretty impressiveresult to
get on thefirst run.
TheTechnical Debt ratio calculation method is
described on theTechnical Debt page. Let mejust say
that thismetricmeanstheratio between theactual
technical debt and theeffort it would taketo rewrite
thewholesourcecodefrom scratch.
TheSQALE(SoftwareQuality Assessment based on
LifecycleExpectations) ratingisbased on the
so-called ?Technical Debt Pyramid?. On the
Technical Debt page, it isdescribed in full detail. In
our caseit looked likethis:
Lessthan 10man-daysto fix all technical dept - not too bad, isn't it?
Expectationsand Results
Actually, theSonarQubeanalysisrevealed somemore
interestingthings, wehaven?t known about our
project or havesimply forgotten in thecourseof
development. Onefindingwasthat acurrently
inactivesub-project of thefront end part contained a
longforgotten copy of thebackend! Sonar pointed it
out immediately becauseon onehand it contained a
lot of duplicates(obviously! becauseof thecode
copy-paste) and lotsof codesmells(becauseit has
been inactivefor quiteawhile). Nicethingto know!
Another findingwasthat oneof our activefront end
projectsactually had TSLint rulesviolations. I was
surprised. How could thishavehappened, if TSLint
waspart of our every build?Theanswer wasquite
simple. Therewasabugin our gulp build files. Here
thestrength of ContinuousInspection showsup. It is
alwaysgood to havesometool look at thesoundness
of your build.
I remember astory from oneof my previousprojects,
whereat thevery end of theproject I learned that the
script executingall testshad abugin it, that caused
thefinal test pass/fail condition alwaysto evaluateas
true. Thiswaspretty scary becauseit meant that any
potential test failswereactually left undetected.
Luckily not so many of them actually failed
unnoticed, but anyway wefaced somemomentsof
fear when wefound out. So herein our current
project, theonedirect action item wasto fix the
TSLint rulesin thissubproject and fix thebuild script.
Thecopy-pasted backend codewasactually excluded
from theproject and after that, our Technical Debt
ratio dropped to 0.7%.
Project sizealso dropped to about 19KLOC. Hereareour detailed statistics:
A number of issuesarealittlemorethan 600and wehave4%duplications.
Thisisthebreakdown of issuesby categories:
These5blockersarerelatively easy to fix, so afew hoursof work should saveus
from thescariest bugs.
Hereisalook at theseissuesfrom another perspective:
Notethat after excludingthedead backend part from theproject, thetechnical
debt dropped by 2days.
I?vealso added thehistory view to our project?sdashboard to track how metrics?valueschangeover time.
Thisway it iseasy to noticewhen someduplicationssuddenly appear or disappear from theproject. Thereis
only oneslight flaw in thisdiagram. When both LOCand complexity arepresented, thelow complexity
values(6.5compared to LOCof >20.000) areinvisible.
SonarQubealso hasnicebubblechartsthat allow
trackingthemost troublesomefilesby comparingthe
number of issues(Y axis) with thefilesizein LOC(X
axis). Each bubbleon thechart representsa
particular filein theproject and itsdiameter is
proportional to thenumber of issuesin thisfile.
Conclusion
Summingup, we?vebeen usingSonarQubein our
project for aweek now. Installation wasvery easy
and painless. Already on thefirst day, SonarQube
pointed out to uslongforgotten, smelly areasin our
repo. And it found 5new critical issues, that our
staticanalysisleft unnoticed. It isdefinitely worth to
havesuch aContinuousInspection tool in the
development pipeline.
What?sstill in front of usisto set up trackingtests
resultsand codecoverage. Wealso want to look for
new pluginsthat might beuseful for us.
What areyour experienceswith Continuous
Inspection?Do you useSonarQubeor maybesome
other tools?Do you know any good pluginssuitable
for full stack projects?We?d loveto hear your
opinions!
CONTACT
pawelk@sparkbit.pl
www.sparkbit.pl
@_sparkbit_

Mais conteúdo relacionado

Destaque

[HeXathon] 발표자료 - 세모알
[HeXathon] 발표자료 - 세모알[HeXathon] 발표자료 - 세모알
[HeXathon] 발표자료 - 세모알NAVER D2
 
Just Jobs - Digital Platform to Connect Skills and Opportunities
 Just Jobs - Digital Platform to Connect Skills and Opportunities Just Jobs - Digital Platform to Connect Skills and Opportunities
Just Jobs - Digital Platform to Connect Skills and OpportunitiesJust.Jobs
 
Lake Louise (Alberta/Canada)
Lake Louise (Alberta/Canada)Lake Louise (Alberta/Canada)
Lake Louise (Alberta/Canada)F. Ovies
 
Projeto Desenvolvimento das Startups do Território de Teresina
Projeto Desenvolvimento das Startups do Território de TeresinaProjeto Desenvolvimento das Startups do Território de Teresina
Projeto Desenvolvimento das Startups do Território de TeresinaSamuel Moraes
 
Email exchange - A melhor solução em email corporativo
Email exchange - A melhor solução em email corporativoEmail exchange - A melhor solução em email corporativo
Email exchange - A melhor solução em email corporativoRedeHost
 
Medical 2015 Mid Year Report NEW 090115
Medical 2015 Mid Year Report NEW 090115Medical 2015 Mid Year Report NEW 090115
Medical 2015 Mid Year Report NEW 090115BRIAN FLEMING, MBA
 
Catalogue xe toyota camry tại dailytoyotahadong.com.v
Catalogue xe toyota camry tại dailytoyotahadong.com.vCatalogue xe toyota camry tại dailytoyotahadong.com.v
Catalogue xe toyota camry tại dailytoyotahadong.com.vvagues bui
 
BABOKv3 讀書會 20160317
BABOKv3 讀書會 20160317BABOKv3 讀書會 20160317
BABOKv3 讀書會 20160317moris lee
 
Cppunit下載、編譯、使用與困難排除
Cppunit下載、編譯、使用與困難排除Cppunit下載、編譯、使用與困難排除
Cppunit下載、編譯、使用與困難排除Chris Wang
 
Women and Social Media
Women and Social MediaWomen and Social Media
Women and Social MediabeBee
 
S.T.A.L.K.E.R. Палачи
S.T.A.L.K.E.R. ПалачиS.T.A.L.K.E.R. Палачи
S.T.A.L.K.E.R. ПалачиProjectRus Group
 

Destaque (15)

[HeXathon] 발표자료 - 세모알
[HeXathon] 발표자료 - 세모알[HeXathon] 발표자료 - 세모알
[HeXathon] 발표자료 - 세모알
 
DNA-APBio Ch 9
DNA-APBio Ch 9DNA-APBio Ch 9
DNA-APBio Ch 9
 
Just Jobs - Digital Platform to Connect Skills and Opportunities
 Just Jobs - Digital Platform to Connect Skills and Opportunities Just Jobs - Digital Platform to Connect Skills and Opportunities
Just Jobs - Digital Platform to Connect Skills and Opportunities
 
S65 lecture1
S65 lecture1S65 lecture1
S65 lecture1
 
Lake Louise (Alberta/Canada)
Lake Louise (Alberta/Canada)Lake Louise (Alberta/Canada)
Lake Louise (Alberta/Canada)
 
Projeto Desenvolvimento das Startups do Território de Teresina
Projeto Desenvolvimento das Startups do Território de TeresinaProjeto Desenvolvimento das Startups do Território de Teresina
Projeto Desenvolvimento das Startups do Território de Teresina
 
Foresight Friday 12.2.2016 - Bios esittely
Foresight Friday 12.2.2016 - Bios esittelyForesight Friday 12.2.2016 - Bios esittely
Foresight Friday 12.2.2016 - Bios esittely
 
Email exchange - A melhor solução em email corporativo
Email exchange - A melhor solução em email corporativoEmail exchange - A melhor solução em email corporativo
Email exchange - A melhor solução em email corporativo
 
Medical 2015 Mid Year Report NEW 090115
Medical 2015 Mid Year Report NEW 090115Medical 2015 Mid Year Report NEW 090115
Medical 2015 Mid Year Report NEW 090115
 
Catalogue xe toyota camry tại dailytoyotahadong.com.v
Catalogue xe toyota camry tại dailytoyotahadong.com.vCatalogue xe toyota camry tại dailytoyotahadong.com.v
Catalogue xe toyota camry tại dailytoyotahadong.com.v
 
BABOKv3 讀書會 20160317
BABOKv3 讀書會 20160317BABOKv3 讀書會 20160317
BABOKv3 讀書會 20160317
 
Cppunit下載、編譯、使用與困難排除
Cppunit下載、編譯、使用與困難排除Cppunit下載、編譯、使用與困難排除
Cppunit下載、編譯、使用與困難排除
 
الموقع الإلكترونى للغرفة التجارية للقاهرة
الموقع الإلكترونى للغرفة التجارية للقاهرةالموقع الإلكترونى للغرفة التجارية للقاهرة
الموقع الإلكترونى للغرفة التجارية للقاهرة
 
Women and Social Media
Women and Social MediaWomen and Social Media
Women and Social Media
 
S.T.A.L.K.E.R. Палачи
S.T.A.L.K.E.R. ПалачиS.T.A.L.K.E.R. Палачи
S.T.A.L.K.E.R. Палачи
 

Último

The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendArshad QA
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 

Último (20)

The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and Backend
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 

Continuous Inspection in a full stack project with SonarQube

  • 1. Continuous Inspection in a full stack project with SonarQube Pawe?Kozio? May2016 I am an enthusiast of softwaremeasurement and codequality. I will introduceyou to oneof our projectsand describe, why wethink wewill benefit from usingContinuousInspection in our daily work. Then I will motivatewhy wedecided to choose SonarQube. Thearticlewill also cover thedetailed technical setup of our SonarQube?sdeployment and our choiceof pluginsand sourcecodemetrics. And lastly, I will shareour opinion about thetool after the first week of usein theproject. I washappy when our client recently said they want to track metricsfor thesourcecodethat wedeliver, and I wasassigned with thetask of settingup atool for that. They needed aproof that thecodewas reliableand maintainableand that wecan keep its quality on thesamehigh level throughout the project. We?vealready had aCI/CD setup in our project. As part of our softwaredelivery pipelinewedo code review, run testsand do staticanalysis. Weuse Jenkinsand Gerrit for thispurpose. Wehaven?t however integrated any tool for trackingcode metricsjust yet. Toolsfor ContiuousInspection Thereareafew such toolsavailable, however, most of them areold and no longer maintained. Examples aretheQALab and theXRadar, which werelast updated morethan 7yearsago. I also knew SonarQubefrom my previousresearch on ContinuousInspection tools. It isopen source (LGPL v3license) and it isbacked by the SonarSourcecompany, so it can beused in arangeof editionsstartingfrom thefreeCommunity Edition up to theUltimateEdition with full support from SonarSource. ProgrammingLanguagesSupport SonarQubehassupport for morethan 20 programminglanguagesincludingJava, C#, C/C++ and Javascript. It analyzesthecodeand evaluatesits maintainability takinginto consideration tests, documentation, duplications, potential bugs, complexity and other aspects. It isvery common to set it up for Javaprojects. This time, however, wewanted to analyzeafull stack project with abigpart written in Typescript using theAngular2framework. I want to share with you Sparkbit?s approach to software quality assurance and our first experiences with the SonarQube tool.
  • 2. At first, I wasworried, if it would bepossible. I saw that SonarQubehasbuilt in Javascript support, however, I knew that analyzingTypescript codeas Javascript would not bepossible. Typescript isa superset of JS, so JScodeisvalid TScodebut not the other way around. Then I found theSonarTsPlugin plugin on Github. Theauthor saysthat theplugin ispre-alphaand tested only on Windows, but thiswastheonly thing available, so I decided to giveit atry. Actually, thesetup waspainless. It sufficed to install Node.jsand TsLint, follow thesetup stepslisted on theplugin websiteand theplugin started to work right away on our Ubuntu setup. Hardwareand softwaresetup Talkingabout thesetup - for start weused a t2.medium machinefrom Amazon AWScloud which has4GBof RAM. I checked that SonarQubeneedsafew GBof memory. TheRequirementspagesaysthat ?The SonarQubeserver requiresat least 2GBof RAM to run efficiently and 1GBof freeRAM for theOS?. It also usesan SQL databaseand theElasticsearch engine. My calculation, therefore, wasthat I would give2GBfor SonarQube, 1GBfor theOSand 1GB for thedatabaseand Elasticsearch for astart. For now, thisisenough to support daily work of a10 person project team. If weever need to grow, wecan easily upgradethemachineto t2.largewith 8BGof RAM. Our detailed technical setup isthat wehavea PostgreSQL databaserunningasserviceand the SonarQubeinstancerunningin asupervisor process on an Ubuntu machine. Disk spaceshould not bean issue. I wasquitesurprised to read on the above-mentioned Requirementspagethat the?Nemo thepublicinstanceof SonarQube, hasmorethan 15 million linesof codeunder analysiswith 4yearsof history. Nemo iscurrently runningon an Amazon EC2c3.largeinstance, usingabout 10Gb of drive space?. Therefore, thedefault 80GBavailableby default with theAWSinstanceshould bemorethan enough for theSonarQubedataand theOS. By theway - thereisalso oneother publicinstanceof SonarQuberunningwith theSonarTsPlugin availablehere. It scansbigpopular TypeScript frameworks, includingtheAngular Framework, Microsoft Visual Studio Codeand theMicrosoft TypeScript Compiler. HavingtheSonarQubeup and running, I moved to theCodeanalysispart. I configured theGit plugin to accessour repo and aJenkinsjob on our CI server to trigger theSonar analysisonceaday. It wasalso interestingto find out that SonarSourceoffersfree and open sourceSonarLint IDEpluginsavailablefor Eclipse, IntelliJand Visual Studio. CodeEvaluation Thefirst analysisrevealed that our project hasabout 25KLOCof Typescript, Javascript, Javaand XML code. SonarQubehasfound morethan 800issuesin our code, most of them beingMinor or Major ones (about 300issuesin each category). Thiswasquitesurprisingbecausewerun Findbugs and TSLint on our codein theCI process, so we expected amuch better result. Better newswasthat thewholeTechnical Debt ratio waslessthan 1%and wegot theSQALE?A?rating, beingthetop of the scale. Wow! That wasapretty impressiveresult to get on thefirst run. TheTechnical Debt ratio calculation method is described on theTechnical Debt page. Let mejust say that thismetricmeanstheratio between theactual technical debt and theeffort it would taketo rewrite thewholesourcecodefrom scratch. TheSQALE(SoftwareQuality Assessment based on LifecycleExpectations) ratingisbased on the so-called ?Technical Debt Pyramid?. On the Technical Debt page, it isdescribed in full detail. In our caseit looked likethis: Lessthan 10man-daysto fix all technical dept - not too bad, isn't it?
  • 3. Expectationsand Results Actually, theSonarQubeanalysisrevealed somemore interestingthings, wehaven?t known about our project or havesimply forgotten in thecourseof development. Onefindingwasthat acurrently inactivesub-project of thefront end part contained a longforgotten copy of thebackend! Sonar pointed it out immediately becauseon onehand it contained a lot of duplicates(obviously! becauseof thecode copy-paste) and lotsof codesmells(becauseit has been inactivefor quiteawhile). Nicethingto know! Another findingwasthat oneof our activefront end projectsactually had TSLint rulesviolations. I was surprised. How could thishavehappened, if TSLint waspart of our every build?Theanswer wasquite simple. Therewasabugin our gulp build files. Here thestrength of ContinuousInspection showsup. It is alwaysgood to havesometool look at thesoundness of your build. I remember astory from oneof my previousprojects, whereat thevery end of theproject I learned that the script executingall testshad abugin it, that caused thefinal test pass/fail condition alwaysto evaluateas true. Thiswaspretty scary becauseit meant that any potential test failswereactually left undetected. Luckily not so many of them actually failed unnoticed, but anyway wefaced somemomentsof fear when wefound out. So herein our current project, theonedirect action item wasto fix the TSLint rulesin thissubproject and fix thebuild script. Thecopy-pasted backend codewasactually excluded from theproject and after that, our Technical Debt ratio dropped to 0.7%. Project sizealso dropped to about 19KLOC. Hereareour detailed statistics: A number of issuesarealittlemorethan 600and wehave4%duplications.
  • 4. Thisisthebreakdown of issuesby categories: These5blockersarerelatively easy to fix, so afew hoursof work should saveus from thescariest bugs. Hereisalook at theseissuesfrom another perspective: Notethat after excludingthedead backend part from theproject, thetechnical debt dropped by 2days. I?vealso added thehistory view to our project?sdashboard to track how metrics?valueschangeover time. Thisway it iseasy to noticewhen someduplicationssuddenly appear or disappear from theproject. Thereis only oneslight flaw in thisdiagram. When both LOCand complexity arepresented, thelow complexity values(6.5compared to LOCof >20.000) areinvisible.
  • 5. SonarQubealso hasnicebubblechartsthat allow trackingthemost troublesomefilesby comparingthe number of issues(Y axis) with thefilesizein LOC(X axis). Each bubbleon thechart representsa particular filein theproject and itsdiameter is proportional to thenumber of issuesin thisfile. Conclusion Summingup, we?vebeen usingSonarQubein our project for aweek now. Installation wasvery easy and painless. Already on thefirst day, SonarQube pointed out to uslongforgotten, smelly areasin our repo. And it found 5new critical issues, that our staticanalysisleft unnoticed. It isdefinitely worth to havesuch aContinuousInspection tool in the development pipeline. What?sstill in front of usisto set up trackingtests resultsand codecoverage. Wealso want to look for new pluginsthat might beuseful for us. What areyour experienceswith Continuous Inspection?Do you useSonarQubeor maybesome other tools?Do you know any good pluginssuitable for full stack projects?We?d loveto hear your opinions!