-
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
Adds invalid swiftlint command rule #4546
Adds invalid swiftlint command rule #4546
Conversation
Generated by 🚫 Danger |
6f63adc
to
8fd470f
Compare
So I managed to work out
as I've done in Not sure what the best way is to go from here ... |
See for example |
So I guess I could special case this rule in
and rely on the handwritten test. Or I could further edit the stencil to generate the appropriate code for this case. That doesn't feel very graceful. I will also face a similar problem for #4684, so ideally any mechanism here would be easily extensible. |
Source/SwiftLintFramework/Rules/Lint/InvalidSwiftLintCommandRule.swift
Outdated
Show resolved
Hide resolved
3c1d2f3
to
9fed2a9
Compare
2a8191e
to
5656430
Compare
See also my comment at |
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.
Sorry to miss your last comment. Apart from some smaller findings, it looks good to me now.
I like that the rule itself is very easy now. Good work!
@@ -27,6 +30,8 @@ public struct Command: Equatable { | |||
case this | |||
/// The command should only apply to the line following its definition. | |||
case next | |||
/// The modifier string was invalid |
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.
Nit: In documentation, prefered style is a period at the end of sentences/descriptions.
@@ -8,13 +8,16 @@ public struct Command: Equatable { | |||
case enable | |||
/// The rule(s) associated with this command should be disabled by the SwiftLint engine. | |||
case disable | |||
/// The action string was invalid |
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.
Same here: Prefer a period at the end.
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.
There should be a rule for that :-)
…mands initializer
5656430
to
f3abe43
Compare
Merged. 😊 Thanks for all the work @mildm8nnered! |
Rule-based approach to #4543
Adds an
invalid_swiftlint_command
rule to detect malformedswiftlint
commands. Bungledenable
's in particular, after a validdisable
can lead to stretches of code going unintentionally un-linted.nonTriggeringExamples:
triggeringExamples:
Command Parsing
This PR also slightly changes the parsing of commands. Previously cases like
Would have been parsed, incorrectly, as
These cases will now be ignored, and will be warned about by this rule.