Here is the usage for the tool:
It was written by ZhonJohansen? and JeffGrover and reveals interesting attributes of C, C++ or Java code (may work for C# and other C-like languages as well?):
- {{{Usage: ruby metrics.rb [switches] start_directory
- -a, --all-reports generate all metrics reports -d, --duplicate find duplicate code -g, --gnuplot produce gnuplot output files to -i, --includes analyze dependencies for quanitity and cycles -l, --line-count count total number of lines in files and functions -s, --conditionals conditional logic (switch/case, if/else) -u, --unused find unused functions and #if 0 or commented code -v, --verbose display details up to
}}}
Here is some sample output (run against our library system):
- {{{ruby metrics.rb -a -v10 XPUtah\library Running metrics with arguments: Gathering metrics for XPUtah\library: Lines File
19 TitleTest.java 17 Title.java 17 PatronTest.java 26 PatronListTest.java 17 PatronList.java 25 Patron.java 19 Main.java
122 LibraryTest.java 108 Library.java
87 CommandRunnerTest.java 90 CommandRunner.java 33 BookTest.java 54 BookListProxyTest.java
112 BookListProxy.java
27 BookListImpl.java
6 BookList.java
22 AllTests.java
- Total unique, pertinent lines: 507 Number of lines occurring more than once: 48 Percentage of duplicate lines 9.467455621301776% Highest percent duplication within a file: 21.62162162162162%
- Book.java at line(s) 1
BookListProxyTest.java at line(s) 2 BookListImpl.java at line(s) 2 CommandRunner.java at line(s) 1 LibraryTest.java at line(s) 2 Patron.java at line(s) 1 TitleTest.java at line(s) 1 BookListProxy.java at line(s) 1 Library.java at line(s) 2
CommandRunnerTest.java at line(s) 16 23 30 37 44 51 63 84
The line: 'CommandRunner runner = new CommandRunner (commandLine);' occurs 8 tot al times in
CommandRunnerTest.java at line(s) 15 22 29 36 43 50 62 83
BookListProxyTest.java at line(s) 6 BookTest.java at line(s) 4 CommandRunnerTest.java at line(s) 7 LibraryTest.java at line(s) 13 PatronTest.java at line(s) 6 TitleTest.java at line(s) 9 PatronListTest.java at line(s) 6
BookTest.java at line(s) 7 10 14 18
BookListImpl.java at line(s) 1 PatronList.java at line(s) 1 BookListProxy.java at line(s) 2 Library.java at line(s) 1
- Main.java at line(s) 5 Library.java at line(s) 85 92
CommandRunnerTest.java at line(s) 56 69 76
LibraryTest.java at line(s) 52 96 108
CommandRunner.java at line(s) 25 58 69
File: BookListProxyTest.java Proportion of duplicated lines in file: 21.62162162162162% Number of unique duplicated lines: 8
File: PatronListTest.java Proportion of duplicated lines in file: 12.5% Number of unique duplicated lines: 2
File: LibraryTest.java Proportion of duplicated lines in file: 12.34567901234568% Number of unique duplicated lines: 10
File: BookListProxy.java Proportion of duplicated lines in file: 9.090909090909092% Number of unique duplicated lines: 5
File: CommandRunnerTest.java Proportion of duplicated lines in file: 6.896551724137931% Number of unique duplicated lines: 4
File: CommandRunner.java Proportion of duplicated lines in file: 6.25% Number of unique duplicated lines: 4
File: BookTest.java Proportion of duplicated lines in file: 4.761904761904762% Number of unique duplicated lines: 1
- File: Book.java Proportion of duplicated lines in file: 3.448275862068965% Number of unique duplicated lines: 1
- File: Library.java Proportion of duplicated lines in file: 3.448275862068965% Number of unique duplicated lines: 2
- Line Count Summary:
- Most comment lines: 6 (in file Title.java)
Most global lines: 10 (in file LibraryTest.java) Longest function: 31 lines (function go() in file CommandRunner.java) Most functions in file: 14 (in file Library.java) Total comment lines: 11 Total global code: 94 lines Total code: 705 lines Total number of files: 18 Total number of functions: 92 Average function length: 6.641304347826087 lines Average comment lines per file: 0 Average functions per file: 5 Average file length: 39 lines
CommandRunner.java
- go() 31 addPatron() 12 addBook() 10 checkOut() 9
CommandRunner() 4
BookListProxy.java
- loadBooks() 20 saveBooks() 16 getBookById() 12 getBookByName() 11 run() 10
- loadPatrons() 19 savePatrons() 17 getDueDate() 10 getBookById() 5 createNewTitle() 4
CommandRunnerTest.java
- testCheckOut() 15 testAddPatron() 10 testPatronSearchFail() 6 testISBNSearch() 6 testAddBook() 6
LibraryTest.java
- testNoPatronFile() 15 testBooksPersistence() 15 testPatronPersistence() 12 testGetBookByName() 12 testAddAndGetPatron() 9
- saveBook() 14 loadBook() 13 checkOut() 7 Book() 5 equals() 4
BookListProxyTest.java
- testPersistingMultipleBooks() 14 testPersistingBook() 11 testRetrievingBookWithoutPersistence() 10
- main() 14
AllTests.java
- suite() 12 main() 4
PatronListTest.java
- testAdd() 7 testIsValid() 6
PatronListTest() 3 testCantAddDuplicate() 2
- Total blocks of dead code: 0 Total uncalled functions: 34
testPersistingMultipleBooks (in file: BookListProxyTest.java) main (in file: AllTests.java) testCantAddDuplicate (in file: PatronListTest.java) testCreateBook (in file: BookTest.java) testSerialize (in file: BookTest.java) testRetrievingBookWithoutPersistence (in file: BookListProxyTest.java) testAddPatron (in file: CommandRunnerTest.java) testAddBook (in file: CommandRunnerTest.java) testBooksPersistence (in file: LibraryTest.java) getBookMap (in file: BookListImpl.java) getDueDate (in file: Library.java) testPatronPersistence (in file: LibraryTest.java) tearDown (in file: LibraryTest.java) testBookName (in file: BookTest.java) testAddAndGetPatron (in file: LibraryTest.java) testIsValid (in file: PatronListTest.java) testAdd (in file: PatronListTest.java) testNoPatronFile (in file: LibraryTest.java) testPatronSearchFail (in file: CommandRunnerTest.java) testAuthorSearch (in file: CommandRunnerTest.java) testGetBookByName (in file: LibraryTest.java) testUnmatchedArgumentSearch (in file: CommandRunnerTest.java) testTitleSearch (in file: CommandRunnerTest.java) testISBNSearch (in file: CommandRunnerTest.java) testBookId (in file: BookTest.java) testGetBookByBookId (in file: LibraryTest.java) setUp (in file: CommandRunnerTest.java) testPersistingBook (in file: BookListProxyTest.java) testCreateTitle (in file: TitleTest.java) testCreateTitleUsingLibraryFactory (in file: TitleTest.java) testGetPatronId (in file: PatronTest.java) testCheckOut (in file: BookTest.java) testRemovePatron (in file: LibraryTest.java) testSaveBooksThroughLibrary (in file: LibraryTest.java)
- Number of cyclical dependencies: 0 Most dependencies in a source file: 0 (in file: ) Average dependencies per file: 0.0
- Book.java (0 dependencies)
BookListProxyTest.java (0 dependencies) Main.java (0 dependencies)
BookListImpl.java (0 dependencies) Title.java (0 dependencies)
BookTest.java (0 dependencies)
CommandRunner.java (0 dependencies)
CommandRunnerTest.java (0 dependencies)
LibraryTest.java (0 dependencies)
PatronList.java (0 dependencies)
- Most 'switch' statements: 0 (() in ) Most cases: 0 (() in )
Most if/else conditions: 18 (go() in CommandRunner.java)
- Most comment lines: 6 (in file Title.java)
}}}
