Skip to content

Commit

Permalink
Merge pull request #538 from eclipse/deps-view
Browse files Browse the repository at this point in the history
New "Bloat" tab in frontend-apps
  • Loading branch information
serenaponta authored Mar 31, 2022
2 parents aa8d212 + f4e0e95 commit dbee174
Show file tree
Hide file tree
Showing 5 changed files with 292 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ masterCreateSpaceTooltip=Create workspace


Archives=Dependencies
Bloat=Bloat
patchAnalysis=Vulnerabilities
mavenVerified=Maven-verified archive
testCoverageTitle=Testcoverage for
Expand Down
6 changes: 6 additions & 0 deletions frontend-apps/src/main/webapp/model/Formatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,12 @@ model.Formatter = {
return a;
},

debloat: function(reach,traced,exec){
if( reach==0 && traced==0 && exec>0)
return true;
else return false;
},

parentDepth : function(parent) {
let a=0;
if(parent){
Expand Down
155 changes: 143 additions & 12 deletions frontend-apps/src/main/webapp/view/Component.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,117 @@ sap.ui.controller("view.Component", {
return emptyModel;
},

computeDebloatViewMetrics : function(_test){
var archiveInScope = this.getView().byId("archiveInScope");
var archiveDebloat = this.getView().byId("archiveDebloat");
var archiveTraced = this.getView().byId("archiveTraced");
var archiveReachable = this.getView().byId("archiveReachable");
var archiveTotalTraces = this.getView().byId("archiveTotalTraces");

var archivesInTable = this.getView().byId("idBloatList").getModel().getObject("/");
var archives = 0;
var traced = 0;
var reachable = 0;
var traces = 0;
var debloatable = 0;
for (var a=0;a<archivesInTable.length;a++){
if(_test || archivesInTable[a].scope!="TEST"){
archives++;
if(archivesInTable[a].tracedExecConstructsCounter>0){
traced++;
traces = traces + archivesInTable[a].tracedExecConstructsCounter;
}
if(archivesInTable[a].reachExecConstructsCounter>0){
reachable++;
}
if(archivesInTable[a].tracedExecConstructsCounter==0 && archivesInTable[a].reachExecConstructsCounter==0 && archivesInTable[a].lib.constructTypeCounters.countExecutable>0){
debloatable++;
}
}
}

archiveInScope.setText("Archives in selected scopes: " + archives);
archiveDebloat.setText("Debloatable archives: " + debloatable);
archiveTraced.setText("Archives Traced: " + traced);
archiveReachable.setText("Archives Reachable: " + reachable);
archiveTotalTraces.setText("Total Number of Traces: " + traces);

},

// includeTestDeps: function(){
// if(this.getView().byId("showDebloat").getSelected()==true){
// this.showDebloatableArchives();
// }
// else{
// var scopeColumn = this.getView().byId("scopeColumn");
// var oBloatView = this.getView().byId("idBloatList");
// if(scopeColumn.getFiltered()==true){
// scopeColumn.setFilterValue("");
// scopeColumn.setFiltered(false);
// oBloatView.filter(scopeColumn,"")
// this.computeDebloatViewMetrics(true);
// }
// else{
// scopeColumn.setFilterValue("!=TEST");
// scopeColumn.setFiltered(true);
// oBloatView.filter(scopeColumn,"!=TEST")
// this.computeDebloatViewMetrics(false);
// }
// }
// },

showDebloatableArchives: function(){
var array=[];
var scopeColumn = this.getView().byId("scopeColumn");
if(this.getView().byId("showDebloat").getSelected()==true){
var filter1 = new sap.ui.model.Filter(
"reachExecConstructsCounter",
sap.ui.model.FilterOperator.EQ,
"0");
var filter2 = new sap.ui.model.Filter(
"tracedExecConstructsCounter",
sap.ui.model.FilterOperator.EQ,
"0");
var filter3 = new sap.ui.model.Filter(
"lib/constructTypeCounters/countExecutable",
sap.ui.model.FilterOperator.NE,
"0");

array.push(filter1);
array.push(filter2);
array.push(filter3);
}
if(this.getView().byId("includeTest").getSelected()==false){
var filter4 = new sap.ui.model.Filter(
"scope",
sap.ui.model.FilterOperator.NE,
"TEST");
array.push(filter4);
scopeColumn.setFilterValue("!=TEST");
scopeColumn.setFiltered(true);
this.computeDebloatViewMetrics(false);
}
else if (this.getView().byId("includeTest").getSelected()==true){
scopeColumn.setFilterValue("");
scopeColumn.setFiltered(false);
this.computeDebloatViewMetrics(true);
}

if(array!=[]){
var tableFilter = new sap.ui.model.Filter({
filters: array,
and: true
});

this.getView().byId("idBloatList").getBinding("rows").filter(tableFilter);
}
else{
this.getView().byId("idBloatList").getBinding("rows").filter();
}
this.getView().byId("idBloatList").setVisibleRowCount(this.getView().byId("idBloatList").getBinding("rows").iLength);

},

// Vulnerabilities tab: Sets the 2 counters
setVulnDepCounters:function(_archives, _vulns) {
var archiveCount = this.getView().byId("archiveCount");
Expand Down Expand Up @@ -271,6 +382,10 @@ sap.ui.controller("view.Component", {
oArchiveView.setModel(this.getEmptyModel());
oArchiveView.setBusy(true);

var oBloatView = this.getView().byId("idBloatList");
oBloatView.setModel(this.getEmptyModel());
oBloatView.setBusy(true);

//var oConstructView = this.getView().byId("idPatchAnalysisList");
//oConstructView.setModel(emptyModel);
//oConstructView.setBusy(true);
Expand Down Expand Up @@ -321,14 +436,28 @@ sap.ui.controller("view.Component", {
}
sUrl = model.Config.getArchivesServiceUrl(groupId,artifactId,versionId, cache);


var archiveTotal = this.getView().byId("archiveTotal");
var archiveAvgAge = this.getView().byId("archiveAvgAge");

var archiveInScope = this.getView().byId("archiveInScope");
var archiveDebloat = this.getView().byId("archiveDebloat");
var archiveTraced = this.getView().byId("archiveTraced");
var archiveReachable = this.getView().byId("archiveReachable");
var archiveTotalTraces = this.getView().byId("archiveTotalTraces");
var archiveAvgAge = this.getView().byId("archiveAvgAge");

var scopeColumn = this.getView().byId("scopeColumn");

archiveTotal.setText("Archives Total: ");
archiveAvgAge.setText("Average age (in months): ");


archiveInScope.setText("Archives in selected scopes: ");
archiveDebloat.setText("Debloatable archives: ");
archiveTraced.setText("Archives Traced: ");
archiveReachable.setText("Archives Reachable: ");
archiveTotalTraces.setText("Total Number of Traces: ");
archiveAvgAge.setText("Average age (in months): ");


model.Config.addToQueue(oArchiveModel);
model.Config.loadData(oArchiveModel, sUrl, 'GET');
Expand All @@ -338,29 +467,30 @@ sap.ui.controller("view.Component", {
oArchiveView.setVisibleRowCount(oArchiveModel.getObject("/").length);
oArchiveView.setModel(oArchiveModel);
oArchiveView.setBusy(false);

oBloatView.setModel(oArchiveModel);
scopeColumn.setFilterValue("!=TEST");
scopeColumn.setFiltered(true);
oBloatView.filter(scopeColumn,"!=TEST")
oBloatView.setBusy(false);

var archives = oArchiveModel.getObject("/");
var traced = 0;
var traces = 0;
var days = 0, archives_with_timestamp = 0, now = Date.now();
for(var a=0;a<archives.length; a++){
if(archives[a].tracedExecConstructsCounter>0){
traced++;
traces = traces + archives[a].tracedExecConstructsCounter;
}

if(archives[a].lib.digestTimestamp!=null) {
archives_with_timestamp++;
var timestamp19 = archives[a].lib.digestTimestamp.substring(0,19);
var timestamp = Date.parse(timestamp19);
days += Math.floor(Math.abs(now-timestamp)/86400000);
}
}

archiveTotal.setText("Archives Total: " + archives.length);
archiveTraced.setText("Archives Traced: " + traced);
archiveTotalTraces.setText("Total Number of Traces: " + traces);
archiveAvgAge.setText("Average age (in months): " + (archives_with_timestamp==0 ? "n/a" : Math.floor(days/30/archives_with_timestamp)));
});

this.computeDebloatViewMetrics(false);

}.bind(this));
}

// Goal-Executions-Tab
Expand Down Expand Up @@ -696,6 +826,7 @@ sap.ui.controller("view.Component", {
// oEvent.getSource().removeSelections();
// },


onSearchButtonPress : function() {

// Search string
Expand Down
Loading

0 comments on commit dbee174

Please sign in to comment.