-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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 syntax to swiftlint_version to allow for specifying minimum and maximum versions #5694
base: main
Are you sure you want to change the base?
Conversation
4f1c1f6
to
fe70e91
Compare
Generated by 🚫 Danger |
c040424
to
8f9d14d
Compare
@SimplyDanny @mildm8nnered if you could take a look at this when you get a chance, thanks! |
I see where you are coming from and why this would help, yet I was wondering whether a new separate key is really the way to go. The list is continuously growing and there is the problem of conflicting options. What about What I was thinking about is an extension of |
Yeah I think I actually like that better, what're your thoughts on syntax? I kinda like Dart's. Traditional and caret. Then if we can't parse, just throw a fatal error. Plus |
Also what's the minimum version of macOS that SwiftLint supports? Would love to use new SwiftRegex but it's macOS 13 or newer only |
SwiftLint still supports macOS 12. We'd need good reasons to change that. While I fancy as well with SwiftRegex, it's not enough reason to change the minimum deployment version. But that might change when macOS 15 is out. About the syntax: I personally don't like the caret style so much. Only the three variants
seem to be enough. There is no good reason for |
In practice I’m guessing the less than or inclusive versions wouldn’t actually be used much (I doubt we ever will), but doesn’t seem like that much more work so might as well just do it while I’m in there. I’m fine with omitting caret syntax |
In your implementation it could be helpful to know that |
8f9d14d
to
3985b2a
Compare
88111b9
to
28e4bd4
Compare
@SimplyDanny updated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good starting point! Please also add some tests for all the cases.
// make sure the remaining string is just a version string of numeral.numeral.numeral | ||
versionString = versionString.trimmingCharacters(in: .whitespacesAndNewlines) | ||
guard versionString.range(of: #"^\d+\.\d+\.\d+$"#, options: .regularExpression) != nil else { | ||
showInvalidVersionStringError() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be more specific for the error case of an invalid version number format.
4682673
to
8bddfbe
Compare
@SimplyDanny how do you suggest I approach tests on this? AFAIK, XCTest can't handle pulling out info from stdout nor can it intercept calls to |
8bddfbe
to
5908cde
Compare
@SimplyDanny just seeing if you had any thoughts on this. Apologies for the follow up, this is just rapidly causing chaos amongst our 9000 internal branches (which is a whole separate issue but) |
) | ||
} | ||
|
||
func compareVersionString(_ versionString: String) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if "version constraint" should be a struct that implements the comparison logic. At least this struct can be tested then.
|
||
// make sure the remaining string is just a version string of numeral.numeral.numeral | ||
versionString = versionString.trimmingCharacters(in: .whitespacesAndNewlines) | ||
guard versionString.range(of: #"^\d+\.\d+\.\d+$"#, options: .regularExpression) != nil else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feels like the Version
initializer should check this.
1ddd4fe
to
8667ecb
Compare
8667ecb
to
c1164c2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some more style issues ...
@SimplyDanny yeah sorry I pushed a bunch of stuff earlier then got distracted with some fires at work, I was working on refactoring into a struct anyways |
Currently, the configuration supports a
swiftlint_version
option. This option does not work for our workflow because we have many branches that may not be up to date with main/master. However, there are breaking changes that occur in SwiftLint, such asredundant_optional_initialization
changing between 0.53.0 and 0.55.1, causing our team to not have consistency in their linting.This adds new syntax to
swiftlint_version
that will compare to the current version installed and throw a warning/error if the installed version does not match the pattern the user specifiedThe syntax is as follows: