testilo 44.2.4 → 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 -25
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,21 +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
221
|
tools: {}
|
|
222
222
|
};
|
|
223
|
-
const issueDetails = details.issue[
|
|
223
|
+
const issueDetails = details.issue[issueID];
|
|
224
224
|
if (! issueDetails.countLimit) {
|
|
225
225
|
delete issueDetails.countLimit;
|
|
226
226
|
}
|
|
@@ -229,7 +229,7 @@ exports.scorer = report => {
|
|
|
229
229
|
// Add data from the instance to the issue details.
|
|
230
230
|
issueDetails.instanceCounts[which] += count;
|
|
231
231
|
if (! issueDetails.tools[which][canonicalRuleID]) {
|
|
232
|
-
const ruleData = issues[
|
|
232
|
+
const ruleData = issues[issueID].tools[which][canonicalRuleID];
|
|
233
233
|
issueDetails.tools[which][canonicalRuleID] = {
|
|
234
234
|
quality: ruleData.quality,
|
|
235
235
|
what: ruleData.what,
|
|
@@ -240,30 +240,34 @@ exports.scorer = report => {
|
|
|
240
240
|
};
|
|
241
241
|
}
|
|
242
242
|
details
|
|
243
|
-
.issue[
|
|
243
|
+
.issue[issueID]
|
|
244
244
|
.tools[which][canonicalRuleID]
|
|
245
245
|
.complaints
|
|
246
246
|
.countTotal += count || 1;
|
|
247
247
|
if (
|
|
248
248
|
! details
|
|
249
|
-
.issue[
|
|
249
|
+
.issue[issueID]
|
|
250
250
|
.tools[which][canonicalRuleID]
|
|
251
251
|
.complaints
|
|
252
252
|
.texts
|
|
253
253
|
.includes(what)
|
|
254
254
|
) {
|
|
255
255
|
details
|
|
256
|
-
.issue[
|
|
256
|
+
.issue[issueID]
|
|
257
257
|
.tools[which][canonicalRuleID]
|
|
258
258
|
.complaints
|
|
259
259
|
.texts
|
|
260
260
|
.push(what);
|
|
261
261
|
}
|
|
262
|
-
issuePaths[
|
|
262
|
+
issuePaths[issueID] ??= {};
|
|
263
263
|
// If the element has a path ID:
|
|
264
264
|
if (pathID) {
|
|
265
|
-
|
|
266
|
-
|
|
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
|
+
}
|
|
267
271
|
}
|
|
268
272
|
}
|
|
269
273
|
}
|
|
@@ -293,8 +297,8 @@ exports.scorer = report => {
|
|
|
293
297
|
}
|
|
294
298
|
});
|
|
295
299
|
// For each non-ignorable issue with any complaints:
|
|
296
|
-
Object.keys(details.issue).forEach(
|
|
297
|
-
const issueData = details.issue[
|
|
300
|
+
Object.keys(details.issue).forEach(issueID => {
|
|
301
|
+
const issueData = details.issue[issueID];
|
|
298
302
|
// For each tool with any complaints for the issue:
|
|
299
303
|
Object.keys(issueData.tools).forEach(toolID => {
|
|
300
304
|
// Get the sum of the quality-weighted counts of its issue rules.
|
|
@@ -312,7 +316,7 @@ exports.scorer = report => {
|
|
|
312
316
|
const maxAddition = issueData.countLimit ? maxWeight / issueData.countLimit : 0;
|
|
313
317
|
issueData.score = Math.round(issueData.weight * issueData.maxCount * (1 + maxAddition));
|
|
314
318
|
// For each tool that has any rule of the issue:
|
|
315
|
-
Object.keys(issues[
|
|
319
|
+
Object.keys(issues[issueID].tools).forEach(toolName => {
|
|
316
320
|
// If the tool was in the job and has no instances of the issue:
|
|
317
321
|
if (testTools.has(toolName) && ! issueData.instanceCounts[toolName]) {
|
|
318
322
|
// Report its instance count as 0.
|
|
@@ -329,9 +333,26 @@ exports.scorer = report => {
|
|
|
329
333
|
});
|
|
330
334
|
return severityTotals;
|
|
331
335
|
}, details.severity.total);
|
|
332
|
-
|
|
336
|
+
const elementData = {};
|
|
337
|
+
// For each issue:
|
|
333
338
|
Object.keys(issuePaths).forEach(issueID => {
|
|
334
|
-
|
|
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;
|
|
335
356
|
});
|
|
336
357
|
// Add the summary issue-count total to the score.
|
|
337
358
|
summary.issueCount = Object.keys(details.issue).length * issueCountWeight;
|