Skip to content

Lint pipeline improvements; fix enabling/disabling of lint rules. #16

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

Merged
merged 3 commits into from
Jul 23, 2019

Conversation

allevato
Copy link
Member

Have lint rules extend SyntaxVisitorBase and make them classes again
instead of using the visitor protocol.

RuleMask previously only kept track of rule disablement, assuming that
any range where a rule was not disabled should have it enabled. This
isn't quite correct; it's actually a tri-state of enabled, disabled, and
whatever-is-in-the-configuration.

With these changes, rule enablement/disablement is now handled in the
lint pipeline (format pipeline coming later), not in individual rules.
(This will also be refined later, because some individual rules do
need finer control over that check.)

Fixes SR-11114.

allevato added 3 commits July 22, 2019 12:32
In an older version of SwiftSyntax, SyntaxVisitor was a class and thus
the lint rules were as well. When SwiftSyntax changed SyntaxVisitor to be
a protocol with mutating methods, we lost the ability to treat the rules
polymorphically in certain situations due to Swift language limitations.

Now that SwiftSyntax generates a class version of SyntaxVisitor, we can
bring that old design back.
RuleMask previously only kept track of rule disablement, assuming that
any range where a rule was not disabled should have it enabled. This
isn't quite correct; it's actually a tri-state of enabled, disabled, and
whatever-is-in-the-configuration.

With these changes, rule enablement/disablement is now handled in the
lint pipeline (format pipeline coming later), not in individual rules.
(This will actually be refined later, because some individual rules do
need finer control over that check.)

Fixes SR-11114.
@allevato allevato requested a review from akyrtzi July 23, 2019 18:38
@allevato allevato merged commit 5652419 into swiftlang:master Jul 23, 2019
@allevato allevato deleted the pipeline branch July 23, 2019 18:50
allevato added a commit to allevato/swift-format that referenced this pull request Jul 23, 2019
This mostly completes what was started in
swiftlang#16, except for the part
about giving certain rules finer control than just detection based
on the line number of the node being visited.

Fixes SR-11114.
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.

2 participants