Total Pageviews

2014/12/09

Utilize CLOC(Count Lines of Code) to count lines of code

Requirement
If I would like to count lines of code for each Java program in my Java project, which tool can help me?

Solution
Go to http://cloc.sourceforge.net/ to download exe file (i.e. cloc-1.62.exe).

Assume cloc-1.62.exe had been saved into D:\software
Assume the Java project located in D:\workspace2\ave\ave-webapp\src\main\java
  • Step1. open command prompt.
  • Step2. Change directory to Java project directory, i.e. D:\workspace2\ave\ave-webapp\src\main\java
  • Step3. Execute this command: d:\software\cloc-1.62.exe . --by-file

Check the result:
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
D:\workspace2\ave\ave-webapp\src\main\java>d:\software\cloc-1.62.exe . --by-file
      94 text files.
      94 unique files.
       8 files ignored.

http://cloc.sourceforge.net v 1.62  T=0.32 s (296.3 files/s, 60038.9 lines/s)
------------------------------------------------------------------------------------------------------------
File                                                                     blank        comment           code
------------------------------------------------------------------------------------------------------------
.\gov\nta\ave\web\rest\Ave102eResource.java                                369            299           1505
.\gov\nta\ave\web\rest\Ave104eResource.java                                195            235            907
.\gov\nta\ave\web\rest\Ave103eResource.java                                198            235            891
.\gov\nta\ave\web\rest\Ave101eResource.java                                199            242            890
.\gov\nta\ave\web\rest\Ave106eResource.java                                188            148            783
.\gov\nta\ave\web\rest\Ave401eResource.java                                212            234            772
.\gov\nta\ave\web\rest\Ave201eResource.java                                110             91            576
.\gov\nta\ave\web\rest\Ave105eResource.java                                 85             16            405
.\gov\nta\ave\web\controller\Ave608rReportController.java                  107            114            338
.\gov\nta\ave\web\controller\Ave201eReportController.java                   69             38            334
.\gov\nta\ave\web\rest\Ave904eResource.java                                 57             71            309
.\gov\nta\ave\web\rest\Ave903eResource.java                                 80             23            251
.\gov\nta\ave\web\controller\Ave114rReportController.java                   58             43            227
.\gov\nta\ave\web\controller\Ave613rReportController.java                   54             37            194
.\gov\nta\ave\web\controller\Ave401eReportController.java                   70             38            178
.\gov\nta\ave\web\rest\Ave121eResource.java                                 46             26            168
.\gov\nta\ave\web\rest\Ave115qResource.java                                 31             38            168
.\gov\nta\ave\web\rest\Ave907eResource.java                                 45             66            157
.\gov\nta\ave\web\rest\Ave117rResource.java                                 50             43            150
.\gov\nta\ave\web\controller\Ave609rReportController.java                   33             35            148
.\gov\nta\ave\web\controller\Ave108rReportController.java                   35             41            147
.\gov\nta\ave\web\controller\Ave116rReportController.java                   43             24            146
.\gov\nta\ave\web\rest\Ave909eResource.java                                 39             13            140
.\gov\nta\ave\web\controller\Ave611rReportController.java                   30             12            137
.\gov\nta\ave\web\controller\Ave502rReportController.java                   40             30            117
.\gov\nta\ave\web\controller\Ave105eReportController.java                   24              2            112
.\gov\nta\ave\web\controller\Ave610rReportController.java                   40             29            111
.\gov\nta\ave\web\rest\Ave905eResource.java                                 31              4            108
.\gov\nta\ave\web\controller\Ave605rReportController.java                   24             16            104
.\gov\nta\ave\web\rest\Ave112qResource.java                                 32             25            100
.\gov\nta\ave\web\controller\Ave117rReportController.java                   17             11             82
.\gov\nta\ave\web\rest\Ave501eResource.java                                 14              0             78
.\gov\nta\ave\web\controller\Ave607rReportController.java                   20             10             75
.\gov\nta\ave\web\dto\Ave102eFormBean.java                                  40             32             75
.\gov\nta\ave\web\rest\Ave114rResource.java                                 16             25             73
.\gov\nta\ave\web\controller\Ave601rReportController.java                   17              2             71
.\gov\nta\ave\web\rest\Ave901eResource.java                                 15              0             71
.\gov\nta\ave\web\controller\Ave602rReportController.java                   17              2             71
.\gov\nta\ave\web\rest\Ave110qResource.java                                 19              1             70
.\gov\nta\ave\web\dto\Ave106eFormBean.java                                  26             16             68
.\gov\nta\ave\web\controller\Ave405rReportController.java                   18             10             67
.\gov\nta\ave\web\rest\Ave122qResource.java                                 14              8             67
.\gov\nta\ave\web\controller\Ave406rReportController.java                   23              4             67
.\gov\nta\ave\web\rest\Ave111qResource.java                                 17              1             64
.\gov\nta\ave\web\controller\Ave612rReportController.java                   17             11             61
.\gov\nta\ave\web\controller\Ave604rReportController.java                   16              1             58
.\gov\nta\ave\web\controller\Ave403rReportController.java                   18             12             56
.\gov\nta\ave\web\dto\Ave101eFormBean.java                                  14              7             56
.\gov\nta\ave\web\dto\Ave103eFormBean.java                                  14              7             56
.\gov\nta\ave\web\dto\Ave104eFormBean.java                                  14              7             56
.\gov\nta\ave\web\controller\Ave408rReportController.java                   18             11             55
.\gov\nta\ave\web\controller\Ave603rReportController.java                   14              0             53
.\gov\nta\ave\web\controller\Ave410rReportController.java                   15             21             53
.\gov\nta\ave\web\controller\Ave606rReportController.java                   16             10             52
.\gov\nta\ave\web\controller\Ave115qReportController.java                   14              9             46
.\gov\nta\ave\web\controller\Ave107rReportController.java                   12              5             46
.\gov\nta\ave\web\controller\Ave904eReportController.java                   14              1             45
.\gov\nta\ave\web\rest\Ave902eResource.java                                 10              0             45
.\gov\nta\ave\web\controller\Ave113qReportController.java                   11              6             44
.\gov\nta\ave\web\dto\Ave201eFormBean.java                                  19             12             43
.\gov\nta\ave\web\controller\Ave203rReportController.java                   16             16             43
.\gov\nta\ave\web\controller\Ave501eReportController.java                   11              0             42
.\gov\nta\ave\web\controller\Ave903eReportController.java                   13              1             41
.\gov\nta\ave\web\controller\Ave901eReportController.java                   14              0             36
.\gov\nta\ave\web\controller\Ave402rReportController.java                   11              0             36
.\gov\nta\ave\web\controller\Ave303rReportController.java                   10              0             35
.\gov\nta\ave\web\controller\Ave302rReportController.java                   11              2             33
.\gov\nta\ave\web\rest\Ave113qResource.java                                  8             14             32
.\gov\nta\ave\web\controller\Ave404rReportController.java                    8              7             31
.\gov\nta\ave\web\controller\Ave204rReportController.java                    9              7             30
.\gov\nta\ave\web\controller\Ave202rReportController.java                    6              0             30
.\gov\nta\ave\web\controller\Ave407rReportController.java                    8              1             28
.\gov\nta\ave\web\controller\Ave301rReportController.java                    9              1             28
.\gov\nta\ave\web\controller\Ave409rReportController.java                    9              1             28
.\gov\nta\ave\web\dto\Ave608rFormBean.java                                  21              0             24
.\gov\nta\ave\web\dto\Ave609rFormBean.java                                  19              0             22
.\gov\nta\ave\web\dto\Ave401eFormBean.java                                  19              0             22
.\gov\nta\ave\web\dto\Ave903eFormBean.java                                  16              0             19
.\gov\nta\ave\web\dto\Ave121eFormBean.java                                  14              0             18
.\gov\nta\ave\web\dto\Ave613rFormBean.java                                   7              0             18
.\gov\nta\ave\web\dto\Ave610rFormBean.java                                  10              0             13
.\gov\nta\ave\web\dto\Ave105eFormBean.java                                   7              0             11
.\gov\nta\ave\web\dto\Ave122qFormBean.java                                   6              0             10
.\gov\nta\ave\web\dto\Ave907eFormBean.java                                   4              0              8
.\gov\nta\ave\web\dto\Ave113qFormBean.java                                   4              0              7
.\gov\nta\ave\web\dto\Ave905eFormBean.java                                   2              0              7
.\gov\nta\ave\web\dto\Ave203rFormBean.java                                   2              0              7
.\gov\nta\ave\web\dto\ComboboxDto.java                                       4              0              7
.\gov\nta\ave\web\dto\Ave606rFormBean.java                                   2              0              7
.\gov\nta\ave\web\dto\Ave404rFormBean.java                                   2              0              7
.\gov\nta\ave\web\dto\Ave403rFormBean.java                                   3              0              6
.\gov\nta\ave\web\rest\package-info.java                                     0              5              1
.\gov\nta\ave\web\controller\package-info.java                               0              3              1
.\gov\nta\ave\web\dto\package-info.java                                      0              3              1
------------------------------------------------------------------------------------------------------------
SUM:                                                                      3388           2571          13086
------------------------------------------------------------------------------------------------------------

D:\workspace2\ave\ave-webapp\src\main\java>


Reference
[1] http://cloc.sourceforge.net/

No comments: