staabm / phpstan-todo-by

Todo comments with expiration
https://staabm.github.io/2023/12/17/phpstan-todo-by-published.html
MIT License
173 stars 4 forks source link

Rule errors are reported doubly when multiple nodes reference the same comment #101

Open EmilMassey opened 2 months ago

EmilMassey commented 2 months ago

In some cases, the same expired comment is reported twice.

Version

phpstan: 1.11.5 phpstan-todo-by: 0.1.27

Code

/**
 * TODO: APP-1234 <comment>
 */
#[FirstAttribute]
#[SecondAttribute]
private string $foo;

Configuration (interesting parts)

includes:
  - vendor/staabm/phpstan-todo-by/extension.neon

parameters:
  todo_by:
    ticket:
      enabled: true
      tracker: jira
      resolvedStatuses:
        - Done
      keyPrefixes:
        - APP
      jira:
        server: https://<host>.atlassian.net
        credentialsFilePath: jira-apikey.txt

Command parameters

vendor/bin/phpstan analyse -c phpstan.neon src tests fixtures public/index.php

Output

------ ---------------------------------------------------------------------------------- 
  Line   src/File.php                                    
 ------ ---------------------------------------------------------------------------------- 
  16     Should have been resolved in APP-1234: <comment>
         💡 See https://<host>.atlassian.net/browse/APP-1234                               
  16     Should have been resolved in APP-1234: <comment>
         💡 See https://<host>.atlassian.net/browse/APP-1234                               
 ------ ---------------------------------------------------------------------------------- 

Additional Info

Collector visits two nodes in a file and both have the same comment: PhpParser\Node\Stmt\Property and PhpParser\Node\AttributeGroup - that's probably the cause

Reproducer: https://github.com/EmilMassey/phpstan-todo-by/commit/3898c039db0e345798b2339e448243fc36c41200