Code archives/Miscellaneous/Code statistics
This code has been declared by its author to be Public Domain code.
Download source code
| |||||
UPD: fixed some bugs | |||||
SuperStrict Global Files:Int = 1 Global Comments:Int Global CodeLines:Int Global CommentLines:Int Global Classes:Int Global CommentedClasses:Int Global Methods:Int Global CommentedMethods:Int Global Fields:Int Global CommentedFields:Int Global GlobalFunctions:Int Global CommentedGlobalFunctions:Int Global GlobalVariables:Int Global CommentedGlobalVariables:Int Global Constants:Int Global CommentedConstants:Int Local FileName:String = RequestFile( "Select bmx file to process...", "bmx" ) Print "File " + StripDir( FileName ) + ":" ProcessFile( FileName ) Print "" Print "Files: " + Files Print "Code lines: " + CodeLines Print "Comment lines: " + CommentLines Print "" Print "Classes: " + StatEntry( Classes, CommentedClasses, False ) Print "Class fields: " + StatEntry( Fields, CommentedFields ) Print "Class methods / functions: " + StatEntry( Methods, CommentedMethods ) Print "" Print "Global functions: " + StatEntry( GlobalFunctions, CommentedGlobalFunctions, False ) Print "Global variables: " + StatEntry( GlobalVariables, CommentedGlobalVariables, False ) Print "Constants: " + StatEntry( Constants, CommentedConstants, False ) Print "" Print "Total items: " + StatEntry( Classes + Methods + Fields + GlobalFunctions + GlobalVariables + Constants, CommentedClasses + .. CommentedMethods + CommentedFields + CommentedGlobalFunctions + CommentedGlobalVariables + CommentedConstants, False ) Function ProcessFile( FileName:String ) Local File:TStream = ReadFile( FileName ) Local OldDir:String = CurrentDir() ChangeDir( ExtractDir( FileName ) ) Local RemFlag:Int Local InClass:Int Local Commented:Int Local FirstLines:Int = True While Not EOF( File ) Local Line:String = Trim( ReadLine( File ) ).ToLower() If RemFlag Then If Line.StartsWith( "endrem" ) Or Line.StartsWith( "end rem" ) Then RemFlag = False Else If Line.StartsWith( "bbdoc" ) Then Commented = True If Not FirstLines Then CommentLines :+ 1 End If Else If Line = "rem" Or Line.StartsWith( "rem " ) Then RemFlag = True Else If Line.StartsWith( "'" ) If Not FirstLines Then CommentLines :+ 1 Else If Line.StartsWith( "include" ) ProcessFile( Line[ 8.. ].Replace( "~q", "" ) ) Files :+ 1 ElseIf Line <> "" Then FirstLines = False CodeLines :+ 1 If Line.StartsWith( "type" ) Then InClass = True Set( Classes, CommentedClasses, Commented ) Else If Line.StartsWith( "endtype" ) Or Line.StartsWith( "end type" ) Then InClass = False Else If Line.StartsWith( "method" ) Then Set( Methods, CommentedMethods, Commented ) Else If Line.StartsWith( "function" ) Then If InClass Then Set( Methods, CommentedMethods, Commented ) Else Set( GlobalFunctions, CommentedGlobalFunctions, Commented ) Else If Line.StartsWith( "field" ) Then Set( Fields, CommentedFields, Commented ) Fields :+ CountCommas( Line ) ElseIf Line.StartsWith( "global" ) Then Set( GlobalVariables, CommentedGlobalVariables, Commented ) ElseIf Line.StartsWith( "const" ) Then Set( Constants, CommentedConstants, Commented ) End If End If WEnd CloseFile( File ) ChangeDir( OldDir ) End Function Function Set( Items:Int Var, CommentedItems:Int Var, Commented:Int Var ) Items :+ 1 If Commented Then CommentedItems :+ 1 Commented = False End Function Function CountCommas:Int( Line:String ) Local Commas:Int Local Quotes:Int For Local N:Int = 0 Until Len( Line ) If Line[ N ] = Asc( "~q" ) Then Quotes = Not Quotes ElseIf Not Quotes Then If Line[ N ] = Asc( "," ) Then Commas :+ 1 End If Next Return Commas End Function Function TrimDouble:String( Value:Double ) Local StringValue:String = Value Return StringValue[ ..StringValue.Find( "." ) + 3 ] End Function Function StatEntry:String( Items:Int, CommentedItems:Int, WithClasses:Int = True ) Local ClassString:String = "" If WithClasses Then ClassString = TrimDouble( 1.0 * Items / ( Classes + ( Classes = 0 ) ) ) + " per class, " Return Items + " (" + ClassString + CommentedItems + " or " + TrimDouble( 100.0 * CommentedItems / ( Items + ( Items = 0 ) ) ) + "% commented)" End Function |
Comments
| ||
DWLab framework stats:Files: 41 Code lines: 4215 Comment lines: 999 Classes: 49 (37 or 75.51% commented) Class fields: 175 (3.57 per class, 62 or 35.42% commented) Class methods / functions: 365 (7.44 per class, 233 or 63.83% commented) Global functions: 43 (25 or 58.13% commented) Global variables: 27 (4 or 14.81% commented) Constants: 29 (16 or 55.17% commented) Total items: 688 (377 or 54.79% commented) DWLab world editor stats: Files: 21 Code lines: 2895 Comment lines: 13 Classes: 17 (0 or 0.00% commented) Class fields: 195 (11.47 per class, 0 or 0.00% commented) Class methods / functions: 94 (6.11 per class, 0 or 0.00% commented) Global functions: 11 (0 or 0.00% commented) Global variables: 7 (0 or 0.00% commented) Constants: 73 (0 or 0.00% commented) Total items: 397 (0 or 0.00% commented) Super Mario Bros remake stats: Files: 26 Code lines: 1129 Comment lines: 5 Classes: 53 (0 or 0.00% commented) Class fields: 117 (2.20 per class, 0 or 0.00% commented) Class methods / functions: 112 (2.16 per class, 0 or 0.00% commented) Global functions: 0 (0 or 0.00% commented) Global variables: 1 (0 or 0.00% commented) Constants: 83 (0 or 0.00% commented) Total items: 366 (0 or 0.00% commented) MindStorm stats: Files: 11 Code lines: 379 Comment lines: 0 Classes: 10 (0 or 0.00% commented) Class fields: 48 (4.79 per class, 0 or 0.00% commented) Class methods / functions: 22 (2.20 per class, 0 or 0.00% commented) Global functions: 0 (0 or 0.00% commented) Global variables: 1 (0 or 0.00% commented) Constants: 30 (0 or 0.00% commented) Total items: 111 (0 or 0.00% commented) Huge isometric maze stats: Files: 5 Code lines: 263 Comment lines: 0 Classes: 6 (0 or 0.00% commented) Class fields: 20 (3.33 per class, 0 or 0.00% commented) Class methods / functions: 13 (2.16 per class, 0 or 0.00% commented) Global functions: 1 (0 or 0.00% commented) Global variables: 2 (0 or 0.00% commented) Constants: 11 (0 or 0.00% commented) Total items: 53 (0 or 0.00% commented) Post code statistics of your projects. |
| ||
wxmax stats:Files: 221 Code lines: 34566 Comment lines: 15253 Classes: 636 (482 or 75.78% commented) Class fields: 155 (0.24 per class, 3 or 1.93% commented) Class methods / functions: 6810 (10.70 per class, 5281 or 77.54% commented) Global functions: 145 (87 or 60.00% commented) Global variables: 42 (7 or 16.66% commented) Constants: 2283 (51 or 2.23% commented) Total items: 10071 (5911 or 58.69% commented) ... excluding the extern functions and consts Files: 430 Code lines: 46990 Comment lines: 15858 Classes: 636 (482 or 75.78% commented) Class fields: 161 (0.25 per class, 3 or 1.86% commented) Class methods / functions: 6810 (10.70 per class, 5281 or 77.54% commented) Global functions: 5494 (87 or 1.58% commented) Global variables: 46 (7 or 15.21% commented) Constants: 4443 (148 or 3.33% commented) Total items: 17590 (6008 or 34.15% commented) ... including the extern functions and consts... :o) |
| ||
wow! |
| ||
DWLab 1.3.2Files: 71 Code lines: 6002 Comment lines: 1316 Classes: 74 (50 or 67.56% commented) Class fields: 277 (3.74 per class, 97 or 35.01% commented) Class methods / functions: 511 (6.90 per class, 313 or 61.25% commented) Global functions: 51 (32 or 62.74% commented) Global variables: 57 (11 or 19.29% commented) Constants: 41 (18 or 43.90% commented) Total items: 1011 (521 or 51.53% commented) Color Lines 1.0 beta: Files: 29 Code lines: 1045 Comment lines: 15 Classes: 33 Class fields: 72 Class methods / functions: 91 Global functions: 1 Global variables: 5 Constants: 22 Total items: 224 |
Code Archives Forum