CSE 70, Fall 2008
Software Engineering
Lab 7 Instructions
Measure cyclomatic complexity.
Open IRCMessage.java
and examine the parseParams method.
Based on reading the code,
what is the McCabe Cyclomatic Complexity of parseParams?
Write down your answer.
Metrics is an Eclipse plugin that calculates cyclomatic complexity.
Follow these directions to install and use it:
-
Install the plugin.
-
In Eclipse's Help menu,
select Software Updates -> Find and Install...
-
In the Install/Update dialog,
select Search for new features to install and hit Next.
-
Hit New Remote Site and enter the name "Metrics" and the URL
http://metrics.sourceforge.net/update/.
Hit OK, then Finish.
-
Check the box next to the plugin name and hit Next.
-
Select I accept the terms in the license agreement and hit Next, then Finish.
-
Enable and use the plugin.
-
In the Package Explorer tab, select your project and hit Alt+Enter to bring up the Properties dialog.
-
Select the Metrics panel, check Enable Metrics, and hit OK.
-
In the Window menu, select Show View -> Other..., then select Metrics -> Metrics View and hit OK.
-
In the Java view, notice the Metrics tab in the bottom panel.
-
Investigate the code.
-
Look in the Metrics tab.
Expand the McCabe Cyclomatic Complexity entry
and locate
IRCMessage.parseParams.
Does the plugin's calculation match your own?
-
Which methods in the entire project have the most lines of code?
-
Does the lines of code calculation count comments?
Do an experiment to find out.
-
As you develop your project,
use this plugin to measure the complexity of your code
to get an idea how many tests you may need
and identify opportunities for refactoring.