realm / SwiftLint

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

Adds `baseline` and `write_baseline` config file options #5552

Closed mildm8nnered closed 1 week ago

mildm8nnered commented 2 months ago

So baselines can be used by people who can't pass command line arguments (e.g. plugin users).

baseline and write_baseline - these behave exactly the same way as their command line equivalents. The command line will take preference if there is a conflict, but there is not way to "unset" the config file entries from the command line - if there is a baseline config file entry, you can override it to be a different value, but there is no way to tell SwiftLint "don't read a baseline at all".

This is very similar to the PR from a while ago adding a strict config option - #5226

SwiftLintBot commented 2 months ago
17 Messages
:book: Linting Aerial with this PR took 1.03s vs 0.99s on main (4% slower)
:book: Linting Alamofire with this PR took 1.38s vs 1.37s on main (0% slower)
:book: Linting Brave with this PR took 8.01s vs 8.09s on main (0% faster)
:book: Linting DuckDuckGo with this PR took 4.39s vs 4.45s on main (1% faster)
:book: Linting Firefox with this PR took 11.33s vs 11.42s on main (0% faster)
:book: Linting Kickstarter with this PR took 10.14s vs 10.15s on main (0% faster)
:book: Linting Moya with this PR took 0.55s vs 0.56s on main (1% faster)
:book: Linting NetNewsWire with this PR took 2.77s vs 2.78s on main (0% faster)
:book: Linting Nimble with this PR took 0.81s vs 0.82s on main (1% faster)
:book: Linting PocketCasts with this PR took 8.77s vs 8.68s on main (1% slower)
:book: Linting Quick with this PR took 0.45s vs 0.45s on main (0% slower)
:book: Linting Realm with this PR took 5.01s vs 5.19s on main (3% faster)
:book: Linting Sourcery with this PR took 2.51s vs 2.53s on main (0% faster)
:book: Linting Swift with this PR took 4.9s vs 4.95s on main (1% faster)
:book: Linting VLC with this PR took 1.33s vs 1.34s on main (0% faster)
:book: Linting Wire with this PR took 19.21s vs 19.31s on main (0% faster)
:book: Linting WordPress with this PR took 14.21s vs 14.29s on main (0% faster)

Generated by :no_entry_sign: Danger

mildm8nnered commented 2 months ago

Is write_baseline really useful to have in the configuration? That would mean every new violation is directly added to the baseline. But new appearing violations should rather be fixed.

So I don't expect it to get that much use, but I could see a few possible use cases.

If you want to generate the Baselines in your CI environment, and can't pass command line options, then this would let you do so without having to reconstruct that environment locally. I could imagine people having a monthly or even yearly job for this.

If you wanted to track whether existing violations were getting fixed, you could write out a baseline for the build, and then use swiftlint baseline compare against the main baseline to detect fixed violations.