Repository navigation
Make unmatched ignoreErrors entries and too high counts fixable - #6906
Merged
Merged
Conversation
…solver So that other code than ResultCacheManager can tell whether a file belongs to a package Composer installed. Amp-Thread-ID: https://ampcode.com/threads/T-01a19bac-7181-7568-be9c-c7ec28db8ebc
ignore.unmatched removes the entry from the config file, or only the message or identifier from a list like `messages` when it has other items. ignore.count lowers the count when the error occurred fewer times. A higher count is not fixed, it would ignore more errors - that is what --generate-baseline is for. The entry is looked for in the whole config cascade except for files of installed Composer packages. Only PHP config files, like PHP baselines, are fixed so far. A fix edits the source range of the parsed node and its diff covers only the changed lines. Printing the whole file for every fix took 4.4 s per error on the 31k entries of a WordPress baseline, now it takes under a millisecond. Amp-Thread-ID: https://ampcode.com/threads/T-01a19bac-7181-7568-be9c-c7ec28db8ebc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Continues #6902.
--fixnow fixes two errors aboutignoreErrorsentries in config files:ignore.unmatchedremoves the entry. When it matched through a list likemessagesoridentifiersthat has other items, only that item is removed.ignore.countlowers the count when the error occurred fewer times than the entry says. A count lower than the occurrences is not fixed, it would ignore more errors - that is what--generate-baselineis for.Where the entry is looked for
allConfigFiles), except files of installed Composer packages. The check moved fromResultCacheManagertoPackageDependencyResolver::isFileOfInstalledPackage(); packages from path repositories are still treated as the project's own code.Performance
The first version used the format-preserving printer for every fix. On a WordPress level 10 baseline (31k entries, 186k lines) that took 4.4 s per error: cloning the AST and printing the whole file. Now the file is parsed once, a fix edits the source range of the node, and its diff covers only the changed lines, which is all
Patcherreads. With 1,863 broken entries in that baseline, every fix takes under 1 ms and--fixfinished in 28 s; the fixed baseline equals the original minus the broken entries.The parse is lazy, but it happens on every run that reports one of these errors: about 1.5 s for the 7 MB WordPress baseline.
Removing the last items of a list
Removing an item rewrites the whole list, so removals of two items of one list conflict and go in separate rounds. Otherwise all items could be removed in one round, leaving an invalid
'messages' => [].Tests:
IgnoreErrorsConfigFixerTestapplies the diffs throughPatcher, and a newe2e/fix-baselinetest checks the fixed baseline file, that entries in NEON and invendor/stay, and that--fix --generate-baselineis rejected.