#4 code quality
TRANSCRIPT
Code quality tools and metrics
eleks.com
Agenda
• Good code or not?• Metrics• Tools
Which code is good
• Metrics does exists to understand fitness of your code
• Various tools exists which helps to analyze it
Technical debt
..is extra development work that arises when code that is easy to implement in the short run is used instead of applying the best overall solution.
Metrics
Cyclomatic complexity
It provides a numeric value representing the complexity of a function or method
Cyclomatic complexity
Chidamber & Kemerer object-oriented metrics
Shyam R. ChidamberChris F. Kemerer
http://faculty.salisbury.edu/~stlauterburg/cosc425/metricforood_chidamberkemerer94.pdf
Chidamber & Kemerer object-oriented metrics
Name Description
DIT Depth of inheritance tree
NOC Number of children
NPM Number of public methods
RFC Response for class - # of methods executed due to method call
CE Efferent coupling - # of other classes this class uses (outgoing calls)
CA Afferent coupling - how many other classes use this class (incoming calls)
WMC Weighted methods/class∑ of cyclomatic complexity
Limitations of metrics
• no “1 True Metric”• gathered but ignored• inaction / overaction• signal to noise prefer trends to discrete values
SonarQube - http://www.sonarqube.org
• Centralize code quality metrics
• Plugin based
Reports• Code coverage • Rule compliance• Documentation • Complexity • Technical debt
SonarQube – Helicopter View
SonarQube – Issues View
File View
Quality Gates
Sonarlint - http://www.sonarlint.org/
Inspired by Technology.Driven by Value.
Find us at eleks.com
Have a question? Write to [email protected]