Commit 7f100df
authored
Fix: fix off-by-one error in ast-grep parsing: convert 0-indexed line/column numbers to 1-indexed (#2738)
Fixes #2737
`ast-grep` uses 0-based indices in its file + column output. However,
qlty expects 1-based indexes. This was leading to off-by-one errors. The
trufflehog parser shows how to implement this correctly by adding one to
everything. This also fixes another issue where invalid columns (0)
would cause the `snippet` not to show in the output, as can be seen in
the jest snapshot diff below.
This bug was leading to pretty critical lint issues not being caught at
work :(
This PR fixes the appropriate part of the code and updates the tests.
The `jest` snapshot / integration test below didn't have a snippet prior
to the fix because `0` is not considered a valid column. So this also
fixes that bug as well :)1 parent 663aded commit 7f100df
File tree
2 files changed
+49
-10
lines changed- qlty-check/src/parser
- qlty-plugins/plugins/linters/ast-grep/fixtures/__snapshots__
2 files changed
+49
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
67 | 69 | | |
68 | 70 | | |
69 | 71 | | |
| |||
104 | 106 | | |
105 | 107 | | |
106 | 108 | | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
107 | 143 | | |
108 | 144 | | |
109 | 145 | | |
| |||
210 | 246 | | |
211 | 247 | | |
212 | 248 | | |
213 | | - | |
214 | | - | |
215 | | - | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
216 | 253 | | |
217 | 254 | | |
218 | 255 | | |
Lines changed: 5 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | | - | |
14 | | - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| 21 | + | |
20 | 22 | | |
21 | 23 | | |
22 | 24 | | |
| |||
0 commit comments