You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor: make categories optional in core config (#437)
Closes#407
I aimed for handling the optional categories only in the cli layer and
maintained the existing data structure fully in reports. I just hide the
sections for empty categories.
Follow-up by @Tlacenka:
- I added tests for scoring and sorting reports.
- I allowed passing both `undefined` and `[]` by configuring categories
schema to allow empty array.
- I reduced minimal mocks.
- I typed categories as a non-optional property as soon as in the only
plugins middleware.
---------
Co-authored-by: Katerina Pilatova <katerina.pilatova@flowup.cz>
@@ -498,37 +482,6 @@ async function runnerFunction(options: Options): Promise<AuditOutputs> {
498
482
}
499
483
```
500
484
501
-
### Audit groups
502
-
503
-
As an optional property a plugin can maintain `groups` as an array of [`Group`s](@TODO).
504
-
While [categories](#plugins-and-categories) can score audits across plugins, groups are only targeting plugins within a plugin.
505
-
For simple plugins this is not needed but it is beneficial in bigger plugins as audit groups also simplify the configuration.
506
-
507
-
An audit group maintains:
508
-
509
-
- metadata about the group [GroupMeta](@TODO)
510
-
- a list of referenced audits under `refs` as [GroupRef](@TODO) array
511
-
512
-
The minimum information of an audit group looks like this:
513
-
514
-
```typescript
515
-
import { Group } from'@code-pushup/models';
516
-
517
-
const myGroup:Group= {
518
-
slug: 'performance',
519
-
refs: [
520
-
{
521
-
slug: 'file-size-audit',
522
-
weight: 1,
523
-
},
524
-
],
525
-
// optional details
526
-
};
527
-
```
528
-
529
-
The weight property of a reference is used to calculate a score for all audits listed under refs.
530
-
A weight of 0 can be used for informative audits and a value from 1 upward to give a weight in the score compared to other audits.
531
-
532
485
### Audit details
533
486
534
487
To have better attribution in your audits you can use the `details` section in `AuditOutputs`.
@@ -630,11 +583,42 @@ The `report.md` file should contain a similar content like the following:
630
583
631
584
</details>
632
585
633
-
## Plugins and categories
586
+
## Groups
587
+
588
+
As an optional property a plugin can maintain `groups` as an array of [`Group`s](@TODO).
589
+
While [categories](#plugins-and-categories) can score audits across plugins, groups are only targeting audits within a plugin.
590
+
For simple plugins this is not needed but it is beneficial in bigger plugins as audit groups also simplify the configuration.
591
+
592
+
An audit group maintains:
593
+
594
+
- metadata about the group [GroupMeta](@TODO)
595
+
- a list of referenced audits under `refs` as [GroupRef](@TODO) array
596
+
597
+
The minimum information of an audit group looks like this:
598
+
599
+
```typescript
600
+
import { Group } from'@code-pushup/models';
601
+
602
+
const myGroup:Group= {
603
+
slug: 'performance',
604
+
refs: [
605
+
{
606
+
slug: 'file-size-audit',
607
+
weight: 1,
608
+
},
609
+
],
610
+
// optional details
611
+
};
612
+
```
613
+
614
+
The weight property of a reference is used to calculate a score for all audits listed under refs.
615
+
A weight of 0 can be used for informative audits and a value from 1 upward to give a weight in the score compared to other audits.
616
+
617
+
## Categories
634
618
635
619
In this chapter we will see how plugin results contribute to the category scoring.
636
620
637
-
**basic categories setup**
621
+
**basic category setup**
638
622
In this example we create a Performance category which contains one audit and one group.
639
623
640
624
Assign weights based on what influence each audit and group should have on the overall category score (assign weight 0 to only include it for extra info, without influencing the category score).
0 commit comments