Lines
0.00%
0 / 15
Methods
0.00%
0 / 2
Classes
0.00%
0 / 1
| Name | Lines | Methods | CRAP | ||||
|---|---|---|---|---|---|---|---|
| __construct | 0.00% | 0 / 1 | 0.00% | 0 / 1 | 2 | ||
| warnIfGeneratedCodeDrifted | 0.00% | 0 / 14 | 0.00% | 0 / 1 | 20 | ||
| 10 | final readonly class GeneratedCodeDrift | |
| 11 | { | |
| 12 | public function __construct( | |
| 13 | private HaSession $session, | |
| 14 | private LoggerInterface $logger, | |
| 15 | private ?ManifestCheck $manifest = null, | |
| 16 | ) {} | |
| 17 | ||
| 18 | public function warnIfGeneratedCodeDrifted(): void | |
| 19 | { | |
| 20 | if ($this->manifest === null) { | |
| 21 | return; | |
| 22 | } | |
| 23 | ||
| 24 | if (!$this->manifest->hasCurrentFormat()) { | |
| 25 | $this->logger->warning('Generated classes were written by another stewart generate format; run stewart generate', [ | |
| 26 | 'format' => $this->manifest->readFormatVersion(), | |
| 27 | 'expected_format' => GeneratedFormat::VERSION, | |
| 28 | ]); | |
| 29 | } | |
| 30 | ||
| 31 | $drift = $this->manifest->findDrift($this->session->listEntityIds()); | |
| 32 | ||
| 33 | if ($drift === null) { | |
| 34 | return; | |
| 35 | } | |
| 36 | ||
| 37 | $this->logger->warning('Generated entity classes no longer match Home Assistant; run stewart generate', [ | |
| 38 | 'added' => $drift->added, | |
| 39 | 'removed' => $drift->removed, | |
| 40 | ]); | |
| 41 | } | |
| 42 | } |