Skip to content
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

Adds baseline and write_baseline config file options #5552

Merged
merged 5 commits into from
Jun 27, 2024

Conversation

mildm8nnered
Copy link
Collaborator

@mildm8nnered mildm8nnered commented May 1, 2024

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
Copy link

SwiftLintBot commented May 1, 2024

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

Generated by 🚫 Danger

@mildm8nnered mildm8nnered marked this pull request as ready for review May 1, 2024 17:39
@mildm8nnered mildm8nnered force-pushed the mildm8nnered-baseline-config2 branch from 1342498 to 01cc6fd Compare May 3, 2024 21:35
Copy link
Collaborator

@SimplyDanny SimplyDanny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Source/swiftlint/Helpers/LintOrAnalyzeCommand.swift Outdated Show resolved Hide resolved
@mildm8nnered
Copy link
Collaborator Author

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.

@mildm8nnered mildm8nnered force-pushed the mildm8nnered-baseline-config2 branch 2 times, most recently from 1217db3 to f97a825 Compare May 11, 2024 13:03
@mildm8nnered mildm8nnered force-pushed the mildm8nnered-baseline-config2 branch from f97a825 to e3830ca Compare June 24, 2024 08:40
CHANGELOG.md Outdated
* Adds `baseline` and `write_baseline` configuration file settings, equivalent
to the `--baseline` and `--write-baseline` command line options.
[Martin Redington](https://github.com/mildm8nnered)
[#5552](https://github.com/realm/SwiftLint/issues/5552)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be moved up into the "Main" section.

@mildm8nnered mildm8nnered force-pushed the mildm8nnered-baseline-config2 branch from 2c9e59d to a90e3c9 Compare June 26, 2024 21:58
@mildm8nnered mildm8nnered merged commit 8bed208 into realm:main Jun 27, 2024
12 checks passed
@mildm8nnered mildm8nnered deleted the mildm8nnered-baseline-config2 branch June 27, 2024 17:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants