Commit 497d425
committed
Add
Summary
--
This PR is stacked on #19608 and of more dubious value. It bothered me to see
that `Candidate::into_diagnostic` and `Candidate::report_diagnostic` were
essentially the same, differing only in taking a `LintContext` instead of a
`Checker`. This was also the only reason we needed to collect a `Vec` of
`Candidate`s in `ambiguous_unicode_character` instead of reporting them
directly.
This PR fixes those two concerns, but at the cost of introducing a trait
implemented by `LintContext` and `Checker`. I'm leaning towards it not being
worth it, unless we think the trait will be useful elsewhere.
If we do want to keep the trait, we could obviously move `report_diagnostic`
into it and move the actual implementations into the trait impls. I held off
doing that for now to avoid a big import diff, especially if we didn't want this
change at all.
Test Plan
--
Existing testsDiagnosticReporter trait, deduplicate Unicode checks1 parent 01361d6 commit 497d425
File tree
2 files changed
+67
-65
lines changed- crates/ruff_linter/src
- checkers/ast
- rules/ruff/rules
2 files changed
+67
-65
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3326 | 3326 | | |
3327 | 3327 | | |
3328 | 3328 | | |
| 3329 | + | |
| 3330 | + | |
| 3331 | + | |
| 3332 | + | |
| 3333 | + | |
| 3334 | + | |
| 3335 | + | |
| 3336 | + | |
| 3337 | + | |
| 3338 | + | |
| 3339 | + | |
| 3340 | + | |
| 3341 | + | |
| 3342 | + | |
| 3343 | + | |
| 3344 | + | |
| 3345 | + | |
| 3346 | + | |
| 3347 | + | |
| 3348 | + | |
| 3349 | + | |
| 3350 | + | |
| 3351 | + | |
| 3352 | + | |
| 3353 | + | |
| 3354 | + | |
| 3355 | + | |
| 3356 | + | |
| 3357 | + | |
| 3358 | + | |
| 3359 | + | |
| 3360 | + | |
| 3361 | + | |
Lines changed: 34 additions & 65 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
180 | 181 | | |
181 | 182 | | |
182 | 183 | | |
183 | | - | |
184 | | - | |
185 | | - | |
| 184 | + | |
186 | 185 | | |
187 | 186 | | |
188 | 187 | | |
| |||
203 | 202 | | |
204 | 203 | | |
205 | 204 | | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
211 | 212 | | |
212 | 213 | | |
213 | 214 | | |
214 | 215 | | |
215 | 216 | | |
216 | 217 | | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
222 | 225 | | |
223 | 226 | | |
224 | 227 | | |
225 | 228 | | |
226 | 229 | | |
227 | 230 | | |
228 | | - | |
| 231 | + | |
229 | 232 | | |
230 | 233 | | |
231 | 234 | | |
232 | | - | |
233 | | - | |
234 | | - | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
235 | 238 | | |
236 | 239 | | |
237 | | - | |
| 240 | + | |
238 | 241 | | |
239 | 242 | | |
240 | 243 | | |
| |||
246 | 249 | | |
247 | 250 | | |
248 | 251 | | |
249 | | - | |
| 252 | + | |
250 | 253 | | |
251 | 254 | | |
252 | 255 | | |
| |||
264 | 267 | | |
265 | 268 | | |
266 | 269 | | |
267 | | - | |
| 270 | + | |
268 | 271 | | |
269 | 272 | | |
270 | 273 | | |
| |||
289 | 292 | | |
290 | 293 | | |
291 | 294 | | |
292 | | - | |
| 295 | + | |
293 | 296 | | |
294 | 297 | | |
295 | 298 | | |
296 | 299 | | |
297 | | - | |
298 | | - | |
299 | 300 | | |
300 | 301 | | |
301 | 302 | | |
| |||
341 | 342 | | |
342 | 343 | | |
343 | 344 | | |
344 | | - | |
345 | | - | |
346 | | - | |
347 | | - | |
348 | | - | |
349 | | - | |
350 | | - | |
351 | | - | |
352 | | - | |
353 | | - | |
354 | | - | |
355 | | - | |
356 | | - | |
357 | | - | |
358 | | - | |
359 | | - | |
360 | | - | |
361 | | - | |
362 | | - | |
363 | | - | |
364 | | - | |
365 | | - | |
366 | | - | |
367 | | - | |
368 | | - | |
369 | | - | |
370 | | - | |
371 | | - | |
372 | | - | |
373 | | - | |
374 | | - | |
375 | | - | |
376 | | - | |
377 | | - | |
378 | | - | |
379 | | - | |
380 | | - | |
381 | | - | |
382 | | - | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
383 | 352 | | |
384 | 353 | | |
385 | | - | |
| 354 | + | |
386 | 355 | | |
387 | 356 | | |
388 | 357 | | |
389 | 358 | | |
390 | 359 | | |
391 | 360 | | |
392 | | - | |
| 361 | + | |
393 | 362 | | |
394 | 363 | | |
395 | 364 | | |
396 | 365 | | |
397 | 366 | | |
398 | 367 | | |
399 | | - | |
| 368 | + | |
400 | 369 | | |
401 | 370 | | |
402 | 371 | | |
| |||
0 commit comments