realm / SwiftLint

A tool to enforce Swift style and conventions.
https://realm.github.io/SwiftLint
MIT License
18.45k stars 2.2k forks source link

Fixed baseline compare issues #5605

Closed mildm8nnered closed 4 days ago

mildm8nnered commented 1 month ago

Fixes #5606 where baseline compare can produce some false alarms, because we throw away the text information from one of the baselines, but the files on disk may be absent or have changed, so the new text values read during filtering may (likely) not be appropriate.

In this PR, the logic and public API for filter is completely unchanged, but the public function converts the StyleViolations to BaselineViolations, and retrieves any existing BaselineViolations for the file.

These BaselineViolations are then passed to a private filter function, which implements the core filtering logic.

The compare function now passes the BaselineViolations from each Baseline to this private function.

We now also sort the violations reported by baseline compare, by location and rule, so the output should now be wholly deterministic which is was not quite before.

mildm8nnered commented 1 month ago

I think CI is failing here for unrelated reasons ...

SwiftLintBot commented 1 week ago
17 Messages
:book: Linting Aerial with this PR took 0.68s vs 0.65s on main (4% slower)
:book: Linting Alamofire with this PR took 0.89s vs 0.88s on main (1% slower)
:book: Linting Brave with this PR took 5.26s vs 5.51s on main (4% faster)
:book: Linting DuckDuckGo with this PR took 2.8s vs 2.94s on main (4% faster)
:book: Linting Firefox with this PR took 8.09s vs 8.0s on main (1% slower)
:book: Linting Kickstarter with this PR took 7.22s vs 7.05s on main (2% slower)
:book: Linting Moya with this PR took 0.4s vs 0.41s on main (2% faster)
:book: Linting NetNewsWire with this PR took 1.84s vs 1.84s on main (0% slower)
:book: Linting Nimble with this PR took 0.56s vs 0.57s on main (1% faster)
:book: Linting PocketCasts with this PR took 6.06s vs 6.26s on main (3% faster)
:book: Linting Quick with this PR took 0.33s vs 0.34s on main (2% faster)
:book: Linting Realm with this PR took 3.42s vs 3.53s on main (3% faster)
:book: Linting Sourcery with this PR took 1.7s vs 1.73s on main (1% faster)
:book: Linting Swift with this PR took 3.16s vs 3.11s on main (1% slower)
:book: Linting VLC with this PR took 0.93s vs 0.89s on main (4% slower)
:book: Linting Wire with this PR took 11.85s vs 12.52s on main (5% faster)
:book: Linting WordPress with this PR took 8.89s vs 9.03s on main (1% faster)

Generated by :no_entry_sign: Danger

mildm8nnered commented 1 week ago

Should we have another test that checks if outputs are sorted?

I've updated the test so that there are multiple violations in the output of compare, and I'm passing the initial violations in in reverse order, to verify the sorting of the output.