testilo 44.2.3 → 44.3.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/package.json +1 -1
- package/procs/score/tsp.js +46 -26
package/package.json
CHANGED
package/procs/score/tsp.js
CHANGED
|
@@ -94,16 +94,16 @@ const issueIndex = {};
|
|
|
94
94
|
// Initialize an array of variably named tool rules.
|
|
95
95
|
const issueMatcher = [];
|
|
96
96
|
// For each issue:
|
|
97
|
-
Object.keys(issues).forEach(
|
|
97
|
+
Object.keys(issues).forEach(issueID => {
|
|
98
98
|
// For each tool with rules belonging to that issue:
|
|
99
|
-
Object.keys(issues[
|
|
99
|
+
Object.keys(issues[issueID].tools).forEach(toolName => {
|
|
100
100
|
// For each of those rules:
|
|
101
|
-
Object.keys(issues[
|
|
101
|
+
Object.keys(issues[issueID].tools[toolName]).forEach(ruleID => {
|
|
102
102
|
issueIndex[toolName] ??= {};
|
|
103
103
|
// Add it to the directory of tool rules.
|
|
104
|
-
issueIndex[toolName][ruleID] =
|
|
104
|
+
issueIndex[toolName][ruleID] = issueID;
|
|
105
105
|
// If it is variably named:
|
|
106
|
-
if (issues[
|
|
106
|
+
if (issues[issueID].tools[toolName][ruleID].variable) {
|
|
107
107
|
// Add it to the array of variably named tool rules.
|
|
108
108
|
issueMatcher.push(ruleID);
|
|
109
109
|
}
|
|
@@ -206,22 +206,21 @@ exports.scorer = report => {
|
|
|
206
206
|
// If the instance rule has an ID:
|
|
207
207
|
if (canonicalRuleID) {
|
|
208
208
|
// Get the issue of the rule.
|
|
209
|
-
const
|
|
209
|
+
const issueID = issueIndex[which][canonicalRuleID];
|
|
210
210
|
// If the issue is non-ignorable:
|
|
211
|
-
if (
|
|
211
|
+
if (issueID !== 'ignorable') {
|
|
212
212
|
// Initialize the issue details if necessary.
|
|
213
|
-
details.issue[
|
|
214
|
-
summary: issues[
|
|
215
|
-
wcag: issues[
|
|
213
|
+
details.issue[issueID] ??= {
|
|
214
|
+
summary: issues[issueID].summary,
|
|
215
|
+
wcag: issues[issueID].wcag || '',
|
|
216
216
|
score: 0,
|
|
217
217
|
maxCount: 0,
|
|
218
|
-
weight: issues[
|
|
219
|
-
countLimit: issues[
|
|
218
|
+
weight: issues[issueID].weight,
|
|
219
|
+
countLimit: issues[issueID].max,
|
|
220
220
|
instanceCounts: {},
|
|
221
|
-
elementXPaths: [],
|
|
222
221
|
tools: {}
|
|
223
222
|
};
|
|
224
|
-
const issueDetails = details.issue[
|
|
223
|
+
const issueDetails = details.issue[issueID];
|
|
225
224
|
if (! issueDetails.countLimit) {
|
|
226
225
|
delete issueDetails.countLimit;
|
|
227
226
|
}
|
|
@@ -230,7 +229,7 @@ exports.scorer = report => {
|
|
|
230
229
|
// Add data from the instance to the issue details.
|
|
231
230
|
issueDetails.instanceCounts[which] += count;
|
|
232
231
|
if (! issueDetails.tools[which][canonicalRuleID]) {
|
|
233
|
-
const ruleData = issues[
|
|
232
|
+
const ruleData = issues[issueID].tools[which][canonicalRuleID];
|
|
234
233
|
issueDetails.tools[which][canonicalRuleID] = {
|
|
235
234
|
quality: ruleData.quality,
|
|
236
235
|
what: ruleData.what,
|
|
@@ -241,30 +240,34 @@ exports.scorer = report => {
|
|
|
241
240
|
};
|
|
242
241
|
}
|
|
243
242
|
details
|
|
244
|
-
.issue[
|
|
243
|
+
.issue[issueID]
|
|
245
244
|
.tools[which][canonicalRuleID]
|
|
246
245
|
.complaints
|
|
247
246
|
.countTotal += count || 1;
|
|
248
247
|
if (
|
|
249
248
|
! details
|
|
250
|
-
.issue[
|
|
249
|
+
.issue[issueID]
|
|
251
250
|
.tools[which][canonicalRuleID]
|
|
252
251
|
.complaints
|
|
253
252
|
.texts
|
|
254
253
|
.includes(what)
|
|
255
254
|
) {
|
|
256
255
|
details
|
|
257
|
-
.issue[
|
|
256
|
+
.issue[issueID]
|
|
258
257
|
.tools[which][canonicalRuleID]
|
|
259
258
|
.complaints
|
|
260
259
|
.texts
|
|
261
260
|
.push(what);
|
|
262
261
|
}
|
|
263
|
-
issuePaths[
|
|
262
|
+
issuePaths[issueID] ??= {};
|
|
264
263
|
// If the element has a path ID:
|
|
265
264
|
if (pathID) {
|
|
266
|
-
|
|
267
|
-
|
|
265
|
+
issuePaths[issueID][pathID] ??= [];
|
|
266
|
+
// If the tool is not yet listed as a reporter of the issue for the element:
|
|
267
|
+
if (! issuePaths[issueID][pathID].includes(which)) {
|
|
268
|
+
// Add the tool to the list.
|
|
269
|
+
issuePaths[issueID][pathID].push(which);
|
|
270
|
+
}
|
|
268
271
|
}
|
|
269
272
|
}
|
|
270
273
|
}
|
|
@@ -294,8 +297,8 @@ exports.scorer = report => {
|
|
|
294
297
|
}
|
|
295
298
|
});
|
|
296
299
|
// For each non-ignorable issue with any complaints:
|
|
297
|
-
Object.keys(details.issue).forEach(
|
|
298
|
-
const issueData = details.issue[
|
|
300
|
+
Object.keys(details.issue).forEach(issueID => {
|
|
301
|
+
const issueData = details.issue[issueID];
|
|
299
302
|
// For each tool with any complaints for the issue:
|
|
300
303
|
Object.keys(issueData.tools).forEach(toolID => {
|
|
301
304
|
// Get the sum of the quality-weighted counts of its issue rules.
|
|
@@ -313,7 +316,7 @@ exports.scorer = report => {
|
|
|
313
316
|
const maxAddition = issueData.countLimit ? maxWeight / issueData.countLimit : 0;
|
|
314
317
|
issueData.score = Math.round(issueData.weight * issueData.maxCount * (1 + maxAddition));
|
|
315
318
|
// For each tool that has any rule of the issue:
|
|
316
|
-
Object.keys(issues[
|
|
319
|
+
Object.keys(issues[issueID].tools).forEach(toolName => {
|
|
317
320
|
// If the tool was in the job and has no instances of the issue:
|
|
318
321
|
if (testTools.has(toolName) && ! issueData.instanceCounts[toolName]) {
|
|
319
322
|
// Report its instance count as 0.
|
|
@@ -330,9 +333,26 @@ exports.scorer = report => {
|
|
|
330
333
|
});
|
|
331
334
|
return severityTotals;
|
|
332
335
|
}, details.severity.total);
|
|
333
|
-
|
|
336
|
+
const elementData = {};
|
|
337
|
+
// For each issue:
|
|
334
338
|
Object.keys(issuePaths).forEach(issueID => {
|
|
335
|
-
|
|
339
|
+
// For each element reported as exhibiting it:
|
|
340
|
+
Object.keys(issuePaths[issueID]).forEach(pathID => {
|
|
341
|
+
elementData[issueID] ??= {};
|
|
342
|
+
const toolList = issuePaths[issueID][pathID].sort().join(' + ');
|
|
343
|
+
elementData[issueID] ??= {}
|
|
344
|
+
elementData[issueID][toolList] ??= [];
|
|
345
|
+
// Classify the element by the set of tools reporting it for the issue.
|
|
346
|
+
elementData[issueID][toolList].push(pathID);
|
|
347
|
+
});
|
|
348
|
+
// Sort the XPaths.
|
|
349
|
+
Object.keys(elementData).forEach(issueID => {
|
|
350
|
+
Object.keys(elementData[issueID]).forEach(toolList => {
|
|
351
|
+
elementData[issueID][toolList].sort();
|
|
352
|
+
});
|
|
353
|
+
});
|
|
354
|
+
// Add the element data to the score details.
|
|
355
|
+
details.element = elementData;
|
|
336
356
|
});
|
|
337
357
|
// Add the summary issue-count total to the score.
|
|
338
358
|
summary.issueCount = Object.keys(details.issue).length * issueCountWeight;
|