Resource Standard Metrics for C, C++ and Java Visual Metrics Version 5.53 License Type: Site Multi-Network License - 10000 Users Licensed To : M Squared Technologies License No. : ST1000 License Date: Fri Jun 25 06:09:01 1999 (C) 2000 M Squared Technologies Run Date: Tue Oct 10 21:45:31 2000 ________________________________________________________________________ RSM Help Text Syntax: D:\BIN\RSM.EXE <-option -option parameter> filename or wild cards -A Automated processing CSV File Format output -A -f Functions and Files -A -i Generate Inheritance Tree -A -s File Summary -A -Ta Sorted Total Functions, Classes, Namespaces -A -Tf Sorted Total Functions -A -To Sorted Total Classes, Interfaces, Namespaces -A -TP Quality Notice Listing -A -Ti Inheritance Tree -A -W Work file differentials -A -x workfile.old workfile.new Work file extraction -a Allocation/de-allocation memory function counts -b Benchmark processing performance -C Comment Documentation relative to function or class -c Complexity measure, Cyclomatic and Interface -D De-character source, Warning: Modifies Source Code -t Remove tabs \t -u Remove carriage returns \r, make UNIX files -d Add carriage returns \r, create DOS files -d Determine source against LOC algorithm -E Extract literal strings or comments from source code -Es Extract strings -Ec Extract comments -e Estimation Analysis based on LOC and Complexity -f Function names and LOC per function -F process file names from list -H HTML output mode for use with a WWW browser -h Help and licensing information -i Inheritance tree generation -k Key sort for metrics reports -k0 No list sort (fastest operation) -k1 Sort by Name (default) -k2 Sort by LOC -k3 Sort by eLOC -k4 Sort by lLOC -k5 Sort by Cyclomatic Complexity -k6 Sort by Work File Difference State -l List function names declared in each file -m Macro names declared in each file -n Notices for code quality & common errors -N Notice format style -Ns Single line summary format -Nv Visual Studio and KAWA interactive format -o Object class metrics -O RSM output to a file instead of screen -p Printable format for source code -B1 Begin Top Margin -M5 Left Margin -P55 Page Length -L80 Line Length -S"string" Header String -r Recurse directory -R Read File Processing Options -Rd Process the directory (-r No Recursive Descent) -RL List files to be processed and exit -RN No file name sort -s Summary LOC metrics per file -T Totals only mode, Sorted -Ta Total Functions, Classes, Namespaces, Notices -Tf Total Functions, Classes Namespaces and Notices -Ti Inheritance Tree Only -To Total Classes, Interfaces, Namespaces -Tp Total Quality Profile -Tq Total Quality Notice Summary List -Tn Quality Notices Emitted by file and line number -Ts Total LOC Summary -TL Summaries Only, No Lists of functions, classes etc. -TN No file names displayed -v Verbose LOC, keywords and metrics -u User Log -us Show the current user log -ua (Network Lic) Archive log/restart -ur (Network Lic) Remove user from current log -w Work file created for the specified source files -W Work differential between last (workfile.dat) and now -x Extract work differential between two work files -y Display configuration parameters, export rsm.cfg -z Show Source/Software License Agreement -Z Show license and user log information filename or *.c *.h ../src/*.c etc. Resource Standard Metrics provides a standard method to quantify the quantity and quality of worked performed for a source code module or a project. This program will analyze a C, C++ or Java source for metrics and semantic quality problems which most compilers do not catch. Source files may be processed via wild cards, recursively down a file tree or from a specified list of file or directories. The evaluation copy of this program will only process 10 files at a one execution. Files are normally sorted alphabetically but this can be modified using the -RN runtime option. The -F section of this help file details the format for the file list. RSM processes files from 1 of four modes. 1. Direct Files rsm -f -o /proj/src/filename.cpp 2. Wild Cards rsm -f -o /proj/src/*.cpp 3. Recursive descent of a directory tree rsm -f -o -r h,cpp /proj/src 4. Reading from a list of files or directories rsm -f -o -F /proj/filelist.lst RSM uses runtime switches to configure its operation. There are two types of switches. The plain switch takes no parameters and the complex switch requires a modification parameter. Switches like f, o, v, c are plain switches they may be specified by using a dash for each switch or by running them as a single string. i.e. Plain Switches: rsm -focmnv *.cpp or rsm -f -o -c -m -n -v *.cpp Complex switches must be separated by a dash(-) for each switch. Each complex switch requires an additional modifier. If -r is used for recursive mode, it must be the last switch. i.e. Complex Switches: rsm -focmnv -k4 -r h,cpp c:\src where k and r are complex switches (LOC) Lines of code are defined as a line of code, if a line in the source code is not a blank line or not a comment line. (eLOC) Resource Standard Metrics defines an effective line of code as a LOC which is not stand-alone braces {} or parenthesis (). (lLOC) Logical Lines of code are defined as code statements or those lines which end in a semicolon. The for loop structure counts for one lLOC. Logical lines within a source file can exceed the physical lines within a file if there occurs code and comments on the same physical line. The sum of code, blanks and comments equates to the logical lines. Metrics programs that show code, comments and blank lines equal to the physical lines are not accounting for second instance of code or comments. Various key words and statements are provided for code analysis. Read-ability and code quality can easily be determined by analyzing the quality notices, comment percentage, white space content and key words used within the source code. RSM Configuration RSM is configured from a configuration file, rsm.cfg. If the configuration file is not found, RSM creates a configuration file. You can edit the configuration file with and ASCII editor to change the operation parameters of RSM. The configuration file is heavily commented to assist in this customization. You may use the -y option to examine the rsm.cfg file. RSM looks for the rsm.cfg file at the location where the license file was found. The rsm.cfg file, like the license file should be placed in a directory which should be located on your system path. The file name has to be rsm.cfg. File Names and Wild Cards The Windows operating system requires DOS type paths and filenames. The UNIX OS require UNIX paths and filename. Under Windows file name are case insensitive where in UNIX they are case sensitive. i.e. normal with wild cards: rsm -f -c *.c *.cc recursive descent: rsm -f -o -r c,cc,h,hh /proj read a file list: rsm -f -o -c -F filelist.txt (Windows) rsm -f -c c:\src\*.h c:\src\*.c (UNIX) rsm.sol -f- c /src/*.h /src/*.c Source File Requirements RSM is designed to process only source code from the C, ANSI C, C++ ANSI C++ and Java 2.0 languages. Do not attempt to have RSM process source files outside of these languages. RSM requires that each source file be compilable. RSM reads no preprocessor directives so that it may analyze all the source in a file. RSM will always process header files prior to source files. However there may be macros, like in Windows that are outside the language specification. These macros must be defined to RSM in the rsm_macro.cfg file, which is located with the rsm.lic license file. RSM is thoroughly tested against a suite of source files for all these languages. Run Time Switch Options The options shown with a * can be aggregated together to form compound reports. Some experimentation will be required to find the combination of options which yield the desired report Automated Processing CSV File Output Mode ------------------------------------------------------------------------ -A The CSV mode creates a Comma Separated Version output for import of metrics directly into spreadsheet programs. This output can be redirected to a file then directly opened by MS Excel. -A -f Functions and Files -A -i Inheritance Tree -A -s File Summary -A -Ta Sorted Total Functions, Classes, Namespaces -A -Tf Sorted Total Functions -A -Tq Quality Notice by File -A -To Sorted Total Classes, Interfaces, Namespaces -A -Ti Class inheritance tree -A -W Work file differentials -A -x Work file extraction i.e. rsm -A -f *.cpp *.c > metrics.csv rsm -A -Ta -k5 *.h *.cpp > metrics.csv rsm -A -w *.h *.cpp > diff.csv rsm -A -x oldfile.dat newfile.dat > diff.csv rsm -A -Ti -O proj_inherit.csv -F projfiles.txt * Allocation/De-allocation of Memory Mode ------------------------------------------------------------------------ -a Produces metrics on memory creation through the counting of instances of malloc, calloc, realloc and new. Memory de-allocation is measured by counting free and delete. This metric is useful for focusing on functions which use dynamic memory. Most program bugs can be attributed to problems in dynamic memory management. i.e. rsm -a *.c * Benchmark Mode ------------------------------------------------------------------------ -b This mode tracks the CPU, User, Wait and elapsed time for the running of RSM. This mode is intended to create a timing metric for RSM so that the time required to execute metrics is known. It may also serve as a benchmark for comparing RSM to other like products, although no other products are known which have as many features as RSM. i.e. rsm -b *.c * Comment Documentation Mode ------------------------------------------------------------------------ -C This mode extracts comments relative to functions and classes for the specified files by either wild cards or file specification options. This mode should not be used with other metrics options. i.e. rsm -C *.c * Complexity Mode ------------------------------------------------------------------------ -c This mode measures both cyclomatic complexity and function interface complexity. Function cyclomatic and interface complexity are combined to form function complexity. Cyclomatic complexity is consistent with McCabe's definition where each decision point or predicate node is counted plus 1 for the function body. RSM provides a logic keyword metric which provides insight to the degree of logic used within a function. The logic keywords counted are: while, if, case, for and goto. RSM provides a count of the number of comparison operators used within a function. This metric can provide insight into the ratio of comparisons to the number of logic keywords. If a module has a logic keyword count of 12 and a comparative count of 30, the module has branching decisions that are composed of at least two tests or conditions per logic construct. Functional interface complexity is calculated by summing the number of function input parameters and the number of return states. This metric can be useful when analyzing the complexity of a function's interface. A function's estimated size can be related to a function's interface complexity using the -e option. Function complexity is calculated by the sum of cyclomatic complexity and the interface complexity. The maximum and average complexity is reported for the file and for all files processed, the project. i.e. rsm -c *.java De-Character Source Files ------------------------------------------------------------------------ -D De-character source code to remove tabs, and convert source code from DOS to UNIX and UNIX to DOS format. This option operates in a standalone mode and modifies the original source. You must have the source code to be modified checked out with write permissions. -Dt Remove tabs where the tabs/space setting is in the rsm.cfg file. -Dd Create DOS format files, where each line terminates in a carriage return and new line. -Du Create UNIX format files, where each line is terminates in a new line. i.e. rsm -Dt -Du *.h *.cpp rsm -Dt -Dd h,c,cpp,java c:\proj\game Deterministic Mode ------------------------------------------------------------------------ -d This mode will show the user a line of source and how RSM determines whether the line is code or comment. Too often metrics tools yield code lines and comment lines equal to the physical lines measured. RSM accounts for comments and code on a single line and counts two logical lines. RSM also measure effective code by eliminating the lines of code which contain just { } or ( ). i.e. rsm -d source.c This mode produces the validation of the given source against the LOC algorithm of Resource Standard Metrics. Output will echo each line of code and a state of the LOC determination. Example Output: Line 1: /* functions using pointers to functions */ LOC Type(s): Line 2: LOC Type(s): Line 3: #include /*standard includes*/ LOC Type(s): Line 4: #include // more includes LOC Type(s): * Estimation Analysis Based on LOC and Complexity ------------------------------------------------------------------------ -e* Estimation analysis presents LOC, eLOC, lLOC per: function input parameter; function return state; interface complexity (parameters + returns); cyclomatic complexity and total functional complexity (Interface + Cyclo) complexity. i.e. rsm -e *.c Extract Strings or Comments from Source Code ------------------------------------------------------------------------ -E Extract strings or comments from a source file. This feature allows for the creation of a file which contains text. This file can then be spell checked using a program like GNU ispell or Microsoft Word. Each string/comment is output with the line number of the file for which it was located. This option should be used without any other RSM formatting options. -Ec Extract comments -Es Extract literal strings i.e. rsm -Es -Ec *.h *.cpp > spellcheck.txt rsm -Es -r h,c,cpp,java c:\proj\game > spellcheck.txt * Function Analysis Mode ------------------------------------------------------------------------ -f Function mode determines the functions in the source and if quality notices are on, it will perform quality checking on the functions. Modes -f and -n are usually used together. i.e. rsm -f *.c * File List Mode ------------------------------------------------------------------------ -F Will process files and directories from a list. This mode is useful for performing a discrete set of file metrics. The list must be a text file with compliant the specified format. The -RL mode can be helpful in creating the file list. File Format: Files must be the complete path and file name. i.e. c:\project\src\vertex.java /proj/source/geom.cpp Directory Format: Directories must the the full path. The following parameters to the directory are required for descent of the directory. -r Recursive descent of the directory -n No Recusive descent c,h,cpp Types string tells RSM which kind of files directory Starting point for processing i.e. -r java /proj/java/source -n h,cpp /proj/cpp/source Example File filelist.txt c:\src\control.c c:\src\display.c -r h,c,cpp,java d:\myprojects Note that no wild cards are valid in this mode. * HTML Output Mode ------------------------------------------------------------------------ -H This mode creates HTML output with color, fonts and hyperlinks to files. Such output is meant to be processed by a WWW browser like Netscape Navigator or MS Explorer. You may set the background color of the HTML reports by setting the associated parameter in the rsm.cfg file. If the background is not set, then the browser default background color will be used. The HTML option is designed for use with all RSM reports and options designated with a star '*'. i.e. rsm -Hfacmnv *.c > metrics.htm rsm -Hx rm122819.97 rm122919.97 > metrics.html netscape metrics.html The HTML text, vlink and link color must be specified together to override the standard browser default. You may redefine the specified HTML colors by setting the configuration item associated with each color. HTML colors may be specified by the #000000 hex value or by the text word. HTML hyperlinks are by default the literal file name. If you desire relative hyperlinks you can set the associated rsm.cfg file setting, Relative HTML Links: Yes. Help Mode ------------------------------------------------------------------------ -h Produces the help output. Such output can be printed under UNIX by piping the output to lpr or redirecting if to a file. UNIX: i.e. rsm -h | lpr rsm -h > help.txt DOS/W95/NT: i.e. rsm -h > prn rsm -h > help.txt * Inheritance Tree Generation ------------------------------------------------------------------------ -i This mode will generate an inheritance tree of all classes in the current file set. It is assumed that the user creates a file set that has some meaning to a design. When using wild cards, one should process header files before the implementation files. i.e. rsm -i *.h *.cpp * Key Project Sort Method ------------------------------------------------------------------------ -k This mode will sort the project summary data as specified by the key numeric identifier. This mode requires a modifier as specified below. -k0 No sorting methods (fastest operation) -k1 Sort by namespace/package, class or function name -k2 Sort by LOC -k3 Sort by eLOC -k4 Sort by lLOC -k5 Sort by Cyclomatic Complexity -k6 Sort by Work File Difference State i.e. rsm -fo -k3 *.h *.cpp * List Function Name Mode ------------------------------------------------------------------------ -l This mode produces a list of functions that can be cut and pasted from the output into the comment header of the file which was processed. It will create a report where all function names are correlated with their parent file. This is useful when documenting the system. i.e. rsm -l *.cc *.c Example Output: Function: Show Function: Drawable::Drawable Function: Drawable::Show * Macro Mode ------------------------------------------------------------------------ -m Macro mode is similar to function mode except it reports the names of the macros within the source. Macros are a common cause of maintenance and portability headaches, so locating their existence is quite valuable. In Windows code there is an occurrence of placing a macro between the function name and the function open parenthesis or between the class name and the opening brace. You must tell RSM about the macros by either processing the macro prior to its use or you may added the macro by name to a special file called rsm_macro.cfg. Names in this file are read at startup so that RSM knows about your macros defined in other portions of the code which may not be processed by RSM. The rsm_macro.cfg file is located with your rsm.lic license file. i.e. rsm -fm *.c * Quality Notice Mode ------------------------------------------------------------------------ -n Turns on quality checking on the source for approximately 50 common problems which create difficult maintenance, porting or semantic bugs the compiler simply misses. This mode will return the number of notices to the operating system upon RSM normal exit. This will enable scripting languages to pickup the non-zero exit state and flag the end user. i.e. rsm -facmn *.cc *.c *.cpp * Quality Notice Format Mode ------------------------------------------------------------------------ -N Quality notices by default are displayed in a verbose format. This option display a single line summary of the quality notice. -Ns Single line summary format -Nv Visual Studio and KAWA interactive format Quality notices output in Visual Studio format allows the user, inside Visual Studio environment, to double click on a quality notice and jump directly to the file and specified line number. For specific information on setting up RSM as an integrated tool to Visual Studio visit the RSM web site, http://mSquaredTechnologies.com i.e. rsm -f -o -c -Nv *.h *.cpp i.e. rsm -foc -Ns *.h *.cpp * Output Report to a file ------------------------------------------------------------------------ -O This mode routes the RSM report from the stdout or screen to a file. If the file cannot be opened, RSM will output the report to the screen. i.e. rsm -H -o -f -O rsm_report.htm *.cc *.cpp rsm -A -Ta -O rsm_report.csv -F project_files.txt * Object Class Metrics ------------------------------------------------------------------------ -o This mode details metrics for each class specification identified within the source code. Metrics include LOC, lines of code, eLOC, comments, blanks, the number of public, protected, private attributes and methods. If a class implements inheritance, it is shown with the respective base classes. i.e. rsm -of *.cc *.cpp Print Format, Code Listing Mode ------------------------------------------------------------------------ -p This mode generates a code listing for the files specified by name, wild card, file list or recursive mode. Files are created with a user specified header, file name, page number, file date and line numbers for each line of code. Line numbers correspond with the line numbers generated from other RSM modes. This output is suitable for publication and peer reviews. i.e. rsm -p *.cc *.c *.cpp rsm -p -F filelist.txt rsm -p -r cpp,h,hh ./ Page Formatting switches that apply to print code-listing mode. -B1 Top Margin, Default 0 -M10 Left Margin, Default 5 -P66 Page Length, Default 55 -L72 Line Length, Default 80 -S"string" Header String i.e.. rsm -p -B5 -M5 -P60 -L78 -H"My Code" .\src\*.c * Recursive Descent Mode ------------------------------------------------------------------------ -r Recursive descent mode will process all the specified files from a given point in the directory tree. A file spec must be specified as a list of file extensions separated by commas. The starting point must be a directory. i.e. rsm -r rsm -fac -r c,cpp ./proj rsm -f -a -c -r cc,c,h,hh .\mysrc rsm -v -RN -r h,c c:\srcs * Read File Processing Options ------------------------------------------------------------------------ -R RSM processes files from 1 of four modes. 1. Direct Files rsm -f -o /proj/src/file 2. Wild Cards rsm -f -o /proj/src/*.cpp 3. Recursive descent of a directory tree rsm -f -o -r h,cpp /proj/src 4. Reading from a list of files or directories rsm -f -o -F /proj/filelist.lst The following options modify the way RSM processes the files to be analyzed. -RL Generates a list of all files which will be processed in RSM operation. This list may be cut from the report to provide a project file inventory or used at a stating point for creating a file list to process. This option exits upon listing the files. -RN No sorting of the file names found by the file read mode. Normally, RSM sorts files alphabetically, but this option will process files in the order they were found in the directory tree. -Rd This mode turn off recursive decent for a directory. This option does not apply to the recursive flag in the file list. See the file list section for more information. i.e. rsm -RL -RN -r c,h,cc,hh . rsm -RN -r c,cpp .\proj rsm -Rd -r h,cpp "c:\Program Files\proj" * Summary Mode ------------------------------------------------------------------------ -s Summary mode summarizes the LOC, eLOC comments and blanks per file. This mode present the metrics in a summarized format. i.e. rsm -facmns *.c rsm *.c "default if no option specified" * Totals Only Mode ------------------------------------------------------------------------ -T This mode only displays project totals for all files processed. In this mode, other reporting data is suppressed. This mode makes it easy to determine grand totals for your project. This mode requires a modifier as specified below. You may use the -k option for sorting the report by different keys. -Ta All Totals, Functions, Classes, Interfaces, Namespaces Quality Notices and LOC Summary -Tf Total Functions -Ti Inheritance Tree Only -To Total Classes, Interfaces, Namespaces -Tq Total Quality Notice Summary List -Tp Total Quality Notice Profile -Tn Quality Notices by file and line number -Ts Total LOC Summary -TL Summaries Only, No Lists of functions, classes etc. -TN No Filename output for total report i.e. rsm -Ta -k3 *.c *.cpp rsm -Ta -TN -veW -r c,h c:\src rsm -Tn -TN -v -r c ./project User Log Mode ------------------------------------------------------------------------ -u Administration mode for the RSM User log. The user log is called rsm.log and is located in the rsm directory. -us Show User Log Network License Options -ua Archive the user log -ur Remove user from the user log i.e. rsm -us rsm -ua rsm -ur * Verbose Mode ------------------------------------------------------------------------ -v Verbose output shows many metrics for each file and a grand total for all files. This mode provides many different numbers which the user can interpret. i.e. rsm -foacmnv *.cpp *.c * Work Analysis Based on LOC Metric Differentials ------------------------------------------------------------------------ -w Work analysis is the capability to track LOC metrics on a specific code tree over time. This facility will create a differential metrics report using the -W or -x mode for processing the created work analysis files. The -w mode creates a work analysis file based on the files specified by the respective mode. This file is named based on the date, for example, rm.. This file is copied to a file called workfile.dat. The file workfile.dat is used as the last work analysis file for -W mode. i.e. rsm -w -r c,cc,h,hh /project1 Work Analysis from Last Work Analysis File ------------------------------------------------------------------------ -W This mode uses the last work analysis file (workfile.dat) and the current work analysis metrics based upon the specified files. The specified files must match the files specified which originally created the (workfile.dat) file. A work file differential analysis report will be generated. i.e. rsm -W -r c,cc,h,hh /project1 Work Analysis Extraction from Work Analysis Files ------------------------------------------------------------------------ -x This mode extracts the work analysis differential between two work analysis files. These work analysis files must be based on the same code tree. The reported metrics will show LOC information based upon the time differential between these two files. i.e. rsm -x rsm -x rm111019.97 rm111419.97 RSM Configuration Parameters ------------------------------------------------------------------------ -y This option shows the RSM configuration parameters. These settings can be made by specifying their values in the rsm.cfg file. The emitted format is compliant with the rsm.cfg syntax. You can easily create the rsm.cfg file by redirecting the output to a file called rsm.cfg. i.e. rsm -y > c:\rsm\rsm.cfg Remember the rsm.cfg and rsm.lic file must be found in a directory along the system path or at the location specified by the environment variable RSMHOME License Agreement ------------------------------------------------------------------------ -z Shows the software/source code license agreement which the user and company are bound to by using RSM. You may customize the notification boundaries by specifying the parameters in the rsm.cfg file. Use the -y option for creating a rsm.cfg file. Support, Sales and Licenses Please contact M Squared Technologies for all RSM licenses. All licenses turn on the wild card support and summations for all files and functions, yielding project metrics. RSM uses an encrypted license file to provide each user with a unique license tailored to each user's runtime requirements. RSM will look for the license file rsm.lic at the location specified by the environment variable RSMHOME. If the license file is not found at the RSMHOME location, RSM will search the system PATH for the rsm.lic file. If the license file cannot be located, RSM will warn the users and default to the SHAREWARE mode. If the rsm.lic file detects that the file contents have been modified, RSM will default to the SHAREWARE mode. Hacking the RSM license file will void the end user license agreement. License : Site Multi-Network License - 10000 Users Licensed To : M Squared Technologies License No. : ST1000 License Date: 06/25/1999 Maintenance : 06/25/2001 Compile Date: Oct 10 2000 Paid Licenses include the latest revision, pre-compiled for Window 9x/NT or UNIX. Single user or Network licenses available. UNIX licenses include unmodifiable source code for compiling on your exact machine and UNIX operating system. The source is compilable on any ANSI UNIX C compiler. If the information you desire is not located in this help listing, please refer to the on-line manual and/or the frequently asked questions FAQ on our website. Resource Standard Metrics and Visual Metrics are Trademarks belonging to M Squared Technologies. (C) 1995-2000 M Squared Technologies All rights reserved Email - sales@mSquaredTechnologies.com Web Site - http://mSquaredTechnologies.com