Code Metrics
Code Metrics
Understanding
Software
Software Engineering
Control
Metrics Process
Improvement
SWEN-261
Introduction to Software
Engineering
Department of Software Engineering
Rochester Institute of Technology
What is Software Measurement?
2
A metric is not just a number.
3
Several software quality attributes can be related to internal
attributes through metrics
Software Quality Attributes (external) Internal Attributes
4
Dynamic and Static metrics
5
Examples of Static Metrics
6
Even though you can count something, it does not necessarily
count for anything.
§ A metric is only as good as the decisions that it will be used to make.
• Measuring something without it having a solid connection to possibly improving what
you are doing is a waste of time and resources.
§ A measurement falling outside of a target range is not an absolute
indictment.
§ Target values for measurements should be set based on a record of past
measurements and resulting performance.
• Measurement not in some range è some project quality was poorer
§ If measurements that do not fall in the target range indicate a place for
additional scrutiny.
• For product metrics, they indicate possible "code smells".
• Places to consider for refactoring, redesign, or reimplementation
7
Static Code Analysis Tools
§ Static code analysis tools scan all code in a project and seek out
vulnerabilities, validates code against industry best practices, and some
software tools validate against company-specific project specifications
§ They are used by software development and quality assurance teams to
ensure the quality and security of code, and project requirements are met.
§ They can run within an IDE or integrate through a CI/CD Pipeline
8
Static Code Analysis Tools
§ Advantages
• It can find weaknesses in the code at the exact location.
• It allows a quicker turn around for fixes.
• They can scan the entire code base.
• It permits weaknesses to be found earlier in the development life cycle, reducing the
cost to fix.
§ Disadvantages
• They can produce false positives and false negatives.
• They can provide a false sense of security that everything is being addressed.
• They are only as good as the rules they are using to scan with.
§ Bottom-line
• These tools can be a cost-effective approach to measure and track software quality
metrics but don’t replace other key processes like code reviews
9
Static Code Analysis Tools – SonarQube & SonarLint
10