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

Add validation hook to configuration parsing #5824

Merged
merged 1 commit into from
Oct 17, 2024

Conversation

SimplyDanny
Copy link
Collaborator

No description provided.

@SwiftLintBot
Copy link

SwiftLintBot commented Oct 13, 2024

1 Warning
⚠️ If this is a user-facing change, please include a CHANGELOG entry to credit yourself!
You can find it at CHANGELOG.md.
17 Messages
📖 Linting Aerial with this PR took 0.92s vs 0.93s on main (1% faster)
📖 Linting Alamofire with this PR took 1.25s vs 1.27s on main (1% faster)
📖 Linting Brave with this PR took 7.17s vs 7.24s on main (0% faster)
📖 Linting DuckDuckGo with this PR took 4.97s vs 5.03s on main (1% faster)
📖 Linting Firefox with this PR took 10.44s vs 10.52s on main (0% faster)
📖 Linting Kickstarter with this PR took 9.78s vs 9.87s on main (0% faster)
📖 Linting Moya with this PR took 0.53s vs 0.54s on main (1% faster)
📖 Linting NetNewsWire with this PR took 2.61s vs 2.63s on main (0% faster)
📖 Linting Nimble with this PR took 0.77s vs 0.78s on main (1% faster)
📖 Linting PocketCasts with this PR took 8.37s vs 8.5s on main (1% faster)
📖 Linting Quick with this PR took 0.44s vs 0.45s on main (2% faster)
📖 Linting Realm with this PR took 4.5s vs 4.52s on main (0% faster)
📖 Linting Sourcery with this PR took 2.3s vs 2.31s on main (0% faster)
📖 Linting Swift with this PR took 4.48s vs 4.5s on main (0% faster)
📖 Linting VLC with this PR took 1.24s vs 1.25s on main (0% faster)
📖 Linting Wire with this PR took 17.33s vs 17.42s on main (0% faster)
📖 Linting WordPress with this PR took 11.46s vs 11.61s on main (1% faster)

Here's an example of your CHANGELOG entry:

* Add validation hook to configuration parsing.  
  [SimplyDanny](https://github.com/SimplyDanny)
  [#issue_number](https://github.com/realm/SwiftLint/issues/issue_number)

note: There are two invisible spaces after the entry's text.

Generated by 🚫 Danger

@SimplyDanny
Copy link
Collaborator Author

@mildm8nnered, could you have a look?

@@ -3,7 +3,7 @@ import Foundation
/// All possible SwiftLint issues which are printed as warnings by default.
public enum Issue: LocalizedError, Equatable {
/// The configuration didn't match internal expectations.
case invalidConfiguration(ruleID: String)
case invalidConfiguration(ruleID: String, message: String? = nil)
Copy link
Collaborator

@mildm8nnered mildm8nnered Oct 17, 2024

Choose a reason for hiding this comment

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

I wonder if we could help the reader more with distinguishing between invalid rule configurations, and invalid swiftlint configurations (if you consider those to be different things) - invalidRuleConfiguration although I guess that is implied by ruleID). There are some other issues where we could also make that distinction if we wanted to.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Absolutely, I'm always a fan of tools providing clear feedback. This one can only be used inside of rules due to the ruleID parameter which is not otherwise available.

@mildm8nnered
Copy link
Collaborator

Might be good to include an "example" implementation of validate for an actual rule ...

@SimplyDanny
Copy link
Collaborator Author

Might be good to include an "example" implementation of validate for an actual rule ...

#5781 is going to be the first candidate.

@SimplyDanny SimplyDanny merged commit 7385bea into realm:main Oct 17, 2024
14 checks passed
@SimplyDanny SimplyDanny deleted the validate-configs branch October 17, 2024 21:13
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.

3 participants