Skip to content

Commit a05efc0

Browse files
add content for quick fix section of the documentation
1 parent c68618c commit a05efc0

10 files changed

+217
-0
lines changed
49 KB
Loading
60.8 KB
Loading
65.3 KB
Loading
44.7 KB
Loading
51.1 KB
Loading
86.8 KB
Loading
75 KB
Loading
66.4 KB
Loading
78.8 KB
Loading

docs/src/content/docs/tools/vscode/quick-fixes.mdx

Lines changed: 217 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,220 @@ sidebar:
55
order: 40
66
---
77

8+
Quick fixes are context-aware suggestions for resolving problems reported by dbLinter, eliminating the need to search for solutions manually.
9+
10+
## Single Problem
11+
12+
The first three options in the quick fix pop-up window are solutions to the problem on line 8, column 8.
13+
14+
![Single Problem](../../../../assets/images/vscode/vscode-quick-fix-single-problem.png)
15+
16+
The `Replace nvl with coalesce.` option produces the following result:
17+
18+
![Fixed one Problem](../../../../assets/images/vscode/vscode-quick-fix-single-problem-applied.png)
19+
20+
## All Problems of One Rule
21+
22+
Rather than fixing one problem at a time, you can select the option `Fix all <rule> problems like ...` to fix all problems for one rule in one go.
23+
24+
This option is only available if multiple problems have been reported for a rule in a file.
25+
26+
![Fixed All Problems of One Rule](../../../../assets/images/vscode/vscode-quick-fix-all-problems-of-one-rule.png)
27+
28+
The `Fix all G-2180 problems like 'Replace with unquoted identifier.'` option produces the following result:
29+
30+
![Fixed All Problems of One Rule](../../../../assets/images/vscode/vscode-quick-fix-all-problems-of-one-rule-applied.png)
31+
32+
## Fix All Problems
33+
34+
From the quick fix pop-up window, you can select the `Fix all problems` option.
35+
This option is available in every editor position if there are any quick fixes that can be safely applied to the file.
36+
37+
![Fixed All Problems of One Rule](../../../../assets/images/vscode/vscode-quick-fix-all-problems.png)
38+
39+
The `Fix all problems.` option produces the following result:
40+
41+
![Fixed All Problems of One Rule](../../../../assets/images/vscode/vscode-quick-fix-all-problems-applied.png)
42+
43+
## @dbLinter Ignore Marker Comment
44+
45+
If you are unable to fix a problem or choose not to, you can add a `@dbLinter ignore` marker to indicate that the problem is being intentionally accepted.
46+
This avoids making unnecessary or unsafe changes and keeps the linting output meaningful rather than noisy.
47+
48+
### Syntax
49+
50+
The @dbLinter maker comment must be placed within a single-line or multiline comment, and is case-insensitive.
51+
52+
```text
53+
@DBLINTER IGNORE(rule1 [, rule2]...) [comment]
54+
```
55+
56+
The syntax of a rule is as follows:
57+
58+
```text
59+
[tenantName] ruleName
60+
```
61+
62+
If you omit the `tenantName`, the `ruleName` is expected to exist in the `Core` tenant.
63+
64+
### Scope
65+
66+
If the dbLinter marker comment is not the first token on a line, the scope is limited to that line only.
67+
68+
If the dbLinter marker comment is the first token on a line, the scope is determined by the most inner IslandSQL parser rule context that fully contains the comment.
69+
The following IslandSQL parser rules are considered:
70+
71+
- [statement](https://islandsql.github.io/IslandSQL/grammar.html#statement)
72+
- [functionDefinition](https://islandsql.github.io/IslandSQL/grammar.html#functionDefinition)
73+
- [procedureDefinition](https://islandsql.github.io/IslandSQL/grammar.html#procedureDefinition)
74+
- [constructorDeclaration](https://islandsql.github.io/IslandSQL/grammar.html#constructorDeclaration)
75+
- [funcDeclInType](https://islandsql.github.io/IslandSQL/grammar.html#funcDeclInType)
76+
- [procDeclInType](https://islandsql.github.io/IslandSQL/grammar.html#procDeclInType)
77+
78+
The scope is the whole file if the dbLinter marker comment is placed before the first visible IslandSQL parser token.
79+
80+
### Examples
81+
82+
The scope of the dbLinter marker comment is visualised using highlighted lines in the examples below.
83+
84+
```sql {6} title="Scope: Single-Line"
85+
declare
86+
l_var1 integer;
87+
procedure proc1 is
88+
l_var2 integer;
89+
procedure proc2 is
90+
l_var3 integer; -- @dbLinter ignore(G-1030)
91+
l_var4 integer;
92+
begin
93+
null;
94+
end;
95+
begin
96+
proc2;
97+
end;
98+
begin
99+
proc1;
100+
end;
101+
/
102+
```
103+
104+
```sql {5-11} title="Scope: Procedure proc2"
105+
declare
106+
l_var1 integer;
107+
procedure proc1 is
108+
l_var2 integer;
109+
procedure proc2 is
110+
-- @dbLinter ignore(G-1030, G-7120)
111+
l_var3 integer;
112+
l_var4 integer;
113+
begin
114+
null;
115+
end;
116+
begin
117+
proc2;
118+
end;
119+
begin
120+
proc1;
121+
end;
122+
/
123+
```
124+
125+
```sql {3-14} title="Scope: Procedure proc1"
126+
declare
127+
l_var1 integer;
128+
procedure proc1 is
129+
-- @dbLinter ignore(G-1030, G-7120)
130+
l_var2 integer;
131+
procedure proc2 is
132+
l_var3 integer;
133+
l_var4 integer;
134+
begin
135+
null;
136+
end;
137+
begin
138+
proc2;
139+
end;
140+
begin
141+
proc1;
142+
end;
143+
/
144+
```
145+
146+
```sql {1-17} title="Scope: Anonymous PL/SQL Block"
147+
declare
148+
-- @dbLinter ignore(G-1030, G-7120)
149+
l_var1 integer;
150+
procedure proc1 is
151+
l_var2 integer;
152+
procedure proc2 is
153+
l_var3 integer;
154+
l_var4 integer;
155+
begin
156+
null;
157+
end;
158+
begin
159+
proc2;
160+
end;
161+
begin
162+
proc1;
163+
end;
164+
/
165+
```
166+
167+
```sql {1-18} title="Scope: File"
168+
-- @dbLinter ignore(G-1030, G-7120)
169+
declare
170+
l_var1 integer;
171+
procedure proc1 is
172+
l_var2 integer;
173+
procedure proc2 is
174+
l_var3 integer;
175+
l_var4 integer;
176+
begin
177+
null;
178+
end;
179+
begin
180+
proc2;
181+
end;
182+
begin
183+
proc1;
184+
end;
185+
/
186+
```
187+
188+
## AI Fixes
189+
190+
The screenshot in [Single Problem](#single-problem) shows the two options, `Fix` and `Explain`, provided by the Copilot extension in VS Code.
191+
If you have set up an AI agent in VS Code, you will also have access to these options in your installation.
192+
193+
The next screenshot shows a violation of rule [G-3185: Never use ROWNUM at the same query level as ORDER BY](https://dblinter.app/ords/r/dblinter/dblinter-console/rules#P1000_SHOW_RULE=core%20g-3185).
194+
In this case, dbLinter does not provide a quick fix. However, the AI agent can suggest code fixes based on the information it receives.
195+
In other words, the context. For example, this is:
196+
197+
- The content in the editor.
198+
- The name and description of the violated rule.
199+
- The exact position of the rule violation in the editor.
200+
- Additional information about this rule available on the internet.
201+
202+
![AI Fix](../../../../assets/images/vscode/vscode-quick-fix-ai-fix.png)
203+
204+
In this case, the AI agent is Copilot, which is configured to use the GPT-4.1 model.
205+
The following code change is proposed:
206+
207+
![AI Suggestion](../../../../assets/images/vscode/vscode-quick-fix-ai-fix-suggestion.png)
208+
209+
After accepting the proposal, the editor content looks similar to the following:
210+
211+
![AI Suggestion Applied](../../../../assets/images/vscode/vscode-quick-fix-ai-fix-suggestion-applied.png)
212+
213+
The code violation has now been resolved, meaning the query produces the correct result.
214+
215+
However, you cannot be sure that the result is correct.
216+
Why? Because the result is not deterministic.
217+
Even with this simple example, we have experienced different results in the past.
218+
Some were correct and some were wrong. Therefore, you should always check the result produced by the AI agent.
219+
220+
In any case, the provided solution is not the best option.
221+
A modern solution would use the [row_limiting_clause](https://docs.oracle.com/en/database/oracle/oracle-database/26/sqlrf/SELECT.html#GUID-CFA006CA-6FF1-4972-821E-6996142A51C6__BABBADDD), which was introduced with the Oracle Database 12c.
222+
as shown in the second solution of [G-3185](https://dblinter.app/ords/r/dblinter/dblinter-console/rules#P1000_SHOW_RULE=core%20g-3185).
223+
224+
That said, the fixes proposed by the AI agent are powerful and useful when a dbLinter quick fix is unavailable.

0 commit comments

Comments
 (0)