testilo 44.2.0 → 44.2.1

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 +31 -34
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testilo",
3
- "version": "44.2.0",
3
+ "version": "44.2.1",
4
4
  "description": "Prepares Testaro jobs and processes Testaro reports",
5
5
  "main": "call.js",
6
6
  "scripts": {
@@ -51,7 +51,7 @@ const issueCountWeight = 10;
51
51
  */
52
52
  const maxWeight = 30;
53
53
 
54
- // 3. Tool
54
+ // 2. Tool
55
55
  /*
56
56
  Severity: amount added to each raw tool score by each violation of a rule with ordinal severity 0
57
57
  through 3.
@@ -60,17 +60,17 @@ const severityWeights = [1, 2, 3, 4];
60
60
  // Final: multiplier of the raw tool score to obtain the final tool score.
61
61
  const toolWeight = 0.1;
62
62
 
63
- // 4. Element
63
+ // 3. Element
64
64
  // Multiplier of the count of elements with at least 1 rule violation.
65
65
  const elementWeight = 2;
66
66
 
67
- // 5. Prevention
67
+ // 4. Prevention
68
68
  // Each tool prevention by the page.
69
69
  const preventionWeight = 300;
70
70
  // Each prevention of a Testaro rule test by the page.
71
71
  const testaroRulePreventionWeight = 30;
72
72
 
73
- // 6. Log
73
+ // 5. Log
74
74
  // Multipliers of log values to obtain the log score.
75
75
  const logWeights = {
76
76
  logCount: 0.1,
@@ -81,7 +81,7 @@ const logWeights = {
81
81
  visitRejectionCount: 2
82
82
  };
83
83
 
84
- // 7. Latency
84
+ // 6. Latency
85
85
  // Normal latency (11 visits [1 per tool], with 2 seconds per visit).
86
86
  const normalLatency = 22;
87
87
  // Total latency exceeding normal, in seconds.
@@ -89,7 +89,7 @@ const latencyWeight = 2;
89
89
 
90
90
  // RULE CONSTANTS
91
91
 
92
- // Initialize a table of issue-classified tool rules.
92
+ // Initialize a directory of issue-classified tool rules.
93
93
  const issueIndex = {};
94
94
  // Initialize an array of variably named tool rules.
95
95
  const issueMatcher = [];
@@ -100,7 +100,7 @@ Object.keys(issues).forEach(issueName => {
100
100
  // For each of those rules:
101
101
  Object.keys(issues[issueName].tools[toolName]).forEach(ruleID => {
102
102
  issueIndex[toolName] ??= {};
103
- // Add it to the table of tool rules.
103
+ // Add it to the directory of tool rules.
104
104
  issueIndex[toolName][ruleID] = issueName;
105
105
  // If it is variably named:
106
106
  if (issues[issueName].tools[toolName][ruleID].variable) {
@@ -203,38 +203,35 @@ exports.scorer = report => {
203
203
  return patternRE.test(ruleID);
204
204
  });
205
205
  }
206
- // If the rule has an ID:
206
+ // If the instance rule has an ID:
207
207
  if (canonicalRuleID) {
208
208
  // Get the issue of the rule.
209
209
  const issueName = issueIndex[which][canonicalRuleID];
210
- // If the rule ID belongs to a non-ignorable issue:
210
+ // If the issue is non-ignorable:
211
211
  if (issueName !== 'ignorable') {
212
- // Add the instance to the issue details of the score data.
213
- if (! details.issue[issueName]) {
214
- details.issue[issueName] = {
215
- summary: issues[issueName].summary,
216
- wcag: issues[issueName].wcag || '',
217
- score: 0,
218
- maxCount: 0,
219
- weight: issues[issueName].weight,
220
- countLimit: issues[issueName].max,
221
- instanceCounts: {},
222
- tools: {}
223
- };
224
- if (! details.issue[issueName].countLimit) {
225
- delete details.issue[issueName].countLimit;
226
- }
227
- }
228
- if (! details.issue[issueName].tools[which]) {
229
- details.issue[issueName].tools[which] = {};
230
- }
231
- if (! details.issue[issueName].instanceCounts[which]) {
232
- details.issue[issueName].instanceCounts[which] = 0;
212
+ // Initialize the issue details if necessary.
213
+ details.issue[issueName] ??= {
214
+ summary: issues[issueName].summary,
215
+ wcag: issues[issueName].wcag || '',
216
+ score: 0,
217
+ maxCount: 0,
218
+ weight: issues[issueName].weight,
219
+ countLimit: issues[issueName].max,
220
+ instanceCounts: {},
221
+ elementXPaths: [],
222
+ tools: {}
223
+ };
224
+ const issueDetails = details.issue[issueName];
225
+ if (! issueDetails.countLimit) {
226
+ delete issueDetails.countLimit;
233
227
  }
234
- details.issue[issueName].instanceCounts[which] += count;
235
- if (! details.issue[issueName].tools[which][canonicalRuleID]) {
228
+ issueDetails.tools[which] ??= {};
229
+ issueDetails.instanceCounts[which] ??= 0;
230
+ // Add data from the instance to the issue details.
231
+ issueDetails.instanceCounts[which] += count;
232
+ if (! issueDetails.tools[which][canonicalRuleID]) {
236
233
  const ruleData = issues[issueName].tools[which][canonicalRuleID];
237
- details.issue[issueName].tools[which][canonicalRuleID] = {
234
+ issueDetails.tools[which][canonicalRuleID] = {
238
235
  quality: ruleData.quality,
239
236
  what: ruleData.what,
240
237
  complaints: {
@@ -266,7 +263,7 @@ exports.scorer = report => {
266
263
  issuePaths[issueName] ??= new Set();
267
264
  // If the element has a path ID:
268
265
  if (pathID) {
269
- // Ensure that it is in the issue-specific set of paths.
266
+ // Ensure that it is in the issue-specific set of XPaths.
270
267
  issuePaths[issueName].add(pathID);
271
268
  }
272
269
  }