这是indexloc提供的服务,不要输入任何密码
Skip to content

Enable unnecessary_null_checks lint #82084

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

Abhishek01039
Copy link
Contributor

@Abhishek01039 Abhishek01039 commented May 8, 2021

Enable unnecessary_null_checks lint

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I signed the CLA.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@flutter-dashboard flutter-dashboard bot added a: tests "flutter test", flutter_test, or one of our tests f: cupertino flutter/packages/flutter/cupertino repository f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. c: contributor-productivity Team-specific productivity, code health, technical debt. tool Affects the "flutter" command-line tool. See also t: labels. labels May 8, 2021
@google-cla google-cla bot added the cla: yes label May 8, 2021
@Abhishek01039
Copy link
Contributor Author

Hello @goderbauer
can you please review this PR?
Thanks

Copy link
Member

@goderbauer goderbauer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/cc @a14n I believe you attempted to enabled this before?

@a14n
Copy link
Contributor

a14n commented May 10, 2021

See #67443

I mentioned false positives in a comment but I don't exactly remember if I fixed them.

@Abhishek01039 Abhishek01039 requested a review from a14n May 11, 2021 07:06
Copy link
Contributor

@a14n a14n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make the CI happy you either have to disable the lint or add // ignore:... comment on exceptions.

@Abhishek01039 Abhishek01039 requested a review from a14n May 11, 2021 10:22
Copy link
Contributor

@a14n a14n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -227,6 +227,7 @@ class SnippetGenerator {
if (match != null) { // If we saw the start or end of a code block
inCodeBlock = !inCodeBlock;
if (match.namedGroup('language') != null) {
// ignore: unnecessary_null_checks
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this means the lint is not ready yet for our code base. We don't want these ignores everywhere.

Copy link
Contributor Author

@Abhishek01039 Abhishek01039 May 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So should I comment the lint? @goderbauer

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually(after checking) the lint already handle self promotion to non-null (nullable = nullable! is ok) and I think it would defeat the lint to allow any nullable = x!.

A workaround to avoid // ignore would be here:

language = match[1];
language = language!;

As there's only 2 cases where this happens I tend to see this workaround as acceptable.

@@ -227,6 +227,7 @@ class SnippetGenerator {
if (match != null) { // If we saw the start or end of a code block
inCodeBlock = !inCodeBlock;
if (match.namedGroup('language') != null) {
// ignore: unnecessary_null_checks
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually(after checking) the lint already handle self promotion to non-null (nullable = nullable! is ok) and I think it would defeat the lint to allow any nullable = x!.

A workaround to avoid // ignore would be here:

language = match[1];
language = language!;

As there's only 2 cases where this happens I tend to see this workaround as acceptable.

@Abhishek01039 Abhishek01039 requested review from goderbauer and a14n May 13, 2021 03:34
Copy link
Contributor

@a14n a14n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@goderbauer goderbauer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@a14n
Copy link
Contributor

a14n commented May 13, 2021

@Abhishek01039 could you rebase/push to trigger another build? Some current jobs seem to be stuck.

@Abhishek01039
Copy link
Contributor Author

All test passed now!
@a14n

@fluttergithubbot fluttergithubbot merged commit b554f89 into flutter:master May 14, 2021
@jmagman jmagman mentioned this pull request Jul 13, 2021
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a: tests "flutter test", flutter_test, or one of our tests c: contributor-productivity Team-specific productivity, code health, technical debt. f: cupertino flutter/packages/flutter/cupertino repository f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. tool Affects the "flutter" command-line tool. See also t: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants