Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
314 changes: 187 additions & 127 deletions analysis.json

Large diffs are not rendered by default.

220 changes: 113 additions & 107 deletions build/analysis.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ var fs = require('fs'),


var paths = {
testsJson: path.join(__dirname, '../tests.json'),
analysisJson: path.join(__dirname, '../analysis.json')
testsJson: path.join(__dirname, '../tests.json'),
analysisJson: path.join(__dirname, '../analysis.json')
};

var testsFile = fs.readFileSync(paths.testsJson).toString();
Expand All @@ -14,124 +14,130 @@ var tests = JSON.parse(testsFile);
var testList = _.flatten(_.map(_.values(tests), x => _.keys(x)));

var resultTypes = [
'notfound',
'error',
'error_paid',
'warning',
'manual',
'identified'
'notfound',
'error',
'error_paid',
'warning',
'manual',
'identified'
];

var toolNames = [
'google',
'tenon',
'wave',
'codesniffer',
'axe',
'asqatasun',
'sortsite',
'eiii',
'achecker',
'nu',
'siteimprove',
'fae',
'aslint'
'google',
'tenon',
'wave',
'codesniffer',
'axe',
'asqatasun',
'sortsite',
'eiii',
'achecker',
'nu',
'siteimprove',
'fae',
'aslint',
'enabler',
'arc'

];

var analysis = {};

function analyse(){
var tool = {};
var test = {};
var detectable = [];
var percent = {};

// Priming the tools array
tool = _.reduce(toolNames, function (a, b){
a[b] = _.reduce(resultTypes, (c, d) => { c[d] = 0; return c; }, {});
return a;
}, {});

for( catname in tests ){
for( testname in tests[catname] ){
var resObj = tests[catname][testname]["results"];

for( toolName in resObj ){
tool[toolName][resObj[toolName]]++;
}

// Test is detectable by at least one tool
var canDetect = _.without(
_.values(resObj),
'notfound',
'identified'
);

if( canDetect.length > 0 ){
detectable.push(testname);
}
}
}

analysis.counts = tool;

analysis.totals = {
total: testList.length,
detectable: detectable.length,
undetectable: testList.length - detectable.length
}

analysis.percentages = {
detectable: _.round(analysis.totals.detectable / analysis.totals.total * 100),
tools: {}
}

for( tool in analysis.counts ){
var t = analysis.counts[tool];

analysis.percentages.tools[tool] = {
detectable: {
"error_warning": _.round((t.error + t.error_paid + t.warning) / analysis.totals.detectable * 100),
"error_warning_manual": _.round((t.error + t.error_paid + t.warning + t.manual) / analysis.totals.detectable * 100)
},
total: {
"error_warning": _.round((t.error + t.error_paid + t.warning) / analysis.totals.total * 100),
"error_warning_manual": _.round((t.error + t.error_paid + t.warning + t.manual) / analysis.totals.total * 100)
}
function analyse() {
var tool = {};
var test = {};
var detectable = [];
var percent = {};

// Priming the tools array
tool = _.reduce(toolNames, function (a, b) {
a[b] = _.reduce(resultTypes, (c, d) => {
c[d] = 0;
return c;
}, {});
return a;
}, {});

for (catname in tests) {
for (testname in tests[catname]) {
var resObj = tests[catname][testname]["results"];

for (toolName in resObj) {
tool[toolName][resObj[toolName]]++;
}

// Test is detectable by at least one tool
var canDetect = _.without(
_.values(resObj),
'notfound',
'identified'
);

if (canDetect.length > 0) {
detectable.push(testname);
}
}
}
}

// [ [ 'google', 17 ], [ 'tenon', 37 ], ... ]
var tr = _.map(_.get(analysis, 'percentages.tools'), (x,y) => [y, x.total.error_warning, x.total.error_warning_manual] );
tr = tr.sort( (a, b) => b[1] - a[1] );
tr_ew = tr.map(function (val, index){
return {
position: index + 1,
name: val[0],
error_warning: val[1],
error_warning_manual: val[2],

analysis.counts = tool;

analysis.totals = {
total: testList.length,
detectable: detectable.length,
undetectable: testList.length - detectable.length
}
});

tr = tr.sort( (a, b) => b[2] - a[2] );
tr_ewm = tr.map(function (val, index){
return {
position: index + 1,
name: val[0],
error_warning: val[1],
error_warning_manual: val[2],

analysis.percentages = {
detectable: _.round(analysis.totals.detectable / analysis.totals.total * 100),
tools: {}
}
});

analysis.scoreboard = {};
analysis.scoreboard.by_error_warning = tr_ew;
analysis.scoreboard.by_error_warning_manual = tr_ewm;
for (tool in analysis.counts) {
var t = analysis.counts[tool];

analysis.percentages.tools[tool] = {
detectable: {
"error_warning": _.round((t.error + t.error_paid + t.warning) / analysis.totals.detectable * 100),
"error_warning_manual": _.round((t.error + t.error_paid + t.warning + t.manual) / analysis.totals.detectable * 100)
},
total: {
"error_warning": _.round((t.error + t.error_paid + t.warning) / analysis.totals.total * 100),
"error_warning_manual": _.round((t.error + t.error_paid + t.warning + t.manual) / analysis.totals.total * 100)
}
}
}

fs.writeFileSync(paths.analysisJson, JSON.stringify(analysis,'',2), 'utf8');
// [ [ 'google', 17 ], [ 'tenon', 37 ], ... ]
var tr = _.map(_.get(analysis, 'percentages.tools'), (x, y) => [y, x.total.error_warning, x.total.error_warning_manual]);
tr = tr.sort((a, b) => b[1] - a[1]);
tr_ew = tr.map(function (val, index) {
return {
position: index + 1,
name: val[0],
error_warning: val[1],
error_warning_manual: val[2],
}
});

tr = tr.sort((a, b) => b[2] - a[2]);
tr_ewm = tr.map(function (val, index) {
return {
position: index + 1,
name: val[0],
error_warning: val[1],
error_warning_manual: val[2],
}
});

analysis.scoreboard = {};
analysis.scoreboard.by_error_warning = tr_ew;
analysis.scoreboard.by_error_warning_manual = tr_ewm;

fs.writeFileSync(paths.analysisJson, JSON.stringify(analysis, '', 2), 'utf8');
}

module.exports = {
analyse: analyse,
resultTypes: resultTypes,
toolNames: toolNames
analyse: analyse,
resultTypes: resultTypes,
toolNames: toolNames
}
Loading