Commit 0bb629e
[analysis_server] Dot shorthands: Update prefer_const_constructors lint.
Now that `DotShorthandsConstructorInvocation`'s `canBeConst` is updated, we can also update the `prefer_const_constructors` lint.
We skip the lint when we have the `@literal` metadata on the constructor since it's already reporting a warning here: https://dart-review.googlesource.com/c/sdk/+/434881. Similar to instance creation expressions, we also skip reporting a lint if we're instantiating the `Object` class.
Otherwise, if the constructor we're calling with the shorthand is const and we can const-ify it, we report this lint.
Added unit tests.
Fixes: #60911
Bug: #60893
Change-Id: Ib4bcba629f60e0dbff110080918adfacfb1ba5d2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/434981
Commit-Queue: Kallen Tu <[email protected]>
Reviewed-by: Samuel Rawlins <[email protected]>1 parent b3c579d commit 0bb629e
File tree
2 files changed
+74
-0
lines changed- pkg/linter
- lib/src/rules
- test/rules
2 files changed
+74
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
36 | 61 | | |
37 | 62 | | |
38 | 63 | | |
| |||
Lines changed: 49 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
77 | 89 | | |
78 | 90 | | |
79 | 91 | | |
| |||
275 | 287 | | |
276 | 288 | | |
277 | 289 | | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
278 | 299 | | |
279 | 300 | | |
280 | 301 | | |
| |||
363 | 384 | | |
364 | 385 | | |
365 | 386 | | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
366 | 409 | | |
367 | 410 | | |
368 | 411 | | |
| |||
386 | 429 | | |
387 | 430 | | |
388 | 431 | | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
389 | 438 | | |
390 | 439 | | |
391 | 440 | | |
0 commit comments