Counting Duplicate and Shared Lines of Code

4. August 2009 09:48 by Jaguilar in General  //  Tags: ,   //   Comments (0)

One question commonly asked by our customers is how both duplicate (same file copied in several projects) and shared files (one copy of the file referenced from multiple projects) are counted. If you create a migration solution using the VBUC, it counts the lines of code in a project (Lines column):

This number displayed in the VBUC includes all the lines of code from files referenced in the *.vbp project. This means that it counts shared files and duplicate files each time they appear. This may increase the final amount of lines of code of the total solution. If you do need to find out the number of lines of code counting these files once, we offer you two options:

The first one is to download and run our new Visual Basic 6.0 and ASP Assessment Tool. This brand-new assessment tool considers both Shared and Duplicate files and counts both accordingly in separate columns.  As shown in the screenshot below, the Assessment Tool identifies “Potential Duplicates”, which are files that have the same name and the same amount of effective (code + design) lines of code. In practice, they are normally the same file copied over several projects. You should note, however, that there may be small changes that keep the same amount of code (assignments, calls to different functions, etc), so there is no guarantee they are exactly the same. FYI, this was done to speed up the analysis process. In the future we will add additional heuristics to eliminate the possibility of false positives.

The second option is to use the same VBUC, but run a detailed analysis using the “Assessment” option. This can be executed from the main menu by selecting Upgrade->Assessment:

This is a more exhaustive assessment than the one executed by the VB6.0/ASP Assessment Tool, and takes much longer to execute. This assessment will not create an HTML report (like the VB6.0/ASP Assessment Tool), but you can open the detailed line count report produced (Assessment_LOC_Report.xml) using MS Excel 2003 or higher.

Categories