Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve LGTM errors #44

Open
wants to merge 2 commits into
base: gh-pages
Choose a base branch
from
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
40 changes: 19 additions & 21 deletions build/analysis.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
var fs = require('fs'),
let fs = require('fs'),
path = require('path'),
_ = require('lodash');


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

var testsFile = fs.readFileSync(paths.testsJson).toString();
var tests = JSON.parse(testsFile);
let testsFile = fs.readFileSync(paths.testsJson).toString();
let tests = JSON.parse(testsFile);
// linear list of all tests
var testList = _.flatten(_.map(_.values(tests), x => _.keys(x)));
let testList = _.flatten(_.map(_.values(tests), x => _.keys(x)));

var resultTypes = [
let resultTypes = [
'notfound',
'error',
'error_paid',
Expand All @@ -22,7 +22,7 @@ var resultTypes = [
'identified'
];

var toolNames = [
let toolNames = [
'google',
'tenon',
'wave',
Expand All @@ -38,30 +38,28 @@ var toolNames = [
'aslint'
];

var analysis = {};
let analysis = {};

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

// 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(let catname in tests ){
for(let testname in tests[catname] ){
let resObj = tests[catname][testname]["results"];

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

// Test is detectable by at least one tool
var canDetect = _.without(
let canDetect = _.without(
_.values(resObj),
'notfound',
'identified'
Expand All @@ -87,7 +85,7 @@ function analyse(){
}

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

analysis.percentages.tools[tool] = {
detectable: {
Expand All @@ -102,9 +100,9 @@ function analyse(){
}

// [ [ 'google', 17 ], [ 'tenon', 37 ], ... ]
var tr = _.map(_.get(analysis, 'percentages.tools'), (x,y) => [y, x.total.error_warning, x.total.error_warning_manual] );
let 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){
let tr_ew = tr.map(function (val, index){
return {
position: index + 1,
name: val[0],
Expand All @@ -114,7 +112,7 @@ function analyse(){
});

tr = tr.sort( (a, b) => b[2] - a[2] );
tr_ewm = tr.map(function (val, index){
let tr_ewm = tr.map(function (val, index){
return {
position: index + 1,
name: val[0],
Expand Down
38 changes: 19 additions & 19 deletions build/generate.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
var nunjucks = require('nunjucks'),
let nunjucks = require('nunjucks'),
fs = require('fs'),
path = require('path'),
analysis = require('./analysis');

var paths = {
let paths = {
testsJson: path.join(__dirname, '../tests.json'),
analysisJson: path.join(__dirname, '../analysis.json'),
changelogJson: path.join(__dirname, '../changelog.json'),
Expand All @@ -12,7 +12,7 @@ var paths = {
out: fname => path.join(paths.outPath, fname)
};

var resultsCopy = {
let resultsCopy = {
"error": "issue found",
"error_paid": "issue found (paid)",
"warning": "warning only",
Expand All @@ -21,7 +21,7 @@ var resultsCopy = {
"manual": "user to check"
};

var toolNamesCopy = {
let toolNamesCopy = {
"tenon": "Tenon",
"achecker": "AChecker",
"axe": "aXe",
Expand All @@ -37,7 +37,7 @@ var toolNamesCopy = {
"aslint": "ASLint"
}

var tools = {
let tools = {
"tenon": {
name: toolNamesCopy["tenon"],
url: "https://tenon.io/"
Expand Down Expand Up @@ -93,7 +93,7 @@ var tools = {
}

function getFilename( catname, testname ){
var filename = [catname.toLowerCase(), testname.toLowerCase()]
let filename = [catname.toLowerCase(), testname.toLowerCase()]
.join('-')
.replace(/[^a-z0-9\-\ ]/, '')
.replace('/', ' ')
Expand All @@ -117,19 +117,19 @@ function processExample( example ){
}

function generateFiles(){
var testsFile = fs.readFileSync(paths.testsJson).toString();
var tests = JSON.parse(testsFile);
let testsFile = fs.readFileSync(paths.testsJson).toString();
let tests = JSON.parse(testsFile);

analysis.analyse();
var analysisResults = require(paths.analysisJson);
let analysisResults = require(paths.analysisJson);

var changelog = fs.readFileSync(paths.changelogJson).toString();
var changes = JSON.parse(changelog);
let changelog = fs.readFileSync(paths.changelogJson).toString();
let changes = JSON.parse(changelog);

nunjucks.configure(paths.templates);

// Generate index
var indexout = nunjucks.render('index.html', {
let indexout = nunjucks.render('index.html', {
tests: tests,
getFilename: getFilename,
analysis: analysisResults,
Expand All @@ -140,21 +140,21 @@ function generateFiles(){

// Generate test cases

var indexout = nunjucks.render('test-cases.html', {
let indexout = nunjucks.render('test-cases.html', {
tests: tests,
getFilename: getFilename
});
fs.writeFileSync(paths.out('test-cases.html'), indexout, 'utf8');

// Generate individual tests

for( catname in tests ){
for( testname in tests[catname] ){
var testObj = tests[catname][testname];
for( let catname in tests ){
for( let testname in tests[catname] ){
let testObj = tests[catname][testname];

var filename = getFilename( catname, testname );
let filename = getFilename( catname, testname );

var filecontent = nunjucks.render('single-test.html', {
let filecontent = nunjucks.render('single-test.html', {
testname: testname,
example: processExample(testObj.example)
});
Expand All @@ -164,7 +164,7 @@ function generateFiles(){
}

// Generate results
var resultsout = nunjucks.render('results.html', {
let resultsout = nunjucks.render('results.html', {
tests: tests,
rcopy: resultsCopy,
getFilename: getFilename,
Expand Down