-
Notifications
You must be signed in to change notification settings - Fork 0
/
metricsUI.js
67 lines (62 loc) · 3.67 KB
/
metricsUI.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
function displayMetrics(tabledata, customFormatter){
var table = new Tabulator("#res-table", {
//height:"311px",
layout:"fitDataFill",
data:tabledata, //load data into table
//responsiveLayout:true,
columns:[
{title:"Project Name", field:"projectName", sorter:"number", titleFormatter:"textarea", variableHeight:true},
{title:"Avg. McCabe\nCyclomatic\nComplexity(CC)", field:"cc", sorter:"number", titleFormatter:"textarea", variableHeight:true},
{title:"Source Lines\nof Code\n(SLOC)", field:"sloc", sorter:"number", titleFormatter:"textarea"},
{title:"Comment\nPercentage\n(CP)", field:"cp", sorter:"number", titleFormatter:"textarea"},
{title:"Attribute\nHiding Factor\n(AHF)", field:"ahf", sorter:"number", titleFormatter:"textarea"},
{title:"Method\nHiding Factor\n(MHF)", field:"mhf", sorter:"number", titleFormatter:"textarea"},
{title:"Avg. Weighted\nMethod per Class\n(WMC)", field:"wmc", sorter:"number", titleFormatter:"textarea"},
{title:"Avg. Depth of\nInheritance Tree\n(DIT)", field:"dit", sorter:"number", titleFormatter:"textarea"},
{title:"Avg. Number of\nchildren\n(NOC)", field:"noc", sorter:"number", titleFormatter:"textarea"},
{title:"Total Access To\nForeign Data\n(ATFD)", field:"atfd", sorter:"number", titleFormatter:"textarea"},
{title:"Total Tight Class\nCohesion\n(TCC)", field:"tcc", sorter:"number", titleFormatter:"textarea"},
// {title:"Success", field:"hasPredicted", formatter:"tickCross", align:"center", width:100}
]
});
}
function displayGodClasses(tabledata, id){
var table = new Tabulator("#"+id, {
layout:"fitColumns",
data:tabledata, //load data into table
responsiveLayout:true,
columns:[
{title:"Class Name", field:"className", sorter:"string", titleFormatter:"textarea", variableHeight:true},
{title:"Avg. Weighted Method per Class (WMC)", field:"wmc", sorter:"number", titleFormatter:"textarea"},
{title:"WMC >= 47", field:"wmcGte47", sorter:"string", titleFormatter:"textarea", formatter: 'tickCross'},
{title:"Access To Foreign Data\n(ATFD)", field:"atfd", sorter:"number", titleFormatter:"textarea"},
{title:"ATFD > 5", field:"atfdGt5", sorter:"string", titleFormatter:"textarea", formatter: 'tickCross'},
{title:"Tight Class Cohesion\n(TCC)", field:"tcc", sorter:"number", titleFormatter:"textarea"},
{title:"TCC < 33%", field:"tccLt33", sorter:"string", titleFormatter:"textarea", formatter: 'tickCross'},
{title:"Is God Class", field:"isGodClass", sorter:"string", titleFormatter:"textarea", formatter: 'tickCross'},
// {title:"Success", field:"hasPredicted", formatter:"tickCross", align:"center", width:100}
]
});
}
ipcRenderer.on('project-metrics', (event, res) => {
var customFormatter = function(cell, formatterParams, onRendered){
cell.getElement().css({"background-color":"#A6A6DF"});
}
console.log(res);
displayMetrics(res, customFormatter);
// currentProject = {projectName: res.projectName, dartFiles: res.dartFiles}
// $("#main-section").html(getMetricButtons(true)+ getHTMLforOnePrj(res.isFlutterProject, res.dartFiles, res.projectName));
});
ipcRenderer.on('smell-detected', (event, res) => {
$('smell-table').html('');
for (let index = 0; index < res.length; index++) {
const finalRes = res[index].finalResult;
const projectName = res[index].projectName;
const id = "sml" + (index+1);
$('#smell-table').append("<h5 class='badge badge-primary mt-5'>" + projectName+ "</h5><div id='"+ id + "'></div>");
//setTimeout(() => {
displayGodClasses(finalRes, id);
//}, 1000);
}
//$('smell-table').append
});