JavaNCSS Metric Results

[ packages] [ objects] [ functions] [ explanations]

The following document contains the results of a JavaNCSSmetric analysis.

Packages

[ packages] [ objects] [ functions] [ explanations]

Packages sorted by NCSS

PackageClassesFunctions NCSS JavadocsJavadoc LinesSingle Comment LinesMulti Comment Lines
battlehex.ui.main1261571482277348
battlehex.model.map1681323874123464
battlehex.model.command1228241321563348
battlehex41817513555121
battlehex.controller623153271190174
battlehex.ui.startup21275739058
battlehex.model.player5157218810145
battlehex.model472310520116
Classes totalFunctions total NCSS total JavadocsJavadoc LinesSingle Comment LinesMulti Comment Lines
6124516332421141181774

Objects

[ packages] [ objects] [ functions] [ explanations]

TOP 30 classes containing the most NCSS

Object NCSS FunctionsClassesJavadocs
battlehex.model.map.Territory9218115
battlehex.ui.main.ControlDisplay69723
battlehex.ui.main.GridDisplayer68613
battlehex.ui.main.GameDisplayer62613
battlehex.ui.startup.GameTypeChoiceView57862
battlehex.ui.main.View53742
battlehex.controller.Controller5211110
battlehex.ui.main.TerritoryInfoDisplayer50414
battlehex.BattleHex47512
battlehex.BattleHex47512
battlehex.model.map.SubTerritoryIterator47702
battlehex.GameFactory40505
battlehex.ui.main.TerritoryDisplayer40404
battlehex.ui.main.CurrentPlayerDisplayer37706
battlehex.ui.main.TileComponent36303
battlehex.model.map.Tile349010
battlehex.model.command.CastleBuy30403
battlehex.model.command.Move30403
battlehex.model.player.PlayerManager29504
battlehex.model.map.Money28718
battlehex.model.map.Surrounding27405
battlehex.controller.TerritorySelectedState23304
battlehex.controller.PlacementPendingState21304
battlehex.model.command.NewGame21302
battlehex.model.command.Game19203
battlehex.ui.main.PolygonDisplayer18303
battlehex.controller.BaseState17304
battlehex.model.command.EndTurn15212
battlehex.model.map.ITerritory1413014
battlehex.model.player.CyclicIterator14405

TOP 30 classes containing the most functions

ObjectNCSS Functions ClassesJavadocs
battlehex.model.map.Territory9218115
battlehex.model.map.ITerritory1413014
battlehex.controller.Controller5211110
battlehex.model.map.Tile349010
battlehex.ui.startup.GameTypeChoiceView57862
battlehex.model.map.ITile8708
battlehex.model.map.Money28718
battlehex.model.map.SubTerritoryIterator47702
battlehex.ui.main.ControlDisplay69723
battlehex.ui.main.CurrentPlayerDisplayer37706
battlehex.ui.main.PassiveLayout13708
battlehex.ui.main.View53742
battlehex.model.map.IMoney7607
battlehex.ui.main.GameDisplayer62613
battlehex.ui.main.GridDisplayer68613
battlehex.ui.main.IController7607
battlehex.BattleHex47512
battlehex.BattleHex47512
battlehex.GameFactory40505
battlehex.model.player.PlayerManager29504
battlehex.model.command.CastleBuy30403
battlehex.model.command.Move30403
battlehex.model.map.Surrounding27405
battlehex.model.player.CyclicIterator14405
battlehex.model.Turn11404
battlehex.ui.main.TerritoryDisplayer40404
battlehex.ui.main.TerritoryInfoDisplayer50414
battlehex.ui.startup.IGameFactory5405
battlehex.controller.BaseState17304
battlehex.controller.PlacementPendingState21304

Averages

NCSS average Program NCSSClasses averageFunctions averageJavadocs average
21.331,633.000.344.023.97

Functions

[ packages] [ objects] [ functions] [ explanations]

TOP 30 functions containing the most NCSS

Function NCSS CCNJavadoc
battlehex.ui.main.TerritoryInfoDisplayer.format(ITerritory)2310
battlehex.BattleHex.main(String[])2081
battlehex.BattleHex.main(String[])2081
battlehex.ui.main.ControlDisplay.createBox(JComponent,JComponent,JComponent)1810
battlehex.ui.main.GridDisplayer.GridDisplayer(IController,IContext,IHexagonBuilder,JComponent)1771
battlehex.model.map.SubTerritoryIterator.extractNeighbours(Vector,ITile)1640
battlehex.model.command.Move.check(IContext)1370
battlehex.ui.main.GameDisplayer.GameDisplayer(JComponent,JComponent)1351
battlehex.ui.main.TerritoryDisplayer.TerritoryDisplayer(IController,IContext,IHexagonBuilder)1371
battlehex.ui.main.TileComponent.TileComponent(ITile,Polygon)1351
battlehex.controller.Controller.findTerritory(IGrid,Coordinate)1290
battlehex.model.command.CastleBuy.check(IContext)1270
battlehex.ui.main.GridDisplayer.addTiles()1250
battlehex.ui.startup.GameTypeChoiceView.GameTypeChoiceView(IGameFactory)1231
battlehex.controller.TerritorySelectedState.TerritorySelectedState(IConsumer,ITerritoryObserver,ITerritory)1171
battlehex.GameFactory.createClient(String,int)1111
battlehex.model.command.EndTurn.execute(IContext)1131
battlehex.model.command.IncomePayment.execute(IContext)1131
battlehex.ui.main.ControlDisplay.createSubPanel(JComponent,Border)1110
battlehex.ui.main.CurrentPlayerDisplayer.CurrentPlayerDisplayer(IContext,IHexagonBuilder)1151
battlehex.ui.main.GridDisplayer.update(IGrid)1121
battlehex.ui.main.TerritoryInfoDisplayer.TerritoryInfoDisplayer(IController,IContext)1151
battlehex.BattleHex.usage(String)1010
battlehex.controller.PlacementPendingState.PlacementPendingState(IConsumer,ITerritoryObserver,ITerritory)1071
battlehex.BattleHex.usage(String)1010
battlehex.model.command.CastleBuy.execute(IContext)1031
battlehex.model.command.Game.endTurn(IGameHandler)1051
battlehex.model.map.Territory.setCapital(ITile)1050
battlehex.model.map.Territory.merge(ITerritory)1041
battlehex.ui.main.TerritoryInfoDisplayer.select(IGrid,ITerritory)1031
Program NCSS: NCSS average CCN averageJavadocs average
1,633.004.391.760.66

Explanations

[ packages] [ objects] [ functions] [ explanations]

Non Commenting Source Statements (NCSS)

Statements for JavaNCSS are not statements as specified in the Java Language Specification but include all kinds of declarations too. Roughly spoken, NCSS is approximately equivalent to counting ';' and '{' characters in Java source files.

Actually, the NCSS counter gets incremented by one for each:

ExamplesComment
Package declarationpackage java.lang;
Import declarationimport java.awt.*;
Class declaration- public class Foo {

- public class Foo extends Bla {
Interface declarationpublic interface Able ; {
Field declaration- int a;

- int a, b, c = 5, d = 6;
No matter how many fields get actually declared through a comma separated list, and no matter if these fields get actually initialized, only one statement is counted. So "int a, b, c = 5, d = 6;" gets only +1 count, not four or even six (let me know if there is good reason to count it differently).
Method declaration- public void cry();

- public void gib() throws DeadException {
Constructor declarationpublic Foo() {
Constructor invocation- this();

- super();
Statement- i = 0;

- if (ok)

- if (exit) {

- if (3 == 4);

- if (4 == 4) { ; }

- } else {
expression, if, else, while, do, for, switch, break, continue, return, throw, synchronized, catch, finally
Labelfine :normal, case, default

Not counted are empty statements, empty blocks or semicolons after closing brackets. Of course, comments don't get counted too. Closing brackets also never get counted, the same applies to blocks in general.

In some cases consecutive semicolons are illegal according to the JLS but JavaNCSS still tolerates them (thought JavaNCSS is still more strict as 'javac'). Nevertheless they are never counted as two statements.

Cyclomatic Complexity Number (CCN)

CCN is also know as McCabe Metric. There exists a much hyped theory behind it based on graph theory, but it all comes down to simply counting 'if', 'for', 'while' statements etc. in a method. Whenever the control flow of a method splits, the "CCN counter" gets incremented by one.

Each method has a minimum value of 1 per default. For each of the following Java keywords/statements this value gets incremented by one:

  • if
  • for
  • while
  • case
  • catch
Also if the control flow of a method returns abortively the CCNvalue will be incremented by one:
  • return
  • throw

An ordinary return at the end of method (no matter if it's a function or a procedure) will not be counted.

Note that else, default, and finallydon't increment the CCN value any further. On the other hand, a simple method with a switchstatement and a huge block of casestatements can have a surprisingly high CCN value (still it has the same value when converting a switchblock to an equivalent sequence of ifstatements).

The first article about this trivial software metric is one of the most cited papers in computer science. Sometimes you just must be the first to point out some basic shit and you are history. It seems just like a wonder that nobody was able to package Lines of Code in a more scientific manner. Now it's too late to label someone's name on it :).