About SW-Quality Safety SW-Entwicklung UML Nachschlagen Programme
Q-Kriterien
Basics
Prozess
CodingRules
SourceCode Metriken
ISO9000 und SW
Grundlagen Metrik Beispiel RSM Beschreibung RSM Beispiel
SourceCode Metrik RSM
Ein Tool um Metriken über SourceCode anzufertigen ist das Tool RSM, welches hier kurz beschrieben werden soll. Ein kostenloses Demo für bis zu 10 Sourcecode-Dateien ist beim Hersteller verfügbar. 

Source Code auf Auffälligkeiten überprüfen 

  1. RSM 6.03 downloaden, in Verzeichnis kopieren (bei mir c:\prg\rsm)
  2. Eine Batch Datei (z.B. startRSMDetect.bat) mit Inhalt:

  3.   set RSMPATH=c:\prg\rsm\rsm.exe
      del %1.csv
      RSMPATH% -c -n -O %1.c %1 
      %RSMPATH% -Dd %1.c
      copy %1.c %1.txt
      del %1.c
      start %1.txt
    anlegen (Pfad anpassen).
  4. Die C, C++ oder JAVA SourceCode Datei in den RSM Ordner kopieren.
  5. Die SourceCode Datei im Explorer auf die BatchDatei schieben (die Batchdatei mit der SourceCode Datei starten).
  6. RSM läuft und erzeugt eine Textdatei.
  7. Die Textdatei wird automatisch geöffnet. Sie enthält alle gefundenen Auffälligkeiten. Ganz am Ende der Datei steht eine Zusammenfassung: Welche Auffälligkeit wie häufig aufgetreten ist. 
Resource Standard Metrics for C, C++ and Java von Squared Technologies.
 
 

RSM für Source Code Metriken
 

  1. RSM 6.03 downloaden, in Verzeichnis kopieren (bei mir c:\prg\rsm)
  2. Eine Batch Datei (z.B. startRSM.bat) mit Inhalt:
      set RSMPATH=c:\prg\rsm\rsm.exe
      del %1.csv
      %RSMPATH% -A -Ta -O %1.csv %1 
      start %1.csv
    anlegen (Pfad anpassen).
  3. Die C, C++ oder JAVA SourceCode Datei in den RSM Ordner kopieren.
  4. Die SourceCode Datei im Explorer auf die BatchDatei schieben (die Batchdatei mit der SourceCode Datei starten).
  5. RSM läuft und erzeugt eine CSV.
  6. Die CSV wird automatisch mit Excel geöffnet (falls installiert). 
Leider erfolgt die Auswertung bzw. Umwandlung in eine Grafik nicht automatisch. 
 

 

Beispieldatei einer von RSM erstellten Zusammenfassung (Metrik+Auffälligkeiten):
 ~~ Project Functional Analysis ~~

  Total Functions .......:       1640
  Total Physical Lines ..:     120886  Total LOC .............:      94579
  Total eLOC ............:      76700  Total lLOC ............:      46527
  Total Cyclomatic Comp. :      15339  Total Interface Comp. .:       8821
  Total Parameters ......:       3553  Total Return Points ...:       5268
  Total Comment Lines ...:      17954  Total Blank Lines .....:      16084
         ------     -----     -----     ------     ------     ----- 
  Avg Physical Lines ....:      73.71
  Avg LOC ...............:      57.67  Avg eLOC ..............:      46.77
  Avg lLOC ..............:      28.37  Avg Cyclomatic Comp. ..:       9.35
  Avg Interface Comp. ...:       5.38  Avg Parameters ........:       2.17
  Avg Return Points .....:       3.21  Avg Comment Lines .....:      10.95
         ------     -----     -----     ------     ------     ----- 
  Max LOC ...............:       2247
  Max eLOC ..............:       1951  Max lLOC ..............:        922
  Max Cyclomatic Comp. ..:        499  Max Interface Comp. ...:         73
  Max Parameters ........:         25  Max Return Points .....:         72
  Max Comment Lines .....:        875  Max Total Lines .......:       3160
         ------     -----     -----     ------     ------     ----- 
  Min LOC ...............:          2
  Min eLOC ..............:          0  Min lLOC ..............:          0
  Min Cyclomatic Comp. ..:          1  Min Interface Comp. ...:          1
  Min Parameters ........:          0  Min Return Points .....:          1
  Min Comment Lines .....:          0  Min Total Lines .......:          3

  ------------------------------------------------------------------------

                        ~~ Project Quality Profile ~~

  Type  Count Percent  Quality Notice
  ________________________________________________________________________

  1       910    2.73  Physical line length exceeds 120 characters
  2         4    0.01  Function name length exceeds 32 characters
  3        31    0.09  Ellipsis '...' are identified as function parameters
  4     28526   85.45  Assignment '=' within 'if' statement
  5        94    0.28  Assignment '=' within 'while' statement
  6        63    0.19  Pre-decrement operator '--' identified
  7        87    0.26  Pre-increment operator '++' identified
  8        94    0.28  'realloc' function identified
  9       190    0.57  'goto' keyword identified
  10      177    0.53  Non-ANSI function prototype identified
  13       49    0.15  'switch' statement does not have a 'default'
  14       22    0.07  'case' conditions do not equal 'break'
  16       20    0.06  Function white space less than 10.0%
  17      654    1.96  Function comment content less than 10.0%
  18       74    0.22  Function eLOC exceeds maximum 150 eLOC
  23      269    0.81  '?' ternary operator identified
  24       80    0.24  ANSI C++ keyword identified within C file
  26      202    0.61  void * generic type identified
  27      358    1.07  Number of function return points exceed 3
  28      339    1.02  Cyclomatic complexity exceeds 10
  29       59    0.18  Number of function parameters exceed 6
  43      361    1.08  Keyword 'continue' has been identified
  44      720    2.16  Keyword 'break' identified outside a 'switch' structure

 

 
©; created Mon Aug 07 22:31:53 CEST 2006; eMail