From ed621f8ba501c1a63429a3a04afe4e3b94793bb7 Mon Sep 17 00:00:00 2001 From: Svyatoslav Varpikhovsky Date: Mon, 3 Jun 2024 16:09:50 +0300 Subject: [PATCH 1/2] FRW-8590 Fixed false positive specification error --- Spryker/Sniffs/Commenting/DocBlockApiAnnotationSniff.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Spryker/Sniffs/Commenting/DocBlockApiAnnotationSniff.php b/Spryker/Sniffs/Commenting/DocBlockApiAnnotationSniff.php index 0116f046..86ba3cdf 100644 --- a/Spryker/Sniffs/Commenting/DocBlockApiAnnotationSniff.php +++ b/Spryker/Sniffs/Commenting/DocBlockApiAnnotationSniff.php @@ -23,7 +23,7 @@ class DocBlockApiAnnotationSniff extends AbstractApiClassDetectionSprykerSniff /** * @var string */ - protected const SPECIFICATION_TAG = 'Specification'; + protected const SPECIFICATION_TAG = 'Specification:'; /** * @inheritDoc @@ -348,7 +348,7 @@ public function assertSpecificationFormat(File $phpCsFile, int $stackPointer): v { $tokens = $phpCsFile->getTokens(); $tokenContent = $tokens[$stackPointer]['content']; - if ($tokenContent === sprintf('%s:', static::SPECIFICATION_TAG)) { + if ($tokenContent === sprintf('%s', static::SPECIFICATION_TAG)) { return; } $this->addTypoInSpecificationTagFixableError($phpCsFile, $stackPointer); From afef65e09483073dd3c7d5cfdd2f0072b611f461 Mon Sep 17 00:00:00 2001 From: Svyatoslav Varpikhovsky Date: Wed, 5 Jun 2024 09:16:16 +0300 Subject: [PATCH 2/2] FRW-8590 Fixed use another way for check specification tag --- Spryker/Sniffs/Commenting/DocBlockApiAnnotationSniff.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Spryker/Sniffs/Commenting/DocBlockApiAnnotationSniff.php b/Spryker/Sniffs/Commenting/DocBlockApiAnnotationSniff.php index 86ba3cdf..bdfcff41 100644 --- a/Spryker/Sniffs/Commenting/DocBlockApiAnnotationSniff.php +++ b/Spryker/Sniffs/Commenting/DocBlockApiAnnotationSniff.php @@ -23,7 +23,7 @@ class DocBlockApiAnnotationSniff extends AbstractApiClassDetectionSprykerSniff /** * @var string */ - protected const SPECIFICATION_TAG = 'Specification:'; + protected const SPECIFICATION_TAG = 'Specification'; /** * @inheritDoc @@ -324,11 +324,12 @@ public function validateSpecification(File $phpCsFile, int $stackPointer): ?int return null; } + $apiTagPosition = $this->findApiAnnotationIndex($phpCsFile, $stackPointer); $specificationPosition = $this->getContentPositionInRange( static::SPECIFICATION_TAG, $tokens, $docCommentOpenerPosition, - $docCommentClosingPosition, + $apiTagPosition ?? $docCommentClosingPosition, ); if (!$specificationPosition) { return null; @@ -348,7 +349,7 @@ public function assertSpecificationFormat(File $phpCsFile, int $stackPointer): v { $tokens = $phpCsFile->getTokens(); $tokenContent = $tokens[$stackPointer]['content']; - if ($tokenContent === sprintf('%s', static::SPECIFICATION_TAG)) { + if ($tokenContent === sprintf('%s:', static::SPECIFICATION_TAG)) { return; } $this->addTypoInSpecificationTagFixableError($phpCsFile, $stackPointer);