Skip to content

CLI option to remove unmatched errors from baseline #3458

@hkdobrev

Description

@hkdobrev

Feature request

Since PHPStan 0.12.18, there is a dedicated CLI option for regenerating the baseline file --generate-baseline.

When using it, it would do 2 things from user perspective:

  1. Any new errors that are reported would be ignored
  2. Any existing ignore rules which are no longer matching would be cleaned up

I'm suggesting another option which would only do the second. This option would just remove rules from the baseline that are not matching, but continue to report new errors.

This is useful in a very key scenario - you have a codebase where there are a lot of ignored errors, but you want to enforce stricter rules for any new code. When you use the baseline for that, you end up with a lot of ignored errors in the baseline. With refactoring, a lot of those would be reported as unmatched rules which is great and you'd clean those up. But if at the same time there are new errors, you would assimilate them in the baseline and ignore them instead of fixing them.

With this option a more automated process could be introduced where no longer matching rules are automatically or semi-automatically cleaned up from the baseline. It will also ensure a more stable usage of regenerating the baseline where people would more explicitly ignore actual errors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions