testilo 9.0.3 → 10.0.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 (51) hide show
  1. package/README.md +31 -7
  2. package/package.json +1 -1
  3. package/procs/score/{sp20b.js → tic21.js} +1252 -991
  4. package/procs/score/tsp21.js +720 -0
  5. package/specs/batches/orgs.json +43 -0
  6. package/specs/scripts/ts21.json +213 -0
  7. package/toolRules/qualWeb.tsv +121 -0
  8. package/procs/score/sp10a.js +0 -591
  9. package/procs/score/sp10b.js +0 -507
  10. package/procs/score/sp10c.js +0 -465
  11. package/procs/score/sp11a.js +0 -1968
  12. package/procs/score/sp12a.js +0 -3000
  13. package/procs/score/sp12b.js +0 -3315
  14. package/procs/score/sp14a.js +0 -4101
  15. package/procs/score/sp15a.js +0 -4899
  16. package/procs/score/sp15b.js +0 -6279
  17. package/procs/score/sp15c.js +0 -6282
  18. package/procs/score/sp16a.js +0 -6362
  19. package/procs/score/sp16b.js +0 -6370
  20. package/procs/score/sp16c.js +0 -6364
  21. package/procs/score/sp17a.js +0 -6099
  22. package/procs/score/sp18a.js +0 -6378
  23. package/procs/score/sp20a.js +0 -6379
  24. package/procs/score/spHover.js +0 -328
  25. package/procs/score/tsp09a.js +0 -564
  26. package/scoring/data/correlations.json +0 -327
  27. package/scoring/data/data.json +0 -26021
  28. package/scoring/data/dupCounts.json +0 -112
  29. package/scoring/data/duplications.json +0 -253
  30. package/scoring/data/groups.json +0 -335
  31. package/scoring/data/issues.json +0 -304
  32. package/scoring/data/rulesetData.json +0 -15
  33. package/scoring/data/testGroups.json +0 -1067
  34. package/scoring/procs/asp09.js +0 -555
  35. package/scoring/procs/asp09NoWAVE.js +0 -508
  36. package/scoring/procs/correlation.js +0 -76
  37. package/scoring/procs/dupCounts.js +0 -39
  38. package/scoring/procs/groups.js +0 -61
  39. package/scoring/procs/packageData.js +0 -171
  40. package/scoring/procs/packageIssues.js +0 -34
  41. package/scoring/procs/regroup.js +0 -39
  42. package/scoring/procs/tempgroup.js +0 -96
  43. /package/procs/score/{spA11yMessage.js → tspA11yMessage.js} +0 -0
  44. /package/procs/score/{spProductPrice.js → tspProductPrice.js} +0 -0
  45. /package/{scoring/data/packageRules → toolRules}/alfa.tsv +0 -0
  46. /package/{scoring/data/packageRules → toolRules}/axe.js +0 -0
  47. /package/{scoring/data/packageRules → toolRules}/htmlcs.js +0 -0
  48. /package/{scoring/data/packageRules → toolRules}/ibm.tsv +0 -0
  49. /package/{scoring/data/packageRules → toolRules}/tenon.tsv +0 -0
  50. /package/{scoring/data/packageRules → toolRules}/wave.json +0 -0
  51. /package/{scoring/data/packageRules → toolRules}/wave.tsv +0 -0
@@ -1,591 +0,0 @@
1
- /*
2
- sp10a
3
- Testilo score proc 10a
4
- Computes scores from Testaro script tp10 and adds them to a report. Does not discount tenon.
5
- Tenon discounting is planned future work.
6
- Usage example: node score 35k1r sp10a
7
- */
8
- exports.scorer = report => {
9
- // CONSTANTS
10
- const {acts} = report;
11
- // Define the configuration disclosures.
12
- const logWeights = {
13
- count: 0.5,
14
- size: 0.01,
15
- prohibited: 15,
16
- visitTimeout: 10,
17
- visitRejection: 10
18
- };
19
- const rules = {
20
- aatt: '',
21
- alfa:'',
22
- axe: '',
23
- bulk: '',
24
- embAc: '',
25
- focAll: '',
26
- focInd: '',
27
- focOp: '',
28
- hover: '',
29
- ibm: '',
30
- labClash: '',
31
- linkUl: '',
32
- log: 'multiply log items by respective logWeights; sum',
33
- menuNav: '',
34
- motion: '',
35
- radioSet: '',
36
- role: '',
37
- styleDiff: '',
38
- tabNav: '',
39
- tenon: '',
40
- wave: '',
41
- zIndex: ''
42
- };
43
- let duplications = {};
44
- const diffStyles = [
45
- 'borderStyle',
46
- 'borderWidth',
47
- 'fontStyle',
48
- 'fontWeight',
49
- 'lineHeight',
50
- 'maxHeight',
51
- 'maxWidth',
52
- 'minHeight',
53
- 'minWidth',
54
- 'opacity',
55
- 'outlineOffset',
56
- 'outlineStyle',
57
- 'outlineWidth',
58
- 'textDecorationLine',
59
- 'textDecorationStyle',
60
- 'textDecorationThickness'
61
- ];
62
- // Initialize the score.
63
- const inferences = {};
64
- let scores = {
65
- total: 0,
66
- aatt: null,
67
- alfa: null,
68
- axe: null,
69
- bulk: null,
70
- embAc: null,
71
- focAll: null,
72
- focInd: null,
73
- focOp: null,
74
- hover: null,
75
- ibm: null,
76
- labClash: null,
77
- linkUl: null,
78
- log: null,
79
- menuNav: null,
80
- motion: null,
81
- radioSet: null,
82
- role: null,
83
- styleDiff: null,
84
- tabNav: null,
85
- tenon: null,
86
- wave: null,
87
- zIndex: null
88
- };
89
- // VARIABLES
90
- let facts;
91
- // If there are any acts:
92
- if (Array.isArray(acts)) {
93
- // If any of them are tests:
94
- const tests = acts.filter(act => act.type === 'test');
95
- if (tests.length) {
96
- // CONSTANTS
97
- // Empirically derived counts of duplications of package rules.
98
- duplications = {
99
- 'aatt': {
100
- 'e:F77': 1,
101
- 'e:H36': 4,
102
- 'e:H37': 2,
103
- 'e:H57': 3,
104
- 'e:H58': 2,
105
- 'w:G141': 3,
106
- 'w:H98': 1,
107
- 'e:ARIA6+H53': 1,
108
- 'e:H24': 2,
109
- 'e:G1+G123+G124': 1,
110
- 'w:G90': 1,
111
- 'w:H44': 1
112
- },
113
- 'alfa': {
114
- 'r3': 2,
115
- 'r28': 4,
116
- 'r2': 2,
117
- 'r4': 3,
118
- 'r7': 2,
119
- 'r53': 3,
120
- 'r10': 1,
121
- 'r11': 1,
122
- 'r12': 2,
123
- 'r20': 1,
124
- 'r42': 1,
125
- 'r43': 1,
126
- 'r47': 1,
127
- 'r5': 2,
128
- 'r68': 1,
129
- 'r93': 1,
130
- 'r13': 1
131
- },
132
- 'axe': {
133
- 'input-image-alt': 4,
134
- 'html-has-lang': 3,
135
- 'valid-lang': 2,
136
- 'heading-order': 3,
137
- 'link-name': 2,
138
- 'aria-command-name': 2,
139
- 'dlitem': 1,
140
- 'image-alt': 2,
141
- 'duplicate-id': 1,
142
- 'aria-required-parent': 1,
143
- 'svg-img-alt': 1,
144
- 'meta-viewport': 1,
145
- 'html-lang-valid': 2,
146
- 'aria-required-children': 1,
147
- 'avoid-inline-spacing': 1,
148
- 'area-alt': 2,
149
- 'aria-allowed-role': 1,
150
- 'aria-required-attr': 1,
151
- 'aria-valid-attr': 1,
152
- 'autocomplete-valid': 1,
153
- 'color-contrast': 1,
154
- 'empty-heading': 2,
155
- 'frame-title': 1,
156
- 'image-redundant-alt': 1,
157
- 'landmark-complementary-is-top-level': 2,
158
- 'landmark-no-duplicate-banner': 1,
159
- 'landmark-no-duplicate-main': 2,
160
- 'document-title': 1,
161
- 'object-alt': 1,
162
- 'page-has-heading-one': 1,
163
- 'select-name': 1
164
- },
165
- 'ibm': {
166
- 'v:WCAG20_Object_HasText': 1,
167
- 'v:WCAG20_Area_HasAlt': 2,
168
- 'v:WCAG20_Input_ExplicitLabelImage': 4,
169
- 'v:WCAG20_Frame_HasTitle': 2,
170
- 'v:WCAG20_Elem_Lang_Valid': 2,
171
- 'v:HAAC_Img_UsemapAlt': 1,
172
- 'v:aria_semantics_role': 1,
173
- 'v:Rpt_Aria_RequiredProperties': 1,
174
- 'v:Rpt_Aria_ValidProperty': 1,
175
- 'v:WCAG21_Input_Autocomplete': 1,
176
- 'v:IBMA_Color_Contrast_WCAG2AA': 2,
177
- 'v:RPT_Header_HasContent': 2,
178
- 'v:WCAG20_Img_HasAlt': 2,
179
- 'v:WCAG20_Img_LinkTextNotRedundant': 1,
180
- 'v:Rpt_Aria_ComplementaryRequiredLabel_Implicit': 1,
181
- 'v:Rpt_Aria_MultipleComplementaryLandmarks_Implicit': 1,
182
- 'v:Rpt_Aria_MultipleBannerLandmarks_Implicit': 1,
183
- 'r:Rpt_Aria_MultipleMainsVisibleLabel_Implicit': 1,
184
- 'v:Rpt_Aria_MultipleMainsRequireLabel_Implicit_2': 1,
185
- 'v:WCAG20_A_HasText': 1,
186
- 'v:Rpt_Aria_ValidIdRef': 1,
187
- 'v:WCAG20_Elem_UniqueAccessKey': 1,
188
- 'v:WCAG20_Input_RadioChkInFieldSet': 1
189
- },
190
- 'wave': {
191
- 'a:link_internal_broken': 1,
192
- 'e:alt_area_missing': 3,
193
- 'e:alt_input_missing': 4,
194
- 'e:alt_missing': 2,
195
- 'e:language_missing': 3,
196
- 'a:heading_skipped': 3,
197
- 'a:event_handler': 1,
198
- 'a:label_orphaned': 1,
199
- 'e:title_invalid': 1,
200
- 'e:heading_empty': 2,
201
- 'a:plugin': 1,
202
- 'a:h1_missing': 1,
203
- 'a:select_missing_label': 1,
204
- 'c:contrast': 1,
205
- 'e:aria_reference_broken': 1,
206
- 'a:accesskey': 1,
207
- 'a:fieldset_missing': 1
208
- }
209
- };
210
- // FUNCTIONS
211
- // Adds the actual or inferred score of a test to the total score.
212
- const increment = test => {
213
- scores.total += typeof scores[test] === 'number' ? scores[test] : inferences[test];
214
- };
215
- // OPERATION
216
- // For each test:
217
- tests.forEach(test => {
218
- const {which} = test;
219
- // Compute its score.
220
- if (which === 'alfa') {
221
- facts = test.result;
222
- if (facts && Array.isArray(facts)) {
223
- rules.alfa = 'multiply cantTell by 2*, failed by 4* (*discounted); sum';
224
- scores.alfa = Math.round(facts.reduce((total, issue) => {
225
- const rawScore = [4, 2][['failed', 'cantTell'].indexOf(issue.verdict)] || 0;
226
- const divisor = duplications.alfa[issue.rule.ruleID] + 1 || 1;
227
- return total + rawScore / divisor;
228
- }, 0));
229
- scores.total += scores.alfa;
230
- }
231
- }
232
- else if (which === 'aatt') {
233
- facts = test.result;
234
- if (facts && Array.isArray(facts)) {
235
- rules.aatt = 'multiply warning by 2*, error by 4* (*discounted); sum';
236
- const issues = facts.filter(fact => fact.type);
237
- scores.aatt = Math.round(issues.reduce((total, issue) => {
238
- const rawScore = [4, 2][['error', 'warning'].indexOf(issue.type)] || 0;
239
- const divisor = duplications.aatt[`${issue.type.slice(0, 1)}:${issue.id}`] + 1 || 1;
240
- return total + rawScore / divisor;
241
- }, 0));
242
- scores.total += scores.aatt;
243
- }
244
- }
245
- else if (which === 'axe') {
246
- facts = test.result && test.result.items;
247
- if (facts) {
248
- rules.axe = 'multiply minor by 2*, moderate by 3*, serious by 4*, critical by 5* (*discounted); sum';
249
- scores.axe = Math.round(facts.reduce((total, item) => {
250
- const rawScore = item.elements.length * (
251
- [5, 4, 3, 2][['critical', 'serious', 'moderate', 'minor'].indexOf(item.impact)] || 0
252
- );
253
- const divisor = duplications.axe[item.rule] + 1 || 1;
254
- return total + rawScore / divisor;
255
- }, 0));
256
- scores.total += scores.axe;
257
- }
258
- }
259
- else if (which === 'ibm') {
260
- facts = test.result;
261
- if (facts && facts.content && facts.url && (facts.content.totals || facts.url.totals)) {
262
- rules.ibm = 'multiply violations by 4*, recommendations by 2* (*discounted); sum';
263
- const ibmScores = {
264
- content: null,
265
- url: null
266
- };
267
- ['content', 'url'].forEach(type => {
268
- const totals = facts[type].totals;
269
- if (totals) {
270
- const items = facts[type].items || [];
271
- ibmScores[type] = Math.round(items.reduce((total, item) => {
272
- const {ruleId, level} = item;
273
- const rawScore = [4, 2][['violation', 'recommendation'].indexOf(level)] || 0;
274
- const divisor = duplications.ibm[`${level.slice(0, 1)}:${ruleId}`] + 1 || 1;
275
- return total + rawScore / divisor;
276
- }, 0));
277
- }
278
- });
279
- if (ibmScores.content !== null || ibmScores.url !== null) {
280
- scores.ibm = Math.max(ibmScores.content || 0, ibmScores.url || 0);
281
- scores.total += scores.ibm;
282
- }
283
- }
284
- }
285
- else if (which === 'tenon') {
286
- facts = test.result
287
- && test.result.data
288
- && test.result.data.resultSummary
289
- && test.result.data.resultSummary.issues;
290
- if (facts) {
291
- rules.tenon
292
- = 'multiply warnings by 1, errors by 3; sum';
293
- const weights = {
294
- totalErrors: 3,
295
- totalWarnings: 1
296
- };
297
- const tenonScores = {
298
- totalErrors: 0,
299
- totalWarnings: 0
300
- };
301
- ['totalErrors', 'totalWarnings'].forEach(level => {
302
- tenonScores[level] = weights[level] * facts[level];
303
- });
304
- scores.tenon = tenonScores.totalErrors + tenonScores.totalWarnings;
305
- scores.total += scores.tenon;
306
- }
307
- }
308
- else if (which === 'wave') {
309
- facts = test.result && test.result.categories;
310
- if (facts) {
311
- rules.wave
312
- = 'multiply alerts by 2*, contrast errors by 3*, errors by 4* (*discounted); sum';
313
- const weights = {
314
- error: 4,
315
- contrast: 3,
316
- alert: 2
317
- };
318
- const waveScores = {
319
- error: 0,
320
- contrast: 0,
321
- alert: 0
322
- };
323
- ['error', 'contrast', 'alert'].forEach(level => {
324
- const {items} = facts[level];
325
- waveScores[level] = Math.round(Object.keys(items).reduce((total, ruleID) => {
326
- const rawScore = items[ruleID].count * weights[level];
327
- const divisor = duplications.wave[`${level.slice(0, 1)}:${ruleID}`] + 1 || 1;
328
- return total + rawScore / divisor;
329
- }, 0));
330
- });
331
- scores.wave = waveScores.error + waveScores.contrast + waveScores.alert;
332
- scores.total += scores.wave;
333
- }
334
- }
335
- else if (which === 'bulk') {
336
- facts = test.result && test.result.visibleElements;
337
- if (typeof facts === 'number') {
338
- rules.bulk = 'subtract 250 from visible elements; make 0 if negative; raise to 0.9th power; multiply by 0.15';
339
- // Deficit: 15% of the excess, to the 0.9th power, of the element count over 250.
340
- scores.bulk = Math.floor(0.15 * Math.pow(Math.max(0, facts - 250), 0.9));
341
- }
342
- else {
343
- inferences.bulk = 100;
344
- }
345
- increment('bulk');
346
- }
347
- else if (which === 'embAc') {
348
- facts = test.result && test.result.totals;
349
- if (facts) {
350
- rules.embAc = 'multiply link- or button-contained links, buttons, inputs, and selects by 3 (discounted)';
351
- scores.embAc = 3 * (facts.links + facts.buttons + facts.inputs + facts.selects);
352
- }
353
- else {
354
- inferences.embAc = 150;
355
- }
356
- increment('embAc');
357
- }
358
- else if (which === 'focAll') {
359
- facts = test.result;
360
- if (facts && typeof facts === 'object') {
361
- rules.focAll= 'multiply discrepancy between focusable and focused element counts by 3';
362
- scores.focAll = 3 * Math.abs(facts.discrepancy);
363
- }
364
- else {
365
- inferences.focAll = 150;
366
- }
367
- increment('focAll');
368
- }
369
- else if (which === 'focInd') {
370
- facts = test.result && test.result.totals;
371
- facts = facts ? facts.types : null;
372
- if (facts) {
373
- rules.focInd = 'multiply indicatorless-when-focused elements by 5';
374
- scores.focInd = 5 * facts.indicatorMissing.total + 3 * facts.nonOutlinePresent.total;
375
- }
376
- else {
377
- inferences.focInd = 150;
378
- }
379
- increment('focInd');
380
- }
381
- else if (which === 'focOl') {
382
- facts = test.result && test.result.totals;
383
- facts = facts ? facts.types : null;
384
- facts = facts ? facts.outlineMissing : null;
385
- if (facts) {
386
- rules.focOl = 'multiply non-outline focus indicators by 3, missing focus indicators by 5; sum';
387
- scores.focOl = 3 * facts.total;
388
- }
389
- else {
390
- inferences.focOl = 100;
391
- }
392
- increment('focOl');
393
- }
394
- else if (which === 'focOp') {
395
- facts = test.result && test.result.totals;
396
- if (facts) {
397
- rules.focOp = 'multiply nonfocusable operable elements by 4, nonoperable focusable by 1; sum';
398
- scores.focOp
399
- = 4 * facts.types.onlyOperable.total + 1 * facts.types.onlyFocusable.total;
400
- }
401
- else {
402
- inferences.focOp = 150;
403
- }
404
- increment('focOp');
405
- }
406
- else if (which === 'hover') {
407
- facts = test.result && test.result.totals;
408
- if (facts) {
409
- rules.hover = 'multiply elements changing page on hover by 4, made visible by 2, with directly changed opacity by 0.1, with indirectly changed opacity by 0.2, unhoverable by 2; sum';
410
- scores.hover
411
- = 4 * facts.triggers
412
- + 2 * facts.madeVisible
413
- + Math.floor(0.1 * facts.opacityChanged)
414
- + Math.floor(0.2 * facts.opacityAffected)
415
- + 2 * facts.unhoverables;
416
- }
417
- else {
418
- inferences.hover = 150;
419
- }
420
- increment('hover');
421
- }
422
- else if (which === 'labClash') {
423
- facts = test.result && test.result.totals;
424
- if (facts) {
425
- rules.labClash = 'multiply conflictually labeled elements by 2, unlabeled elements by 2; sum';
426
- // Unlabeled elements discounted.
427
- scores.labClash = 2 * facts.mislabeled + 2 * facts.unlabeled;
428
- }
429
- else {
430
- inferences.labClash = 100;
431
- }
432
- increment('labClash');
433
- }
434
- else if (which === 'linkUl') {
435
- facts = test.result && test.result.totals;
436
- facts = facts ? facts.inline : null;
437
- if (facts) {
438
- rules.linkUl = 'multiply nonunderlined inline links by 3';
439
- scores.linkUl = 3 * (facts.total - facts.underlined);
440
- }
441
- else {
442
- inferences.linkUl = 150;
443
- }
444
- increment('linkUl');
445
- }
446
- else if (which === 'menuNav') {
447
- facts = test.result && test.result.totals && test.result.totals.navigations;
448
- if (facts) {
449
- rules.menuNav = 'multiply Home and End errors by 1 and other key-navigation errors by 3; sum';
450
- scores.menuNav
451
- = 3 * facts.all.incorrect
452
- - 2 * (facts.specific.home.incorrect + facts.specific.end.incorrect);
453
- }
454
- else {
455
- inferences.menuNav = 150;
456
- }
457
- increment('menuNav');
458
- }
459
- else if (which === 'motion') {
460
- facts = test.result;
461
- if (facts && facts.bytes) {
462
- rules.motion = 'get PNG screenshot sizes (sss); get differing-pixel counts between adjacent PNG screenshots (pd); “sssd” = sss difference ÷ smaller sss - 1; multiply mean adjacent sssd by 5, maximum adjacent sssd by 2, maximum over-all ssd by 1; divide mean pd by 10,000, maximum pd by 25,000; multiply count of non-0 pd by 30; sum';
463
- scores.motion = Math.floor(
464
- 5 * (facts.meanLocalRatio - 1)
465
- + 2 * (facts.maxLocalRatio - 1)
466
- + facts.globalRatio - 1
467
- + facts.meanPixelChange / 10000
468
- + facts.maxPixelChange / 25000
469
- + 30 * facts.changeFrequency
470
- );
471
- }
472
- else {
473
- inferences.motion = 150;
474
- }
475
- increment('motion');
476
- }
477
- else if (which === 'radioSet') {
478
- facts = test.result && test.result.totals;
479
- if (facts) {
480
- rules.radioSet = 'multiply radio buttons not in fieldsets with legends and no other-name radio buttons by 2';
481
- // Defects discounted.
482
- scores.radioSet = 2 * (facts.total - facts.inSet);
483
- }
484
- else {
485
- inferences.radioSet = 100;
486
- }
487
- increment('radioSet');
488
- }
489
- else if (which === 'role') {
490
- facts = test.result && test.result.badRoleElements;
491
- if (typeof facts === 'number') {
492
- rules.role = 'multiple role attributes with invalid or native-HTML-equivalent values by 2';
493
- // Defects discounted.
494
- scores.role = 2 * facts;
495
- }
496
- else {
497
- inferences.role = 100;
498
- }
499
- increment('role');
500
- }
501
- else if (which === 'styleDiff') {
502
- facts = test.result && test.result.totals;
503
- if (facts) {
504
- rules.styleDiff = 'for each of element classes block a, inline a, button, h1, h2, h3, h4, h5, and h6, get diffStyles-distinct styles; multiply their count minus 1 by 2; multiply count of elements with non-plurality styles by 0.2; sum';
505
- // Identify objects having the tag-name totals and style distributions as properties.
506
- const tagNameCounts = Object.values(facts);
507
- // Identify an array of pairs of counts of excess styles and nonplurality elements.
508
- const deficits = tagNameCounts.map(
509
- item => {
510
- const subtotals = item.subtotals ? item.subtotals : [item.total];
511
- return [subtotals.length - 1, item.total - subtotals[0]];
512
- }
513
- );
514
- // Deficit: 2 per excess style + 0.2 per nonplurality element.
515
- scores.styleDiff = Math.floor(deficits.reduce(
516
- (total, currentPair) => total + 2 * currentPair[0] + 0.2 * currentPair[1], 0
517
- ));
518
- }
519
- else {
520
- inferences.styleDiff = 100;
521
- }
522
- increment('styleDiff');
523
- }
524
- else if (which === 'tabNav') {
525
- facts = test.result && test.result.totals && test.result.totals.navigations;
526
- if (facts) {
527
- rules.tabNav = 'multiply Home and End errors by 1 and other key-navigation errors by 3; sum';
528
- scores.tabNav
529
- = 3 * facts.all.incorrect
530
- - 2 * (facts.specific.home.incorrect + facts.specific.end.incorrect);
531
- }
532
- else {
533
- inferences.tabNav = 150;
534
- }
535
- increment('tabNav');
536
- }
537
- else if (which === 'zIndex') {
538
- facts = test.result && test.result.totals;
539
- if (facts) {
540
- rules.zIndex = 'multiply non-auto z indexes by 3';
541
- scores.zIndex = 3 * facts.total;
542
- }
543
- else {
544
- inferences.zIndex = 100;
545
- }
546
- increment('zIndex');
547
- }
548
- });
549
- // Compute the inferred scores of prevented package tests and adjust the total score.
550
- const estimate = (tests, penalty) => {
551
- const packageScores = tests.map(test => scores[test]).filter(score => score !== null);
552
- const scoreCount = packageScores.length;
553
- let meanScore;
554
- if (scoreCount) {
555
- meanScore = Math.floor(
556
- packageScores.reduce((sum, current) => sum + current) / packageScores.length
557
- );
558
- }
559
- else {
560
- meanScore = 100;
561
- }
562
- tests.forEach(test => {
563
- if (scores[test] === null) {
564
- inferences[test] = meanScore + penalty;
565
- scores.total += inferences[test];
566
- }
567
- });
568
- };
569
- estimate(['alfa', 'aatt', 'axe', 'ibm', 'tenon', 'wave'], 100);
570
- }
571
- }
572
- logScore = Math.floor(
573
- logWeights.count * report.logCount
574
- + logWeights.size * report.logSize
575
- + logWeights.prohibited * report.prohibitedCount
576
- + logWeights.visitTimeout * report.visitTimeoutCount
577
- + logWeights.visitRejection * report.visitRejectionCount
578
- );
579
- scores.log = logScore;
580
- scores.total += logScore;
581
- // Add the score facts to the report.
582
- report.score = {
583
- scoreProcID: '',
584
- duplications,
585
- rules,
586
- diffStyles,
587
- logWeights,
588
- inferences,
589
- scores
590
- };
591
- };