Static Software Metrics Tool For Java Course Project CS 6367 Fall 2016 Aaron Leonard
Why software metrics? Relation between software quality, measurements, and metrics Static Java software metrics tool Supported metrics Unsupported metrics Final plan Questions
What/Why software metrics? Software quality, measurements, and metrics Metrics are how to measure quality Can be applied to project management
Software quality, measurements, and metrics How good or how bad is my software Many conflicting definitions We can define attributes of quality and try to measure them Complexity Maintainability Presence of errors
Software quality, measurements, and metrics Quantitative indication of some attribute we’re trying to measure Complexity How long to understand this code? Relative to another? Scale of 1 to 10? Number of hours? Maintainability How hard is it to add some feature / fix some bug? Presence of errors Number of bugs
Software quality, measurements, and metrics Quantitative value of some measurement Where measurement indicates some attribute we're really interested in Give a concrete value that really is observed Some metrics may apply to more than one measurement Some experts may disagree on the usefulness of a given metric
Java software metrics tool Static software metrics Just need to analyse the program source code off-line Using ASM framework As opposed to metrics derived from runtime behavior Time executing, memory, CPU load, exceptions thrown, etc… Test suite quality (you have to actually run it) Code coverage (studied much in the class)
Supported metrics
Lines of code Baseline for many attributes Complexity Maintainability Number of errors Analogous to statement coverage in test suite metrics
Comments Presence of/lines of comment Related to maintainability
McCabe cyclomatic complexity Number of paths in the control flow graph Analogous to branch coverage in test suite metrics Higher value is “more complex”
Halstead metrics Based on number of operations and operands Measures Complexity Maintenance Number of bugs
Halstead volume Length = |operators| + |operands| Vocabulary = |distinct(operators)| + |distinct(operands)| Volume = Length * log(vocabulary) Amount of code written Larger for same lines of code implies more complex code
Halstead Effort, Time, Bugs Difficulty = distinct(operators)| / 2 * |operands| / |distinct(operands)| How hard the code is to understand Effort = Difficulty * Volume How hard is it to write the same code from scratch Time = Effort / 18 Value in seconds Bugs = Volume / 3000
Maintainability index Show maintainability on scale of 1 to 100 Composition of other metrics (171 - 5.2 ln(Halstead volume) - 0.23 * Cyclomatic complexity - 16.2 * ln(Lines of code)) * 100 / 171 Derivation Expert engineers rate software maintainability on scale of 1 to 100 Statistical analysis to combine the existing metrics to fit the expert opinion
Not supported Other complexity metrics Data flow Comment quality metrics Is the comment useful? Or noise Object Oriented design metrics Design reusability Coupling Cohesion
Final implementation plan Given a java .class directory, create an HTML report of the supported metrics Report would show break down by each package, class, and method All supported metrics are implemented But the report generation is not finished Finish final report write up
Questions / comments