-
-
Notifications
You must be signed in to change notification settings - Fork 651
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
Lint and fix areas of templated code that are not actually executed #4202
base: main
Are you sure you want to change the base?
Lint and fix areas of templated code that are not actually executed #4202
Conversation
…ed() for multiple
This reverts commit 692e10e.
….com/barrywhart/sqlfluff into bhart-issue_4061_lint_uncovered_code
trace = tracer_probe.trace(append_to_templated=append_to_templated) | ||
print(f"Yielding trace for {trace.templated_str!r}") | ||
yield trace.raw_sliced, trace.sliced_file, trace.templated_str | ||
return |
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.
Remove this return
to enable "multi-linting"
….com/barrywhart/sqlfluff into bhart-issue_4061_lint_uncovered_code
I'm going to try and pick this work up and finish it off - that will likely involve quite a bit of rework - and I might start this as a new branch. I'll keep this open until I've ported the code across and then close this PR at that point. |
Just picking up on this for anyone watching it. Regardless of the implementation here, this feature would likely mean longer runtimes (because we end up parsing and linting multiple versions of the same file). In the best case scenario we can use the "base" variant as a hint for parsing the other versions, but it's still likely going to be longer. I'll pick this up once I've made a fair inroad into that performance frontier. |
@alanmcruickshank: A followup to your performance comment -- that is true, but we have coverage information on the rendered template and can skip the whole process of generating and linting variants if the initial rendering covered everything. So in most cases, there'll be no impact on performance. I think the draft PR does this. |
Oh, totally agree for files that are fully covered in the first pass, it's the others that will experience the slowdown |
Notes for remaining work & debugging:
LintedFile.get_violations()
and apply only those usingBaseSegment.apply_fixes()
. This will replace the current patch-based strategy.greedy_set_cover()
function here may be useful for choosing a minimum set of variants that covers as much of the raw file as possible.Tests:
==
Brief summary of the change made
Fixes #4061
Are there any other side effects of this change that we should be aware of?
Pull Request checklist
Please confirm you have completed any of the necessary steps below.
Included test cases to demonstrate any code changes, which may be one or more of the following:
.yml
rule test cases intest/fixtures/rules/std_rule_cases
..sql
/.yml
parser test cases intest/fixtures/dialects
(note YML files can be auto generated withtox -e generate-fixture-yml
).test/fixtures/linter/autofix
.Added appropriate documentation for the change.
Created GitHub issues for any relevant followup/future enhancements if appropriate.