-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Labels
P3A lower priority bug or feature requestA lower priority bug or feature requestarea-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.devexp-linterIssues with the analyzer's support for the linter packageIssues with the analyzer's support for the linter packagelinter-lint-proposallinter-status-pendingtype-enhancementA request for a change that isn't a bugA request for a change that isn't a bug
Description
null_aware_followed_by_null_assert
Description
This one is a little odd, but I've seen a few cases. In code like this:
foobarDateRange = (foobarDateRange
.clampSomething(Something.VALUE)!
.applySomething()
?.clampToSomething(Something.OTHER_VALUE)!)!;It's a bit hard to follow the parens and bangs, but that last line essentially has ?.foo(bar)! in it. I don't think there is ever any reason to have a null-aware method call or null aware property access (or chain of these) followed by a null-assert. It fails in the same way as !.foo(bar), with a more-or-equally informative stack trace, and is more readable.
Kind
Readability
Bad Examples
a.b?.c!;
a.b?.c()!;
a.b?.c.d().e!;Not sure if this needs to be careful around cascades...
Good Examples
Add a few examples that demonstrate a “good” adoption of this lint’s principle.
Metadata
Metadata
Assignees
Labels
P3A lower priority bug or feature requestA lower priority bug or feature requestarea-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.devexp-linterIssues with the analyzer's support for the linter packageIssues with the analyzer's support for the linter packagelinter-lint-proposallinter-status-pendingtype-enhancementA request for a change that isn't a bugA request for a change that isn't a bug