Lines
92.85%
13 / 14
Methods
50.00%
1 / 2
Classes
0.00%
0 / 1
| Name | Lines | Methods | CRAP | ||||
|---|---|---|---|---|---|---|---|
| getNodeType | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| processNode | 92.30% | 12 / 13 | 0.00% | 0 / 1 | 2.00 | ||
| 16 | final readonly class GeneratedCodeFromOlderMajorRule implements Rule | |
| 17 | { | |
| 18 | private const string IDENTIFIER = 'stewart.generatedCode'; | |
| 19 | ||
| 20 | public function getNodeType(): string | |
| 21 | { | |
| 22 | return CollectedDataNode::class; | |
| 23 | } | |
| 24 | ||
| 25 | public function processNode(Node $node, Scope $scope): array | |
| 26 | { | |
| 27 | $collected = $node->get(GeneratedCodeFromOlderMajorCollector::class); | |
| 28 | ||
| 29 | if ($collected === []) { | |
| 30 | return []; | |
| 31 | } | |
| 32 | ||
| 33 | ksort($collected); | |
| 34 | $file = (string) array_key_first($collected); | |
| 35 | ||
| 36 | return [ | |
| 37 | RuleErrorBuilder::message(\sprintf('%s was generated by Stewart 1.x, so entity IDs and action names go unchecked.', $collected[$file][0])) | |
| 38 | ->identifier(self::IDENTIFIER) | |
| 39 | ->tip('Run `make generate`.') | |
| 40 | ->file($file) | |
| 41 | ->line(1) | |
| 42 | ->build(), | |
| 43 | ]; | |
| 44 | } | |
| 45 | } |