testilo 2.0.2 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -77
- package/package.json +3 -4
- package/procs/score/tsp09.js +565 -0
- package/score.js +33 -0
- package/scoring/correlation.js +76 -0
- package/scoring/correlations.json +327 -0
- package/scoring/data.json +26021 -0
- package/scoring/dupCounts.js +39 -0
- package/scoring/dupCounts.json +112 -0
- package/scoring/duplications.json +253 -0
- package/scoring/issues.json +304 -0
- package/scoring/packageData.js +171 -0
- package/scoring/packageIssues.js +34 -0
- package/scoring/packageRules/aatt.js +543 -0
- package/scoring/rulesetData.json +15 -0
- package/aceconfig.js +0 -6
- package/index.js +0 -88
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/*
|
|
2
|
+
packageData
|
|
3
|
+
Compiles data on the per-URL distributions of issues in package tests.
|
|
4
|
+
Arguments:
|
|
5
|
+
0. Name of sibling repo containing reports/script directory.
|
|
6
|
+
*/
|
|
7
|
+
const fs = require('fs');
|
|
8
|
+
const compilers = {
|
|
9
|
+
aatt: act => {
|
|
10
|
+
const {result} = act;
|
|
11
|
+
let data = null;
|
|
12
|
+
if (Array.isArray(result)) {
|
|
13
|
+
data = {};
|
|
14
|
+
result.forEach(issue => {
|
|
15
|
+
const {type, id} = issue;
|
|
16
|
+
if (type && id) {
|
|
17
|
+
const typeID = `${type[0]}:${id}`;
|
|
18
|
+
if (data[typeID]) {
|
|
19
|
+
data[typeID]++;
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
data[typeID] = 1;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
return data;
|
|
28
|
+
},
|
|
29
|
+
alfa: act => {
|
|
30
|
+
const {result} = act;
|
|
31
|
+
let data = null;
|
|
32
|
+
if (Array.isArray(result)) {
|
|
33
|
+
data = {};
|
|
34
|
+
result.forEach(issue => {
|
|
35
|
+
const {rule} = issue;
|
|
36
|
+
if (rule) {
|
|
37
|
+
const {ruleID} = rule;
|
|
38
|
+
if (data[ruleID]) {
|
|
39
|
+
data[ruleID]++;
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
data[ruleID] = 1;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
return data;
|
|
48
|
+
},
|
|
49
|
+
axe: act => {
|
|
50
|
+
const {result} = act;
|
|
51
|
+
const {items} = result;
|
|
52
|
+
let data = null;
|
|
53
|
+
if (items) {
|
|
54
|
+
data = {};
|
|
55
|
+
items.forEach(item => {
|
|
56
|
+
const {rule, elements} = item;
|
|
57
|
+
if (data[rule]) {
|
|
58
|
+
data[rule] += elements.length;
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
data[rule] = elements.length;
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
return data;
|
|
66
|
+
},
|
|
67
|
+
ibm: act => {
|
|
68
|
+
const {result} = act;
|
|
69
|
+
const {content, url} = result;
|
|
70
|
+
const contentViolations = content && content.totals && content.totals.violation;
|
|
71
|
+
const urlViolations = url && url.totals && url.totals.violation;
|
|
72
|
+
let data = null;
|
|
73
|
+
if (contentViolations || urlViolations) {
|
|
74
|
+
let items;
|
|
75
|
+
if (contentViolations && urlViolations) {
|
|
76
|
+
items = contentViolations > urlViolations ? content.items : url.items;
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
items = content.items || url.items;
|
|
80
|
+
}
|
|
81
|
+
if (items) {
|
|
82
|
+
data = {};
|
|
83
|
+
items.forEach(item => {
|
|
84
|
+
const {ruleId, level} = item;
|
|
85
|
+
const issueID = `${level[0]}:${ruleId}`;
|
|
86
|
+
if (data[issueID]) {
|
|
87
|
+
data[issueID]++;
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
data[issueID] = 1;
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return data;
|
|
96
|
+
},
|
|
97
|
+
wave: act => {
|
|
98
|
+
const {result} = act;
|
|
99
|
+
const {categories} = result;
|
|
100
|
+
let data = null;
|
|
101
|
+
if (categories) {
|
|
102
|
+
data = {};
|
|
103
|
+
const {error, contrast, alert} = categories;
|
|
104
|
+
[error, contrast, alert].forEach((category, index) => {
|
|
105
|
+
const {items} = category;
|
|
106
|
+
Object.keys(items).forEach(ruleName => {
|
|
107
|
+
const ruleID = `${'eca'[index]}:${ruleName}`;
|
|
108
|
+
const {count} = items[ruleName];
|
|
109
|
+
if (data[ruleID]) {
|
|
110
|
+
data[ruleID] += count;
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
data[ruleID] = count;
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
return data;
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
const repo = process.argv[2];
|
|
122
|
+
const compile = repo => {
|
|
123
|
+
const dirPath = `${__dirname}/../../${repo}/reports/script`;
|
|
124
|
+
const batchDirNames = fs
|
|
125
|
+
.readdirSync(dirPath, {withFileTypes: true})
|
|
126
|
+
.filter(dirEnt => dirEnt.isDirectory())
|
|
127
|
+
.map(dirEnt => dirEnt.name)
|
|
128
|
+
.filter(dirName => fs.readdirSync(`${dirPath}/${dirName}`).includes('jsonReports'));
|
|
129
|
+
const data = {};
|
|
130
|
+
batchDirNames.forEach(batchDirName => {
|
|
131
|
+
const reportNames = fs.readdirSync(`${dirPath}/${batchDirName}/jsonReports`);
|
|
132
|
+
reportNames.forEach(reportName => {
|
|
133
|
+
const reportJSON = fs.readFileSync(`${dirPath}/${batchDirName}/jsonReports/${reportName}`);
|
|
134
|
+
const report = JSON.parse(reportJSON);
|
|
135
|
+
const {acts} = report;
|
|
136
|
+
const urlAct = acts.find(act => act.type === 'url');
|
|
137
|
+
if (urlAct) {
|
|
138
|
+
const url = urlAct.result;
|
|
139
|
+
if (! data[url]) {
|
|
140
|
+
data[url] = {
|
|
141
|
+
aatt: {},
|
|
142
|
+
alfa: {},
|
|
143
|
+
axe: {},
|
|
144
|
+
ibm: {},
|
|
145
|
+
wave: {}
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
const testActs = acts.filter(act => act.type === 'test');
|
|
149
|
+
testActs.forEach(testAct => {
|
|
150
|
+
if (testAct.which === 'aatt') {
|
|
151
|
+
data[url].aatt = compilers.aatt(testAct);
|
|
152
|
+
}
|
|
153
|
+
else if (testAct.which === 'alfa') {
|
|
154
|
+
data[url].alfa = compilers.alfa(testAct);
|
|
155
|
+
}
|
|
156
|
+
else if (testAct.which === 'axe') {
|
|
157
|
+
data[url].axe = compilers.axe(testAct);
|
|
158
|
+
}
|
|
159
|
+
else if (testAct.which === 'ibm') {
|
|
160
|
+
data[url].ibm = compilers.ibm(testAct);
|
|
161
|
+
}
|
|
162
|
+
else if (testAct.which === 'wave') {
|
|
163
|
+
data[url].wave = compilers.wave(testAct);
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
return data;
|
|
170
|
+
};
|
|
171
|
+
fs.writeFileSync(`${__dirname}/package/data.json`, JSON.stringify(compile(repo), null, 2));
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/*
|
|
2
|
+
packageIssues
|
|
3
|
+
Compiles a list of all issue types appearing in packageData.json.
|
|
4
|
+
*/
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const compile = () => {
|
|
7
|
+
const dataJSON = fs.readFileSync(`${__dirname}/scoring/package/data.json`, 'utf8');
|
|
8
|
+
const reportData = JSON.parse(dataJSON);
|
|
9
|
+
const reports = Object.values(reportData);
|
|
10
|
+
const data = {
|
|
11
|
+
aatt: new Set(),
|
|
12
|
+
alfa: new Set(),
|
|
13
|
+
axe: new Set(),
|
|
14
|
+
ibm: new Set(),
|
|
15
|
+
wave: new Set()
|
|
16
|
+
};
|
|
17
|
+
reports.forEach(entry => {
|
|
18
|
+
Object.keys(entry).forEach(key => {
|
|
19
|
+
if (entry[key] !== null) {
|
|
20
|
+
Object.keys(entry[key]).forEach(issueName => {
|
|
21
|
+
data[key].add(issueName);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
return {
|
|
27
|
+
aatt: Array.from(data.aatt).sort(),
|
|
28
|
+
alfa: Array.from(data.alfa).sort(),
|
|
29
|
+
axe: Array.from(data.axe).sort(),
|
|
30
|
+
ibm: Array.from(data.ibm).sort(),
|
|
31
|
+
wave: Array.from(data.wave).sort()
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
fs.writeFileSync(`${__dirname}/scoring/package/issues.json`, JSON.stringify(compile(), null, 2));
|