Code Analyzer |
|
Home McCabe Complexity Download software |
OverviewCode Analyzer can be used to count lines of code (LoC) at the file level or at the function level. When counting at the function level, it also computes the McCabe complexity & the level of nesting inside the function. Counting at file levelWhen used for this purpose, it gives the number of code lines, code & comment lines, commment lines and blank lines in the file. It supports the following file types:
When counting for HTML or JSP files, it will count LoC correctly for javascript and vbscript code embedded within the <script> tag. Counting can be done for a single file or a directory (with the option of recursively counting within sub-directories). The values are written to a .csv file so that it can be opened and analyzed using Excel. This functionality is invoked when the Count LoC button is pressed after selecting a file or directory. Counting at function levelThis can be done for the filetypes - C++, Java and VB. In additional to giving LoC at function level, it also gives the McCabe Complexity of the function & the nesting level within the function. For an explanation of McCabe complexity, please see the document on Structured Testing that can be downloaded from this page. Function level counting is invoked when the Count Detail button is pressed after selecting a file or directory. Using the generated infoLoC is one of the measures of software size. It is often debated as a size measure because:
While this is true, I assume an organization will have coding standards and there will be code reviews, which will lessen the impact of the above anomalies. Hence, it is still a reasonable measure of size across projects implemented in a given language within the same organization. Often I have seen management judging the quality of software based on bugs reported in a release. Modules are compared based on reported bugs, often ignoring their relative size. Defects per KLOC gives a more reasonable picture in this scenario. Also, KLOC can be used to measure individual productivity, especially when its fresh software development (not bug fixing or enhancements to existing software).McCabe complexity is a good measure of how complex the software is and the number of tests required to validate the correctness of the software. For greater software reliability, it is desirable to limit this complexity. So if you have lengthy, highly complex functions that are frequently being touched to fix bugs, consider refactoring it to reduce the complexity.
Known tool limitations
Other infoType of a file (whether Java or C++ etc.) is identified based on file extensions. Use the Config button to change the file extensions, if you are not ok with the defaults. Feedback about the tool are most welcome - pl write to me. |