Skip to content

Commit

Permalink
[build] Add specific template for ccccc.
Browse files Browse the repository at this point in the history
similar to regular html template, but with (hard-coded) link for source file, and with "non-local" scripts.
  • Loading branch information
Jarod42 committed May 24, 2024
1 parent 8253b3c commit 6ab636b
Show file tree
Hide file tree
Showing 4 changed files with 137 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ jobs:
run: |
echo "require 'premake-export-compile-commands/export-compile-commands'" >> premake-system.lua
./premake5 --llvm-root="${{steps.LLVM.outputs.LLVM_ROOT}}" --expand-llvm-config --no-3rd export-compile-commands
./bin/gmake2/Release/ccccc project/export-compile-commands/release/compile_commands.json > index.html
./bin/gmake2/Release/ccccc --template-file=template/ccccc_html/template.tpl project/export-compile-commands/release/compile_commands.json > index.html
- name: Upload index.html
uses: actions/upload-artifact@v4
Expand Down
20 changes: 20 additions & 0 deletions template/ccccc_html/ccccc.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
em {padding: 2px; background-color: #6cf; color: #FFF;}

table {
width:100%;
border: 1px solid;
}

table td, table th {
// width: 30px;
// padding: 1px;
border: #000 1px solid;
}

th { background:aqua}

table.tablesorter tbody td.bad { background: red; font-weight:bold;}
table.tablesorter tbody td.warning { background: yellow; font-weight:bold;}

span.bad {background: red; font-weight:bold; }
span.warning {background: yellow; font-weight:bold; }
46 changes: 46 additions & 0 deletions template/ccccc_html/ccccc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
function setClassToSpecificColumnBadForLowValue(classid, low, high) {
var colNumber = -1;
$.each($('th.' + classid),function(idx,_val) {
var table = $(this).parent().parent();
colNumber = 1 + $(this).parent("tr").children().index($(this));
});
$('table tr').each(function() {
var tr = $(this)
var td = tr.find("td:nth-child(" + colNumber + ")")
var val = parseInt( td.text(), 10 );
if (val <= low) { td.addClass('bad'); }
else if (val <= high) { td.addClass('warning'); }
});
}

function setClassToSpecificColumnBadForHighValue(classid, low, high) {
var colNumber = -1;
$.each($('th.' + classid),function(idx,_val) {
var table = $(this).parent().parent();
colNumber = 1 + $(this).parent("tr").children().index($(this));
});
$('table tr').each(function() {
var tr = $(this)
var td = tr.find("td:nth-child(" + colNumber + ")")
var val = parseInt( td.text(), 10 );
if (val >= high) { td.addClass('bad'); }
else if (val >= low) { td.addClass('warning'); }
});
}

function setClassToColumn() {
setClassToSpecificColumnBadForHighValue('MVG', 10, 30);
setClassToSpecificColumnBadForHighValue('LOCpro', 25, 50);
setClassToSpecificColumnBadForHighValue('NestedBlockCount', 4, 5);
setClassToSpecificColumnBadForHighValue('Halstead_V', 1000, 1200);
setClassToSpecificColumnBadForLowValue('Halstead_V', 10, 15);
setClassToSpecificColumnBadForHighValue('Halstead_B', 1, 2);
setClassToSpecificColumnBadForLowValue('MI', 65, 85);
setClassToSpecificColumnBadForLowValue('CallerCount', -1, 0);
}

function onDocLoaded() {
setClassToColumn()
$("table#myTable").tablesorter({theme : 'blue', widgets: [ "resizable" ], widgetOptions : {} });
}

70 changes: 70 additions & 0 deletions template/ccccc_html/template.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>CCCCCC report</title>
<link rel="stylesheet" href="__jquery.tablesorter/themes/blue/style.css" type="text/css" media="print, projection, screen" />
<link rel="stylesheet" type="text/css" href="ccccc.css" media="all" />
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="__jquery.tablesorter/jquery.tablesorter.js"></script>
<script type="text/javascript" src="jquery.tablesorter.widgets.js"></script>
<script type="text/javascript" src="dragtable.js"></script>
<script type="text/javascript" src="ccccc.js"></script>
</head>
<body onload="onDocLoaded();">
<h1>CCCCC Software Metrics Report</h1>
<h2>Report.</h2>
<em>TIP!</em> Sort multiple columns simultaneously by holding down the shift key and clicking a second, third or even fourth column header!
<table width="100%" id="myTable" class="tablesorter draggable">
<thead>
<tr><th>Filename</th><th>line</th><th>Namespaces Name</th><th>Classes Name</th><th>Prototype</th><th class="LOCphy">LOCphy</th><th class="LOCpro">LOCpro</th><th class="LOCcom">LOCcom</th><th class="LOCbl">LOCbl</th><th class="MVG">MVG</th><th class="NestedBlockCount">Block</th><th class="Halstead_n">Vocabulary size</th><th class="Halstead_N">Program length</th><th class="Halstead_V">Volume</th><th class="Halstead_D">Difficulty</th><th class="Halstead_E">Effort</th><th class="Halstead_T">Time to implement (s)</th><th class="Halstead_B">Delivered bugs</th><th class="MIwoc">MIwoc</th><th class="MIcw">MIcw</th><th class="MI">MI</th><th class="CallCount">CallCount</th><th class="CallerCount">CallerCount</th></tr>
</thead>
<tbody>
{{#ForEachFiles}}{{#ForEachFunctions}}<tr><td><a href="https://github.com/Jarod42/ccccc/blob/master/{{filename}}#L{{lineDefinition}}">{{filename}}</a></td><td>{{lineDefinition}}</td><td>{{namespacesName}}</td><td>{{classesName}}</td><td>{{#explicit}}[explicit] {{/explicit}}{{#static}}[static] {{/static}}{{#virtual}}[virtual] {{/virtual}}{{funcName}}{{#const}} const{{/const}}{{#override}} [override]{{/override}}</td><td>{{LOCphy}}</td><td>{{LOCpro}}</td><td>{{LOCcom}}</td><td>{{LOCbl}}</td><td>{{MVG}}</td><td>{{NestedBlockCount}}</td><td>{{Halstead_n}}</td><td>{{Halstead_N}}</td><td>{{Halstead_V}}</td><td>{{Halstead_D}}</td><td>{{Halstead_E}}</td><td>{{Halstead_T}}</td><td>{{Halstead_B}}</td><td>{{MIwoc}}</td><td>{{MIcw}}</td><td>{{MI}}</td><td>{{CallCount}}</td><td>{{CallerCount}}</td></tr>
{{/ForEachFunctions}}{{/ForEachFiles}}</tbody>
</table>
<h2>Definitions.</h2>
<ul>
<li><b>LOCphy</b> = Number of physical lines<br/>It includes blank line and line with code or comment.</li>
<li><b>LOCpro</b> = Number of lines with code<br/>Number of lines of with source code. (Line may also have comment)<br/>
<span class="warning">high value from 25</span>. <span class="bad">Very high value from 50</span>.
</li>
<li><b>LOCcom</b> = Lines of Comments<br/>Number of lines of comment identified. (Line may also have code)</li>
<li><b>LOCbl</b> = Number of blank-lines.</li>
<li><b>MVG</b> = <a href="http://en.wikipedia.org/wiki/Cyclomatic_complexity">McCabe's Cyclomatic Complexity</a><br/>
Number of linearly independent paths through a program's source code.<br/> It is nearly equivalent to the number of branches.<br/>
<span class="warning">high value from 10</span>. <span class="bad">Very high value from 30</span>.
</li>
<li><b>Block</b> = Max Nested Block Count.<span class="warning">high value from 4</span>. <span class="bad">Very high value from 5</span>.</li>
<li><a href="http://en.wikipedia.org/wiki/Halstead_complexity_measures">Halstead metrics</a>:
<ul>
<li><b>Vocabulary size</b> = Number of distinct 'tokens'.</li>
<li><b>Program length</b> = Number of 'tokens'.</li>
<li><b>Volume</b> = Information contents of the function, measured in mathematical bits.
<span class="warning">low value from 15</span>. <span class="bad">Very low value from 10</span>.
<span class="warning">high value from 1000</span>. <span class="bad">Very high value from 1200</span>.
</li>
<li><b>Difficulty</b> = Error proneness of the program.</li>
<li><b>Effort</b> = The effort to implement or understand a function.</li>
<li><b>Time to implement</b> (in seconds) = Approximation time to implement or understand a function.</li>
<li><b>Delivered bugs</b> = Estimate for the number of errors in the implementation.</li>
</ul></li>
<li><a href="http://www.verifysoft.com/en_maintainability.html">Maintainability Index</a>:
Computed from line count, mvg and halstead metrics.
<ul>
<li><b>MIwoc</b> = maintainability index without comments.</li>
<li><b>MIcw</b> = maintainability index comment weight.</li>
<li><b>MI</b> = maintainability index (MIwoc + MIcw).
<span class="warning">low value from 85</span>. <span class="bad">Very low value from 65</span>.
</li>
</ul></li>
</ul>
<ul>
<li><b>CallCount</b> = The number of functions called by this function.</li>
<li><b>CallerCount</b> = The number of times this function is called.
<span class="warning">low value from 0 (unused function)</span>.
</li>
<ul>
<br/>
<span class="footer">File generated {{Date}} by <a href="https://github.com/Jarod42/ccccc">ccccc</a>.</span>
</body>
</html>

0 comments on commit 6ab636b

Please sign in to comment.