43
Software Metric Tools Joel Keyser, Jacob Napp, Carey Norslien, Stephen Owings, Tristan Paynter

CASE Tools

  • Upload
    erv

  • View
    32

  • Download
    0

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

Page 1: CASE Tools

Software Metric ToolsJoel Keyser, Jacob Napp, Carey Norslien, Stephen Owings, Tristan Paynter

Page 2: CASE Tools

OverviewTool Example Code

Code Analyzer Linux KernelJFreeChartJUnitSLF4J

SourceMonitor Linux KernelSLF4JJUnit

JMetric JUnit

Metrics (Eclipse Plugin) JFreeChartSLF4JJUnit

Understand Linux Kernel

Page 3: CASE Tools

Libraries

Page 4: CASE Tools

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/

Page 5: CASE Tools

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

Page 6: CASE Tools
Page 7: CASE Tools

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)

Page 8: CASE Tools

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.

Page 9: CASE Tools

OpenJDK7 Overview• Open source implementation of Java Standard Edition

• Officially supported by Oracle

• Aided by community participation

Page 10: CASE Tools

Metric Tools

Page 11: CASE Tools

Code Analyzer (Desktop App)

Page 12: CASE Tools

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)

Page 13: CASE Tools

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/

Page 14: CASE Tools

Code Analyzer - jUnit

Page 15: CASE Tools

Code Analyzer - JFreeChart

Page 16: CASE Tools

Code Analyzer– Linux Kernel

Page 17: CASE Tools

SourceMonitor (Desktop App)

Page 18: CASE Tools

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.

Page 19: CASE Tools

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

Page 20: CASE Tools

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...)

Page 21: CASE Tools

Source Monitor Example – Linux Kernel

Entire Linux Kernel

Linux Kernel – arch

Linux Kernel – block

Page 22: CASE Tools
Page 23: CASE Tools

JMetric (Desktop App)

Page 24: CASE Tools

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

Page 25: CASE Tools

JMetric Metrics• LOC, # variables, # methods

• Package Level Lack of Cohesion of Methods (LCOM)

• Class Level Cyclomatic Complexity # Parameters # local variables # if statements

Page 26: CASE Tools

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

Page 27: CASE Tools

JMetric – JUnit Package Analysis

Page 28: CASE Tools

JMetric – JUnit Class Analysis

Page 29: CASE Tools

Metrics (Eclipse Plugin)

Page 30: CASE Tools

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

Page 31: CASE Tools

Metrics (Plugin) Metrics• Cyclomatic Complexity

• Nested Block Depth

Page 32: CASE Tools

Metrics (Plugin) Metrics• Afferent Coupling

• Efferent Coupling

• Depth of Inheritance Tree

Page 33: CASE Tools

Metrics - JFreeChart

Page 34: CASE Tools

Metrics - JUnit

Page 35: CASE Tools

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)

Page 36: CASE Tools

Understand

Page 37: CASE Tools

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

Page 38: CASE Tools

Understand Metrics• Around 70 metrics

• Cyclomatic Complexity

• Maximum Nesting Depth

• Maximum Inheritance Tree

Page 39: CASE Tools

Comparison - Results

Page 40: CASE Tools

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.

Page 41: CASE Tools

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.

Page 42: CASE Tools

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.

Page 43: CASE Tools

Conclusion• Metrics tools can be very useful for code analysis

• Many different types of metrics tool, some open source other commercial