sarnold / cccc

Source code counter and metrics tool for C++, C, and Java
https://sarnold.github.io/cccc/
Other
60 stars 17 forks source link

Per function metrics in detailed report shown as infinity #13

Closed p2k-ko closed 7 years ago

p2k-ko commented 7 years ago

The per function metrics in the detailed report of a module are shown as infinity.

cccc_htm_patch_01

This is due to the initialization of nof to zero in the cccc_html.cc file.

--- old/cccc_htm.cc 2017-04-03 09:16:56.993686941 +0200
+++ new/cccc_htm.cc 2017-04-03 09:56:09.030666528 +0200
@@ -1221,7 +1221,6 @@
 {
   // calculate the counts on which all displayed data will be based
   // int nof=module_ptr->member_table.records(); // Number of functions
-  int nof=0;
   int loc=module_ptr->get_count("LOC");  // lines of code
   int mvg=module_ptr->get_count("MVG");  // McCabes cyclomatic complexity
   int com=module_ptr->get_count("COM");  // lines of comment
@@ -1237,6 +1236,10 @@
   int noc=module_ptr->get_count("NOC");   // number of children
   int cbo=module_ptr->get_count("CBO");   // coupling between objects

+  // To calculate the per function metrics in the detailed report the
+  // number of functions is set to the weighted methods 
+  int nof=wmc1;
+
   fstr << "<TABLE BORDER WIDTH=100%>" << endl
        << "<TR>" << endl;
   Put_Header_Cell("Metric",70);

After applying the patch the values per function are calculated as expected:

cccc_htm_patch_02

sarnold commented 7 years ago

PR merged into master, closing.