From 3be2361eddbe28beb05f6ffadb50a97ac894a075 Mon Sep 17 00:00:00 2001 From: Emanuele Panzeri Date: Fri, 22 Aug 2025 11:00:07 +0200 Subject: [PATCH 1/2] Update error message in UrlRUle to better handle URLs This allows to have clickable links, without the additional `.` or `:` at the end, which breaks on GitHub links. --- src/TodoByIssueUrlRule.php | 6 ++++-- tests/TodoByIssueUrlRuleTest.php | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/TodoByIssueUrlRule.php b/src/TodoByIssueUrlRule.php index c0dfc84..d7d0043 100644 --- a/src/TodoByIssueUrlRule.php +++ b/src/TodoByIssueUrlRule.php @@ -84,10 +84,12 @@ public function processNode(Node $node, Scope $scope): array continue; } + // Adding a space after the {url} allows to have a proper clickable link, without the + // additional character at the end being part of the link's URL, which breaks GitHub links. if ('' !== $todoText) { - $errorMessage = "Should have been resolved in {$url}: ". rtrim($todoText, '.') .'.'; + $errorMessage = "Should have been resolved in {$url} : ". rtrim($todoText, '.') .'.'; } else { - $errorMessage = "Comment should have been resolved with {$url}."; + $errorMessage = "Comment should have been resolved with {$url} ."; } $errors[] = $this->errorBuilder->buildError( diff --git a/tests/TodoByIssueUrlRuleTest.php b/tests/TodoByIssueUrlRuleTest.php index dc9ecdb..39c5ab5 100644 --- a/tests/TodoByIssueUrlRuleTest.php +++ b/tests/TodoByIssueUrlRuleTest.php @@ -39,11 +39,11 @@ public static function provideErrors(): iterable yield [ [ [ - 'Should have been resolved in https://github.com/staabm/phpstan-todo-by/issues/47: we need todo something when this issue is resolved.', + 'Should have been resolved in https://github.com/staabm/phpstan-todo-by/issues/47 : we need todo something when this issue is resolved.', 5, ], [ - 'Comment should have been resolved with https://github.com/staabm/phpstan-todo-by/issues/47.', + 'Comment should have been resolved with https://github.com/staabm/phpstan-todo-by/issues/47 .', 6, ], ], From e8420c8bec2e4960f2ab4e31091436482cf341f2 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Wed, 27 Aug 2025 10:54:37 +0200 Subject: [PATCH 2/2] Update TodoByIssueUrlRuleTest.php --- tests/TodoByIssueUrlRuleTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/TodoByIssueUrlRuleTest.php b/tests/TodoByIssueUrlRuleTest.php index ecaae8b..59ea45d 100644 --- a/tests/TodoByIssueUrlRuleTest.php +++ b/tests/TodoByIssueUrlRuleTest.php @@ -42,6 +42,7 @@ public static function provideErrors(): iterable 'Should have been resolved in https://github.com/staabm/phpstan-todo-by/issues/47 : we need todo something when this issue is resolved.', 5, ], + [ 'Comment should have been resolved with https://github.com/staabm/phpstan-todo-by/pull/155 .', 6, ],