Upload
erv
View
32
Download
0
Tags:
Embed Size (px)
DESCRIPTION
CASE Tools. To help with software quality Peter Behl Cody Calhoun Brent Carlovsky Jake Markwardt. Overview. History 3 rd party tools ReSharper Junit Analyst4j Rose C++ Repositories Automatic Code generation. History 1968. Information System Design and Optimization System(ISDOS) - PowerPoint PPT Presentation
Citation preview
Software Metric ToolsJoel Keyser, Jacob Napp, Carey Norslien, Stephen Owings, Tristan Paynter
OverviewTool Example Code
Code Analyzer Linux KernelJFreeChartJUnitSLF4J
SourceMonitor Linux KernelSLF4JJUnit
JMetric JUnit
Metrics (Eclipse Plugin) JFreeChartSLF4JJUnit
Understand Linux Kernel
Libraries
JUnit Overview• Library used for creating, running, and sharing details of tests in Java
• #1 used open source Java library
• List of detailed features at http://junit.org/
JFreeChart Overview• Library for creating graphs and other charts in Java applications
• 4.9/5 Stars on SourceForge download page
• Easy to work with
• Highly extensible
Linux Kernel Overview• Operating system kernel for Linux.
• Written in C, supported by GCC.
• A kernel “manages input/output requests from software, and translates them into data processing instructions for the central processing unit and other electronic components of a computer” (Wikipedia)
SLF4J Overview• Simple Logging Facade for Java
• User can plug in desired logging framework at deployment
• Research in 2013 sampled 10,000 java projects in GitHub and 30.7% of them used SLF4J.
OpenJDK7 Overview• Open source implementation of Java Standard Edition
• Officially supported by Oracle
• Aided by community participation
Metric Tools
Code Analyzer (Desktop App)
Code Analyzer Overview• Free software
• Simple to use
• Supports C (*.c, *.h) C++ (*.cpp, *.cc, *.h, *.hh) java (*.java) html (*.html, *.htm) Assembly (*.s, *.asm, *.ia)
Code Analyzer Metrics• Total Files (For multiple file metrics)
• Total Lines
• Code Lines
• Comment Lines
• Whitespace Lines
• Average Line Length
• Code Lines/File (For multiple file metrics)
• Comment Lines/File (For multiple file metrics)
• Code/Comments Ratio
• Code/Whitespace Ratio
• Code/(Comments + Whitespace) Ratio
http://www.codeanalyzer.teel.ws/
Code Analyzer - jUnit
Code Analyzer - JFreeChart
Code Analyzer– Linux Kernel
SourceMonitor (Desktop App)
SourceMonitor Overview• Simple Software Metrics System
Free Fully supports most of the common languages (C++, C, C#, VB.NET, Java, and Delphi)
Easy to use
• Somewhat simplistic
• Performance issues with large software projects, such as the Linux Kernel.
SourceMonitor Metrics• LOC
• Percentage of Comments = (Lines w/ Comments) / LOC per class
• Number of Branches per class
• Max + Average depth per class
• Max + Average Complexity per class
How Complexity is Determined• Determined by the number of execution paths through a function/method.
• Starts with a base of 1
• Add 1 for each branch (if, for, while)
• Add 1 for each && or || in a logical condition
• Add 1 for each exit from code (continue, break, throw, etc...)
Source Monitor Example – Linux Kernel
Entire Linux Kernel
Linux Kernel – arch
Linux Kernel – block
JMetric (Desktop App)
JMetric Overview• Software used to measure and display Object-Oriented metrics of other software Specifically for Java Can see the data in charts, tables*, or exported text files
• Created in 1998 through the Swinburne University of Technology
• Was last updated in 2000, hence the bugs
• Fails to analyze most files
• Various interface bugs
JMetric Metrics• LOC, # variables, # methods
• Package Level Lack of Cohesion of Methods (LCOM)
• Class Level Cyclomatic Complexity # Parameters # local variables # if statements
Lack of Cohesion of Methods• BHS/CK/default are different ways to measure the same thing: the lack of cohesion per class
• Low value is good (high cohesion), high value is bad (low cohesion)
• Calculated by comparing the number of methods that share variables with the number of methods that do not
• The point is that, ideally, all variables would be used by all methods
JMetric – JUnit Package Analysis
JMetric – JUnit Class Analysis
Metrics (Eclipse Plugin)
Metrics Overview• Add-in to Eclipse
• Automatically calculates on build
• For metrics that are “bad” Shows resource most responsible Allows easy fixing
• Integrated directly into IDE
Metrics (Plugin) Metrics• Cyclomatic Complexity
• Nested Block Depth
Metrics (Plugin) Metrics• Afferent Coupling
• Efferent Coupling
• Depth of Inheritance Tree
Metrics - JFreeChart
Metrics - JUnit
JFreeChart – Number of Parameterspublic LegendItem(String label, String description,
String toolTipText, String urlText,
boolean shapeVisible, Shape shape,
boolean shapeFilled, Paint fillPaint,
boolean shapeOutlineVisible, Paint outlinePaint,
Stroke outlineStroke,
boolean lineVisible, Shape line,
Stroke lineStroke, Paint linePaint)
Understand
Understand Overview• Static Code Analysis Tool
• An IDE more concerned about analyzing a software project, rather than developing a software project.
• Major Product Features Code Knowledge Metrics & Reports Graphing Standards Testing Dependency Analysis
• Doesn’t care about “good” or “bad” metrics.
• Supports over a dozen languages, including C/C++/C# and Java.
• Three price points Floating License: $1,995 Single Developer License: $995.00 Free Two Week Trial
Understand Metrics• Around 70 metrics
• Cyclomatic Complexity
• Maximum Nesting Depth
• Maximum Inheritance Tree
Comparison - Results
Comparison – SourceMonitor MetricsLibrary LOC % Comments % Branches/Class
SLF4J 26,538 46.0 11.9
Linux Kernel* 37,608 21.2 19.7
JUnit 677,058 17.4 5
JFreeChart 229,491 49.6 14.9
OpenJDK7 3,254,229 43.0 16.1
* Due to performance issues, only the block folder was analyzed.
Comparison – SourceMonitor MetricsLibrary Avg
Depth/ClassAvg Complexity/Class
Number of Files
SLF4J 1.67 1.66 232
Linux Kernel* 1.53 3.69 75
JUnit 1.45 1,226,755** 8071
JFreeChart 1.96 2.38 653
OpenJDK7 2.54 1,359,640*** 14,152
* Due to performance issues, only the block folder was analyzed.** Two methods were measured with 1,936,482,677 complexity.***Avg complexity varied widely.
Comparison – Plugin MetricsLibrary Cyclomatic
Complexity
Nested Block Depth
Afferent Coupling
Efferent Coupling
Depth of Inheritance Tree
SLF4J 1.46 1.26 2.5 2.75 1.162
Linux Kernel*
6.449038505
1.160288839
- - 0.00013293
JUnit 1.265 1.213 12.18 4.557 1.361
JFreeChart 2.27 1.43 35.28 11.42 1.83
Open JDK7*
2.61 .82179 1.645133
* Plugin only supports Java. Understand and Excel were used to obtain similar results.
Conclusion• Metrics tools can be very useful for code analysis
• Many different types of metrics tool, some open source other commercial