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

expire by version #6

Closed staabm closed 9 months ago

staabm commented 9 months ago

if the extension is running in a app which is git versioned, we may be able to find out, what the current and next version is, and therefore allow a variation of the rule, which invalidates comments by a version number instead of a date

Sometimes you just do workarounds until the next minor/major version is released with some needed changes.

needs a POC

similar to the todo_while macro in https://github.com/parker-codes/todo_by

Wirone commented 9 months ago

It's a bit tricky, because versioning can be strictly Git-based (without any version string in the code), and I am not sure if PHPStan should be aware of it (especially that in CI it can be run in detached state). Also, these kind of errors should be reported before the release, so I am not sure how it could be handled to be really helpful - personally I wouldn't want the scenario where I tag the release and pipeline fails because of some comment was triggered after the release 😉.

staabm commented 9 months ago

yeah, we would need some kind of next version prediction

heiglandreas commented 9 months ago

I often encounter todos like "do X after next release" or "after x is merged" to make sure that internal dependencies are met.

I often encounter these todos long after the requirement has been fulfilled as no one actually looked through these comments.

So having a rule that would trigger on such rules would indeed be helpful.

Regarding the versions: There could always be a config file that needs to be adapted manually (or via a build process) when creating a new version (whichever that is).

Similar possibly for merging branches or [PM]Rs...

Wirone commented 9 months ago

Configurable list of regexes that should trigger the error would be enough, I think 🤔.

staabm commented 9 months ago

I think the actual problem is to know when we want the errors to trigger.

e.g. if I put a // todo X after next release into the source, it should not error immediately, but after/right before the event happened.

staabm commented 9 months ago

In https://github.com/staabm/phpstan-todo-by/pull/10 I have implemented a idea, which allows you to define the reference time. That way you can e.g. use a env var to see expired comments in DEV earlier

staabm commented 9 months ago

hey guys,

in https://github.com/staabm/phpstan-todo-by/pull/12 I have implemented a "todo-by-version" rule. its released with https://github.com/staabm/phpstan-todo-by/releases/tag/0.1.7 - please give it a try.

see the projects README

feedback would be awesome.

github-actions[bot] commented 8 months ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.