-
-
Notifications
You must be signed in to change notification settings - Fork 741
Description
Bug Report
| Subject | Details |
|---|---|
| Rector version | 2.3.8 |
I could not find where this is done in the codebase, but it appears the deprecration messages are logged to the stdout. In and of itself, that is fine. However, if one uses --output-format=gitlab for instance, those deprecrations are part of the output that may be piped, breaking the format.
Minimal PHP Code Causing Issue
- register a deprecrated rule as a skipped rule, e.g.
withSkip([\Rector\Php81\Rector\Array_\FirstClassCallableRector::class]) - Exectued
rector process --dry-run --output-format=gitlab | jq-> jq fails because the piped output is not a JSON
When the output is not piped, we get:
$ rector process --dry-run --output-format=gitlab
[WARNING] These rules are skipped, but are deprecated. Most likely you do not need to skip them anymore as not part of
any set and remove them:
* Rector\Php81\Rector\Array_\FirstClassCallableRector
[]
[WARNING] Skipped rule "Rector\Php81\Rector\Array_\FirstClassCallableRector" is deprecated
[WARNING] This skipped rule is never registered. You can remove it from "->withSkip()"
* Rector\Php81\Rector\Array_\FirstClassCallableRectorYou can see all those plain text messages are piped too, breaking the JSON.
Expected Behaviour
I think the simplest way to go about it is to log it to the stderr, and if no stderr is available and a dedicated format output is passed, either it needs to be adjusted to that output format (I do not know if such deprecrations can be passed to the gitlab format for example) or omitted (it is a loss of information, but at least it won't crash).