[comp.lang.pascal] Program style assessment

rdempste@Daisy.EE.UND.AC.ZA (Rob Dempster) (06/27/91)

	I am about to teach a Pascal course to a large group of students and
would like to use software to partially evaluate the practical work done by
the students. Does anyone know of public-domain or shareware which will assist
me in this task. The software should typically monitor the programmers use of
indentation, variable names of a reasonable length, comments and the like.
Access to the source code of the software would be advantageous.

davidr@hplsla.HP.COM (David M. Reed) (06/29/91)

I have a couple of such programs on my HP-UX system (one for checking C code,
and one for checking Pascal).  Unfortunately I do not have, nor do I know
where exists, the source code; so the version I have only runs on an HP
9000/300.  

From the "readme" document:

    HP Labs - Software Engineering Laboratory

    Pascal Style and Metric Analyzer - Version A.00.02


Description:

        The input is one or more syntactically correct Pascal
module or program. PMETRIC outputs the results of the style
analysis and HP metric statistics to the terminal.


Background:

        PMETRIC is a program modeled after a paper by Michael J.
Rees, Automatic assessment aids for Pascal programs, SIGPLAN
Notices 17(10), October 1982.

Interpreting results:

        PMETRIC returns two sets of information.

        (A) HP metric statistics - this is the information the
            Corporate Metric Council is collecting on software
            projects in HP.

            1) Compiler directives
            2) Non-commented source
            3) Whole comment lines
            4) Number of blank lines
            5) Total number of lines

            in addition to the metrics requested by the CMC:

            6) Number of modules
            7) Number of identifiers
            8) Part and Whole comment lines

        (B) Pascal style analysis - makes 9 measurements on the
            Pascal source and returns a style rating based on a
            weighting table customizable by the user.

            The 9 measures are:

            1) Average number of characters per line
            2) Percent comment lines
            3) Percent indentation
            4) Percent blank lines
            5) Percent spaces in line
            6) Average module length
            7) Number reserved words used
            8) Average identifier length
            9) Number of gotos  (note! negative score on this one)

            For each measurement the following is displayed:

                Mark     - raw measurement
                Delta    - improvement to achieve a maximum score
                           ( + need to add, - need to reduce)
                Measures - describes the measurement taken
                Score    - weighted score
                Max      - maximum weighted score for this measurement

                Total Score - sum of all weighted scores (max = 100)

Sample:


           Compiler directives            53
           Non-commented source         1301
           Whole comment lines           785
           Number of blank lines         140
                                      ------
           Total number of lines        2279

           Number of modules              56
           Number of identifiers         499
           Part & Whole comment lines    926

           marks     delta          measures                  score     Max

            27.6    -  2.6   Average # characters per line  :  7.3      15.0
            24.6    - 15.6   Percent comment lines          :  6.4      10.0
            47.5    +  0.0   Percent indentation            : 12.0      12.0
             6.1    +  8.9   Percent blank lines            :  0.0       5.0
             9.4    +  5.6   Percent spaces in line         :  0.0       8.0
            23.2    +  0.0   Average module length          : 20.0      20.0
            55.0    +  0.0   Number reserved words used     : 10.0      10.0
             8.3    +  0.7   Average identifier length      : 12.7      20.0
             0.0    +  3.0   Number labels & gotos          :  0.0     -20.0
                                                            ------
                                                 Total Score  67.5

Customization:

        PMETRIC files:

        pmetric         - executable binary program
        pmetric.dict    - reserve word list (must be sorted)
        pmetric.wght    - weight table for the 9 measurements


        pmetric.dict :

        You can add or delete reserve words from the dictionary but
        remember to keep it sorted. PMETRIC will look for in the
        current directory for pmetric.dict before it will look in
        /usr/contrib/lib/pmetric.dict.

etc....