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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/procs/score/tsp.js +46 -25
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testilo",
3
- "version": "44.2.4",
3
+ "version": "44.3.0",
4
4
  "description": "Prepares Testaro jobs and processes Testaro reports",
5
5
  "main": "call.js",
6
6
  "scripts": {
@@ -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(issueName => {
97
+ Object.keys(issues).forEach(issueID => {
98
98
  // For each tool with rules belonging to that issue:
99
- Object.keys(issues[issueName].tools).forEach(toolName => {
99
+ Object.keys(issues[issueID].tools).forEach(toolName => {
100
100
  // For each of those rules:
101
- Object.keys(issues[issueName].tools[toolName]).forEach(ruleID => {
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] = issueName;
104
+ issueIndex[toolName][ruleID] = issueID;
105
105
  // If it is variably named:
106
- if (issues[issueName].tools[toolName][ruleID].variable) {
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 issueName = issueIndex[which][canonicalRuleID];
209
+ const issueID = issueIndex[which][canonicalRuleID];
210
210
  // If the issue is non-ignorable:
211
- if (issueName !== 'ignorable') {
211
+ if (issueID !== 'ignorable') {
212
212
  // Initialize the issue details if necessary.
213
- details.issue[issueName] ??= {
214
- summary: issues[issueName].summary,
215
- wcag: issues[issueName].wcag || '',
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[issueName].weight,
219
- countLimit: issues[issueName].max,
218
+ weight: issues[issueID].weight,
219
+ countLimit: issues[issueID].max,
220
220
  instanceCounts: {},
221
221
  tools: {}
222
222
  };
223
- const issueDetails = details.issue[issueName];
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[issueName].tools[which][canonicalRuleID];
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[issueName]
243
+ .issue[issueID]
244
244
  .tools[which][canonicalRuleID]
245
245
  .complaints
246
246
  .countTotal += count || 1;
247
247
  if (
248
248
  ! details
249
- .issue[issueName]
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[issueName]
256
+ .issue[issueID]
257
257
  .tools[which][canonicalRuleID]
258
258
  .complaints
259
259
  .texts
260
260
  .push(what);
261
261
  }
262
- issuePaths[issueName] ??= new Set();
262
+ issuePaths[issueID] ??= {};
263
263
  // If the element has a path ID:
264
264
  if (pathID) {
265
- // Ensure that it is in the issue-specific set of XPaths.
266
- issuePaths[issueName].add(pathID);
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(issueName => {
297
- const issueData = details.issue[issueName];
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[issueName].tools).forEach(toolName => {
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
- // Add the element details to the score.
336
+ const elementData = {};
337
+ // For each issue:
333
338
  Object.keys(issuePaths).forEach(issueID => {
334
- details.element[issueID] = Array.from(issuePaths[issueID]);
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;