From 9285e132fbfcb33bc1c836900fcd4650aeaa8fba Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Tue, 19 Dec 2023 09:31:54 +0100 Subject: [PATCH] TodoByVersionRule UX: added configuration tip (#18) --- src/TodoByVersionRule.php | 1 + tests/TodoByVersionRuleTest.php | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/TodoByVersionRule.php b/src/TodoByVersionRule.php index 54c8415..70533e7 100644 --- a/src/TodoByVersionRule.php +++ b/src/TodoByVersionRule.php @@ -129,6 +129,7 @@ public function processNode(Node $node, Scope $scope): array if ($this->nonIgnorable) { $errBuilder->nonIgnorable(); } + $errBuilder->tip("Calculated reference version is '". $referenceVersion ."'.\n\n See also:\n https://github.com/staabm/phpstan-todo-by#reference-version"); $errors[] = $errBuilder->build(); } } diff --git a/tests/TodoByVersionRuleTest.php b/tests/TodoByVersionRuleTest.php index f7e6e9b..c00bed5 100644 --- a/tests/TodoByVersionRuleTest.php +++ b/tests/TodoByVersionRuleTest.php @@ -42,48 +42,58 @@ public static function provideErrors(): iterable ] ]; + $tip = "Calculated reference version is '1.0.0.0'.\n\n See also:\n https://github.com/staabm/phpstan-todo-by#reference-version"; yield [ "1.0", [ [ 'Version requirement <1.0.0 not satisfied: This has to be in the first major release.', 5, + $tip ], [ 'Version requirement <1.0.0 not satisfied.', 10, + $tip ] ] ]; + $tip = "Calculated reference version is '123.4.0.0'.\n\n See also:\n https://github.com/staabm/phpstan-todo-by#reference-version"; yield [ "123.4", [ [ 'Version requirement <1.0.0 not satisfied: This has to be in the first major release.', 5, + $tip ], [ 'Version requirement <1.0.0 not satisfied.', 10, + $tip ] ] ]; + $tip = "Calculated reference version is '123.5.0.0'.\n\n See also:\n https://github.com/staabm/phpstan-todo-by#reference-version"; yield [ "123.5", [ [ 'Version requirement <1.0.0 not satisfied: This has to be in the first major release.', 5, + $tip ], [ 'Version requirement >123.4 not satisfied: Must fix this or bump the version.', 7, + $tip ], [ 'Version requirement <1.0.0 not satisfied.', 10, + $tip ] ] ]; @@ -105,16 +115,20 @@ public function testSemanticVersions(string $referenceVersion, array $errors): v */ public static function provideSemanticVersions(): iterable { + $tip = "Calculated reference version is '1.0.0.0'.\n\n See also:\n https://github.com/staabm/phpstan-todo-by#reference-version"; + yield [ 'nextMajor', // we assume this resolves to 1.0 [ [ 'Version requirement <1.0.0 not satisfied: This has to be in the first major release.', 5, + $tip ], [ 'Version requirement <1.0.0 not satisfied.', 10, + $tip ] ] ];