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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/procs/score/tsp.js +46 -26
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testilo",
3
- "version": "44.2.3",
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,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 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
- elementXPaths: [],
222
221
  tools: {}
223
222
  };
224
- const issueDetails = details.issue[issueName];
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[issueName].tools[which][canonicalRuleID];
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[issueName]
243
+ .issue[issueID]
245
244
  .tools[which][canonicalRuleID]
246
245
  .complaints
247
246
  .countTotal += count || 1;
248
247
  if (
249
248
  ! details
250
- .issue[issueName]
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[issueName]
256
+ .issue[issueID]
258
257
  .tools[which][canonicalRuleID]
259
258
  .complaints
260
259
  .texts
261
260
  .push(what);
262
261
  }
263
- issuePaths[issueName] ??= new Set();
262
+ issuePaths[issueID] ??= {};
264
263
  // If the element has a path ID:
265
264
  if (pathID) {
266
- // Ensure that it is in the issue-specific set of XPaths.
267
- 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
+ }
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(issueName => {
298
- const issueData = details.issue[issueName];
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[issueName].tools).forEach(toolName => {
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
- // Add the element details to the score.
336
+ const elementData = {};
337
+ // For each issue:
334
338
  Object.keys(issuePaths).forEach(issueID => {
335
- 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;
336
356
  });
337
357
  // Add the summary issue-count total to the score.
338
358
  summary.issueCount = Object.keys(details.issue).length * issueCountWeight;