-
Notifications
You must be signed in to change notification settings - Fork 665
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow adding new errors to baseline. #5831
Comments
--set-baseline do work well even if there is already a baseline. The only thing is that the end report won't display any issues and everything is added to the baseline silently Furthermore, it's unfortunate that we have to retype the filename everytime. A --add-to-baseline that displays the list of new issues added would be wonderful |
Right, the list of new issues would be nice to paste into the PR that fixes the |
I think another good use case for adding issues to the baseline is when you want to deprecate a function that's widely used in your codebase, or if you upgrade a dependency library and the deprecates stuff that you can't immediately stop using. |
An alternative feature might be a psalter command to add in place |
@muglug any thoughts on this? Would you be interested in a PR to add this feature? |
Can you summarize what you'd want to add please? I solved my main issue with --set-baseline in the PR above but I'm not sure you explained why it this flag doesn't suit you |
Hi Orklah. I've been testing this out. Also for some reason if I do |
Mmh, possibly everything could be resolved by just allowing --set-baseline not to take a value. |
yeah that could work, although I think a dedicated command would be almost as easy to build. There's also the question of whether Psalm would want to encourage the practice of adding to baseline. Clearly open to people adding new problems to the baseline, rather than my intended use which is for old problems newly visible to Psalm. |
Implemented in #10696 |
Looks great, thanks! |
Currently psalm supports removing errors from the baseline with
--update-baseline
but I don't believe adding new errors is supported. Adding new errors is of course possible running psalm with--set-baseline=psalm-baseline.xml
but I thin that only works properly if the baseline file is deleted first, and it's a little awkward to use.Of course in general we want errors to go down not up and we don't want to introduce new buggy code into a codebase, but I think there's a fairly common scenario where adding new errors make sense.
Suppose we have a legacy codebase that looks like this - simplified for brefity:
Psalm will detect issues on the incorrectly documented getPizzaTopping function, but as this is a large legacy code base we add them to a baseline when we first start using Psalm and move on with our lives.
Some time later we decide we want to fix getPizzaTopping and correctly document it as returning
?PizzaTopping
. At that point Psalm will detect that we should have done a null check inshowTopping
and report an error there. ButshowTopping
has been in production for years and it's working fine, and there are dozens of functions like it. It isn't cost effective to fix them all now. So we probably revert the change to thegetPizzaTopping
declaration.Instead I'm proposing a feature where we would add the issues detected in
showTopping
to the baseline. We don't need to fix it since we we know it's working, but the next time we callgetPizzaTopping
Psalm will insist we do the null check where required.The text was updated successfully, but these errors were encountered: