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

Document-level lint exceptions do not support visitor reuse #145

Closed
peterhuene opened this issue Jul 29, 2024 · 0 comments · Fixed by #147
Closed

Document-level lint exceptions do not support visitor reuse #145

peterhuene opened this issue Jul 29, 2024 · 0 comments · Fixed by #147

Comments

@peterhuene
Copy link
Collaborator

Overview

Related to #135, currently LintVisitor mutates the list of rules on document entry by removing rules that are excepted.

This works "fine" when the visitor visits only a single document, but when the visitor is used again to visit another document, LintVisitor will start complaining about "unknown" rules because the rule was previously removed from the rule set.

This is easily reproduced from within VS Code with the Sprocket extension.

Repro Steps

  1. Open a WDL document in VS Code with the Sprocket extension running and with lints enabled.
  2. Cause a lint diagnostic to show up (line no newline at end of file).
  3. Add an #@ except for that lint rule at the top of the document.
  4. Continue editing the file.

Expected Results

The diagnostic should be continued to be ignored.

Actual Results

A new diagnostic appears for the #@ except of the rule saying the rule is unknown.

peterhuene added a commit to peterhuene/wdl that referenced this issue Jul 30, 2024
Currently `LintVisitor` will remove rules from the rule set upon document entry
when there's a "global" exception.

This works for a single document visit, but if the visitor is reused, the
subsequent visitation will treat any previously globally excepted rules as
unknown rules.

The fix is to use the `each_enabled_rule` for the `document` method so that
globally excepted rules behave like locally excepted rules and the rule set
doesn't change.

Fixes stjude-rust-labs#145.
peterhuene added a commit to peterhuene/wdl that referenced this issue Jul 30, 2024
Currently `LintVisitor` will remove rules from the rule set upon document entry
when there's a "global" exception.

This works for a single document visit, but if the visitor is reused, the
subsequent visitation will treat any previously globally excepted rules as
unknown rules.

The fix is to use the `each_enabled_rule` for the `document` method so that
globally excepted rules behave like locally excepted rules and the rule set
doesn't change.

Fixes stjude-rust-labs#145.
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 a pull request may close this issue.

1 participant