feat: auto-fix naked identifiers when prefer_quoted_identifiers is enabled (RF06)#2599
feat: auto-fix naked identifiers when prefer_quoted_identifiers is enabled (RF06)#2599
Conversation
Agent-Logs-Url: https://github.com/quarylabs/sqruff/sessions/fd222748-b66f-484d-aa33-1d53a0ca0ebc Co-authored-by: gvozdvmozgu <131762131+gvozdvmozgu@users.noreply.github.com>
Benchmark for 9cee641Click to view benchmark
|
Merging this PR will not alter performance
Comparing Footnotes
|
There was a problem hiding this comment.
Pull request overview
This PR enables auto-fixing for rule RF06 (references.quoting) when prefer_quoted_identifiers = true by generating replacement segments that wrap naked identifiers in dialect-appropriate quotes. It also updates the RF06 fixture cases to assert the new fixes and removes outdated documentation stating the mode isn’t fix-compatible.
Changes:
- Add a
LintFix::replacefor theprefer_quoted_identifiersbranch in RF06 to quoteNakedIdentifiersegments. - Introduce helper functions to choose quote characters by dialect and build a
QuotedIdentifiersegment. - Update RF06 YAML fixtures with
fix_strfor previously unfixable cases and remove the “not fix compatible” note from the docs.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| docs/reference/rules.md | Removes outdated note claiming prefer_quoted_identifiers mode is not fix-compatible. |
| crates/lib/test/fixtures/rules/std_rule_cases/RF06.yml | Adds expected fix_str outputs for prefer_quoted_identifiers failures (ANSI/TSQL/BigQuery). |
| crates/lib/src/rules/references/rf06.rs | Implements fixes for naked identifiers under prefer_quoted_identifiers and adds dialect quote helpers. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Agent-Logs-Url: https://github.com/quarylabs/sqruff/sessions/b9828a84-22c4-46a5-8e5b-1ba6873457a7 Co-authored-by: gvozdvmozgu <131762131+gvozdvmozgu@users.noreply.github.com>
Benchmark for daeb214Click to view benchmark
|
Rule RF06 (
references.quoting) could detect unquoted identifiers whenprefer_quoted_identifiers = truebut couldn't fix them — the violations were reported with an empty fix list.Changes
rf06.rs: AddedLintFix::replacein theprefer_quoted_identifiersbranch, wrappingNakedIdentifiersegments in dialect-appropriate quotes via two new helpers:identifier_quote_chars(dialect)— maps dialect →(open, close)quote pairmake_quoted_identifier(dialect, contents, id)— builds theQuotedIdentifiersegmentRF06.yml: Addedfix_strto all 9 previously unfixabletest_fail_*_prefer_quoted_*casesQuote character mapping
name"name"name[name]name`name`Example