You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Fix all parsing warnings & errors in rule examples #3348
enhancementIdeas for improvements of existing features and rules.good first issueIssue to be taken up by new contributors yet unfamiliar with the project.
Many rule examples are very succinct, focusing just on the syntax that is meant to be linted/corrected. For example: if foo == nil. However, this doesn't parse successfully:
In an upcoming PR, I'll want to introduce a change to avoid correcting files if they have parser errors or warnings, since SwiftLint isn't designed to handle all possibilities of invalid Swift code. Generally, it's still useful for SwiftLint to lint Swift files that don't parse 100% cleanly as a feedback mechanism, but we shouldn't attempt to correct files with violations that don't parse cleanly, because that can mangle or delete code in unintended ways.
Because there are currently over 500 rule examples with parser diagnostics, I don't have time to fix all of them, but we probably should do that eventually.
This is a good starter task if someone's interested in contributing to SwiftLint.
Generally, it's still useful for SwiftLint to lint Swift files that don't parse 100% cleanly
What is the reasoning behind this? And does this mean that just SwiftLint should be able to handle invalid code or does this apply for the examples as well. Maybe we could introduce a mechanism to parse all examples and check if there are any parse errors (maybe directly in the Exampleinit method). That way we could make sure all examples are valid while still allowing invalid code to go through SwiftLint.
I think there is not much value in fixing all those parse errors now, without a way to enforcing examples to be valid. If we don’t enforce it, then we would end up in the same situation again after a while, because examples are added or get modified and might become invalid again.
enhancementIdeas for improvements of existing features and rules.good first issueIssue to be taken up by new contributors yet unfamiliar with the project.
Activity
lo1tuma commentedon Feb 17, 2023
What is the reasoning behind this? And does this mean that just
SwiftLintshould be able to handle invalid code or does this apply for the examples as well. Maybe we could introduce a mechanism to parse all examples and check if there are any parse errors (maybe directly in theExampleinitmethod). That way we could make sure all examples are valid while still allowing invalid code to go throughSwiftLint.I think there is not much value in fixing all those parse errors now, without a way to enforcing examples to be valid. If we don’t enforce it, then we would end up in the same situation again after a while, because examples are added or get modified and might become invalid again.
Migrate `protocol_property_accessors_order` examples to `#example`
Migrate `protocol_property_accessors_order` examples to `#example`