Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How can I get project statistics?
Message
De
26/06/2007 09:51:19
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 6 SP5
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Divers
Thread ID:
01235559
Message ID:
01235644
Vues:
33
This message has been marked as the solution to the initial question of the thread.
>Hi
>
>I want to produce some stats about a couple of large projects
>
>No of forms
>No of prg
>No of reports
>
>Lines of code
>
>Is there any easy way to do this?
>
>Thanks
>
>Colin

Here is one I wrote. Not perfect but met my needs
***************************************************************************
*!*	Method:			ProjMetrics
*!*	Purpose:		Calc some simple project metrics
*!*	Author:			bxk 11.11.03
*!*	Parameters:
*!*	Returns:
*!*	Modifications:	
***************************************************************************
LPARAMETERS tcProjectName

ASSERT !EMPTY(tcProjectName) .AND. VARTYPE(tcProjectName) = 'C' ;
	MESSAGE 'A project name is required'
	
ASSERT EMPTY(JUSTEXT(tcProjectName)) .OR. UPPER(JUSTEXT(tcProjectName)) = 'PJX' ;
	MESSAGE 'A _PROJECT_ name is required'
	
CLOS ALL
CLOS DATA ALL
SET CENTURY ON

LOCAL lnClassCount, lnFormCount, lnLibCount, lnLineCount, lnRptCount, ;
	lnDBFCount, lnProgCount, lcOut, lnLines, lcProjName, lcFileName, lnViewCount, ;
	lnTableCount
	
STORE 0 TO lnClassCount, lnFormCount, lnLibCount, lnLineCount, ;
	lnRptCount, lnDBFCount, lnProgCount, lnViewCount, lnTableCount
	
STORE "" TO lcOut

#DEFINE CRLF CHR(13) + CHR(10)

IF ! ('.' $ tcProjectName) 
	lcProjName = tcProjectName + '.PJX'
ELSE
	lcProjName = tcProjectName
ENDIF

USE (lcProjName) in 0 ALIAS metProject
SELECT metProject
SCAN FOR !DELETED()
	lcType = ALLTRIM(metProject.type)
	
	&& Handle project objects implemented as tables
	IF lcType $ 'M,V,K,R,d'
		lcObj = ALLTRIM(metProject.name)
		USE IN SELECT ('metObject')
		USE (lcObj) IN 0 AGAIN ALIAS metObject
		SELECT metObject
		
		DO CASE	
			CASE lcType = 'M'						&& Menus
				SCAN FOR !EMPTY(metObject.procedure)
					lnLines = ALINES(laLines, metObject.procedure)
					lnLineCount = lnLineCount + GetLineCount(@laLines)
				ENDSCAN
				
			CASE lcType = 'V'						&& ClassLibs
				COUNT TO lnCount FOR !EMPTY(class)
				lnClassCount = lnClassCount + lnCount
				lnLibCount = lnLibCount + 1
				
				SCAN FOR !EMPTY(methods)
					lnLines = ALINES(laLines, metObject.methods)
					lnLineCount = lnLineCount + GetLineCount(@laLines)
				ENDSCAN
			
			CASE lcType = 'K'						&& Forms
				lnFormCount = lnFormCount + 1
				SCAN FOR !EMPTY(metObject.methods)
					lnLines = ALINES(laLines, metObject.methods)
					lnLineCount = lnLineCount + GetLineCount(@laLines)
				ENDSCAN
			
			CASE lcType = 'R'						&& Reports
				lnRptCount = lnRptCount + 1
				SCAN FOR !EMPTY(metObject.expr)
					lnLines = ALINES(laLines, metObject.expr)
					lnLineCount = lnLineCount + GetLineCount(@laLines)
				ENDSCAN
				
			CASE lcType = 'd' 
				SCAN FOR !DELETED()
					DO CASE
						CASE objecttype = 'View'
							lnViewCount = lnViewCount + 1
						
						CASE objecttype = 'Table'
							lnTableCount = lnTableCount + 1
						
					ENDCASE
				ENDSCAN
			
		ENDCASE
		
	ELSE
		IF lcType = 'D'								&& Tables
			lnDBFCount = lnDBFCount + 1
		ELSE
			IF lcType = 'P'							&& Programs
				lnProgCount = lnProgCount + 1
				lcProg = ALLTRIM(metProject.name)
				lcLines = FILETOSTR(lcProg)
				lnLines = ALINES(laLines, lcLines)
				lnLineCount = lnLineCount + GetLineCount(@laLines)
			ENDIF
		ENDIF
		
	ENDIF

ENDSCAN

lcOut = lcOut + CRLF + CRLF 
lcOut = lcOut + DTOC(DATE())
lcOut = lcOut + CRLF + CRLF 
lcOut = lcOut + + 'Project metrics for: ' + lcProjName + CRLF + CRLF
lcOut = lcOut + 'Class Count      = ' + TRAN(lnClassCount) + CRLF
lcOut = lcOut + 'Lib Count        = ' + TRAN(lnLibCount) + CRLF
lcOut = lcOut + 'Form Count       = ' + TRAN(lnFormCount) + CRLF
lcOut = lcOut + 'Line Count       = ' + TRAN(lnLineCount) + CRLF
lcOut = lcOut + 'Report Count     = ' + TRAN(lnRptCount) + CRLF
lcOut = lcOut + 'Lookup Count     = ' + TRAN(lnDBFCount) + CRLF
lcOut = lcOut + 'Program Count    = ' + TRAN(lnProgCount) + CRLF
lcOut = lcOut + 'Data Table Count = ' + TRAN(lnTableCount) + CRLF
lcOut = lcOut + 'Data View Count  = ' + TRAN(lnViewCount) + CRLF

lcFileName = JUSTSTEM(lcProjName) + 'Metrics.txt'
StrToFile(lcOut, lcFileName)

MESSAGEBOX(lcFileName + ' Created')

CLOS DATA ALL


RETURN

***************************************************************************
*!*	Method:			GetLineCount
*!*	Purpose:		Returns lines of code in a Method, Prg.  Ignore comments
*!*					white space.
*!*	Author:			bxk
*!*	Parameters:
*!*	Returns:
*!*	Modifications:	
***************************************************************************
FUNCTION GetLineCount
LPARAMETERS taLines

LOCAL lnCount, lnLines
STORE 0 TO lnCount, lnLines

lnLines = ALEN(taLines)
FOR li = 1 TO lnLines
	IF EMPTY(taLines[li]) .OR. LEFT(ALLTRIM(taLines[li]), 1) $ '&*'
	
	ELSE
		lnCount = lnCount + 1
		
	ENDIF
ENDFOR

RETURN lnCount
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform