JavaNCSS Metric Results

[ package ] [ object ] [ function ] [ explanation ]

The following document contains the results of a JavaNCSS metric analysis.
JavaNCSS web site.

Packages

[ package ] [ object ] [ function ] [ explanation ]

Packages sorted by NCSS.

Package Classes Functions NCSS Javadocs Javadoc lines Single lines comment Multi lines comment
net.sf.json 10 377 3233 292 2111 25 236
net.sf.json.util 13 107 968 107 728 6 314
net.sf.json.xml 2 66 835 41 244 10 35
net.sf.json.test 1 28 268 29 107 1 18
net.sf.json.groovy 2 19 218 2 78 3 30
net.sf.json.processors 12 16 120 23 158 0 184
net.sf.json.filters 7 19 103 7 21 0 105
net.sf.json.regexp 4 14 67 9 44 0 60
Classes total Functions total NCSS total Javadocs Javadoc lines Single lines comment Multi lines comment
51 646 5812 510 3491 45 982

Objects

[ package ] [ object ] [ function ] [ explanation ]

TOP 30 classes containing the most NCSS.

Object NCSS Functions Classes Javadocs
net.sf.json.JSONObject 1294 102 0 68
net.sf.json.JSONArray 1164 130 1 88
net.sf.json.xml.XMLSerializer 791 66 2 40
net.sf.json.JsonConfig 432 98 0 97
net.sf.json.util.JSONUtils 370 41 0 41
net.sf.json.test.JSONAssert 255 28 0 29
net.sf.json.util.JSONTokener 227 21 0 19
net.sf.json.groovy.JsonGroovyBuilder 167 11 0 1
net.sf.json.util.JSONBuilder 89 14 0 15
net.sf.json.util.JavaIdentifierTransformer 79 2 5 2
net.sf.json.AbstractJSON 67 11 1 11
net.sf.json.JSONFunction 66 8 0 7
net.sf.json.util.WebUtils 60 12 0 6
net.sf.json.JSONSerializer 52 6 0 7
net.sf.json.JSONNull 32 11 0 4
net.sf.json.filters.MappingPropertyFilter 27 6 0 1
net.sf.json.groovy.JsonSlurper 23 8 0 1
net.sf.json.util.CycleDetectionStrategy 23 2 3 3
net.sf.json.filters.CompositePropertyFilter 22 5 0 1
net.sf.json.regexp.Perl5RegexpMatcher 19 4 0 1
net.sf.json.regexp.RegexpUtils 17 4 0 4
net.sf.json.processors.DefaultDefaultValueProcessor 17 1 0 1
net.sf.json.regexp.JdkRegexpMatcher 16 4 0 1
net.sf.json.processors.JsDateJsonBeanProcessor 12 1 0 2
net.sf.json.util.NewBeanInstanceStrategy 12 1 1 2
net.sf.json.util.PropertySetStrategy 11 1 1 1
net.sf.json.processors.JsDateJsonValueProcessor 10 4 0 1
net.sf.json.JSONException 10 4 0 1
net.sf.json.filters.OrPropertyFilter 10 2 0 1
net.sf.json.filters.AndPropertyFilter 10 2 0 1

TOP 30 classes containing the most functions.

Object NCSS Functions Classes Javadocs
net.sf.json.JSONArray 1164 130 1 88
net.sf.json.JSONObject 1294 102 0 68
net.sf.json.JsonConfig 432 98 0 97
net.sf.json.xml.XMLSerializer 791 66 2 40
net.sf.json.util.JSONUtils 370 41 0 41
net.sf.json.test.JSONAssert 255 28 0 29
net.sf.json.util.JSONTokener 227 21 0 19
net.sf.json.util.JSONBuilder 89 14 0 15
net.sf.json.util.WebUtils 60 12 0 6
net.sf.json.JSONNull 32 11 0 4
net.sf.json.groovy.JsonGroovyBuilder 167 11 0 1
net.sf.json.AbstractJSON 67 11 1 11
net.sf.json.groovy.JsonSlurper 23 8 0 1
net.sf.json.JSONFunction 66 8 0 7
net.sf.json.util.JsonEventListener 9 8 0 9
net.sf.json.JSONSerializer 52 6 0 7
net.sf.json.filters.MappingPropertyFilter 27 6 0 1
net.sf.json.JSON 7 6 0 7
net.sf.json.filters.CompositePropertyFilter 22 5 0 1
net.sf.json.regexp.RegexpUtils 17 4 0 4
net.sf.json.regexp.Perl5RegexpMatcher 19 4 0 1
net.sf.json.regexp.JdkRegexpMatcher 16 4 0 1
net.sf.json.processors.JsDateJsonValueProcessor 10 4 0 1
net.sf.json.JSONException 10 4 0 1
net.sf.json.regexp.RegexpMatcher 3 2 0 3
net.sf.json.processors.JsonValueProcessor 3 2 0 3
net.sf.json.filters.OrPropertyFilter 10 2 0 1
net.sf.json.filters.NotPropertyFilter 8 2 0 1
net.sf.json.filters.AndPropertyFilter 10 2 0 1
net.sf.json.util.JSONStringer 5 2 0 3
Averages.
NCSS average Program NCSS Classes average Functions average Javadocs average
107.82 5,812.00 0.41 12.67 10.00

Functions

[ package ] [ object ] [ function ] [ explanation ]

TOP 30 functions containing the most NCSS.

Functions NCSS CCN Javadocs
net.sf.json.JSONObject.toBean(JSONObject,JsonConfig) 152 79 1
net.sf.json.JSONObject.toBean(JSONObject,Object,JsonConfig) 110 54 1
net.sf.json.JSONObject._fromJSONTokener(JSONTokener,JsonConfig) 102 52 0
net.sf.json.JSONObject._fromBean(Object,JsonConfig) 74 30 1
net.sf.json.JSONObject.equals(Object) 73 59 0
net.sf.json.util.JSONUtils.quote(String) 69 18 1
net.sf.json.JSONArray.equals(Object) 69 55 0
net.sf.json.xml.XMLSerializer.processJSONObject(JSONObject,Element,String[],boolean) 66 23 0
net.sf.json.xml.XMLSerializer.setValue(JSONArray,Element,String) 66 24 0
net.sf.json.xml.XMLSerializer.setValue(JSONObject,Element,String) 63 23 0
net.sf.json.JSONArray.fromObject(Object,JsonConfig) 62 42 1
net.sf.json.JSONArray._fromJSONTokener(JSONTokener,JsonConfig) 61 27 0
net.sf.json.JSONObject._fromMap(Map,JsonConfig) 60 28 0
net.sf.json.test.JSONAssert.assertEquals(String,JSONObject,JSONObject) 59 30 1
net.sf.json.test.JSONAssert.assertEquals(String,JSONArray,JSONArray) 57 30 1
net.sf.json.util.JSONTokener.nextValue(JsonConfig) 54 47 1
net.sf.json.JSONObject._fromDynaBean(DynaBean,JsonConfig) 47 20 0
net.sf.json.xml.XMLSerializer.processJSONValue(Object,Element,Element,String[]) 45 17 0
net.sf.json.JSONObject._fromJSONObject(JSONObject,JsonConfig) 43 21 0
net.sf.json.JsonConfig.copy() 42 4 0
net.sf.json.util.JSONUtils.getTypeClass(Object) 42 28 1
net.sf.json.JSONArray.toCollection(JSONArray,JsonConfig) 42 20 1
net.sf.json.JSONArray._processValue(Object,JsonConfig) 42 28 0
net.sf.json.util.JSONTokener.nextString(char) 41 16 1
net.sf.json.groovy.JsonGroovyBuilder.invokeMethod(String,Object) 40 17 0
net.sf.json.JSONObject._processValue(Object,JsonConfig) 39 27 0
net.sf.json.JSONArray.toArray(JSONArray,JsonConfig) 39 22 1
net.sf.json.JSONObject.toString(int,int) 38 14 1
net.sf.json.JsonConfig.reset() 35 1 1
net.sf.json.xml.XMLSerializer.getType(Element,String) 33 11 0

Averages.

Program NCSS NCSS average CCN average Javadocs average
5,812.00 7.63 4.21 0.67

Explanations

[ package ] [ object ] [ function ] [ explanation ]

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.

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.

Examples Comments
Package declaration package java.lang;
Import declaration import java.awt.*;
Class declaration
  • public class Foo {
  • public class Foo extends Bla {
Interface declaration public interface Able ; {
Field declaration
  • int a;
  • int a, b, c = 5, d = 6;
Method declaration
  • public void cry();
  • public void gib() throws DeadException {
Constructor declaration public Foo() {
Constructor invocation
  • this();
  • super();
Statement declaration
  • 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
Label declaration fine : normal, case, default

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:

  • if
  • for

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