Skip to content
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

refactor: Migrate firebase auth to nnbd #4633

Merged
merged 29 commits into from
Jan 21, 2021

Conversation

rrousselGit
Copy link
Contributor

Description

This migrate firebase_auth to non-nullable types

Do not merge before firebase_core is migrated

Related Issues

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]).
This will ensure a smooth and quick review process. Updating the pubspec.yaml and changelogs is not required.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • My PR includes unit or integration tests for all changed/updated/fixed behaviors (See Contributor Guide).
  • All existing and new tests are passing.
  • I updated/added relevant documentation (doc comments with ///).
  • The analyzer (flutter analyze) does not report any problems on my PR.
  • I read and followed the Flutter Style Guide.
  • I signed the CLA.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require plugin users to manually update their apps to accommodate your change?

  • Yes, this is a breaking change (please indicate a breaking change in CHANGELOG.md and increment major revision).
  • No, this is not a breaking change.

@google-cla google-cla bot added the cla: yes label Jan 12, 2021
@rrousselGit rrousselGit added blocked: do-not-merge PR blocked externally and removed cla: yes labels Jan 12, 2021
@google-cla google-cla bot added the cla: yes label Jan 12, 2021
@google-cla
Copy link

google-cla bot commented Jan 12, 2021

☹️ Sorry, but only Googlers may change the label cla: yes.

/// Complete error message.
final String message;
FirebaseAuthException({
String? message,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

"message" is optional/nullable in base-classes, and some places passed null as message, so I removed the required

Copy link
Member

Choose a reason for hiding this comment

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

required removal makes sense 👍

if (exception is! Exception || exception is! PlatformException) {
// TODO(rrousselGit): Is this dead code?
return exception;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This code cannot be assigned to Exception, so I changed the return type to Object.

But that raise a question: Why do we even need this code? It probably was never reached before, as we'd otherwise get a "XX cannot be assigned to Exception" thrown

Copy link
Member

@Salakar Salakar Jan 12, 2021

Choose a reason for hiding this comment

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

I can't think of any reason why this was needed, @Ehesp might be able to confirm if around

@@ -10,13 +10,13 @@ import '../../firebase_auth_exception.dart';

/// Catches a [PlatformException] and converts it into a [FirebaseAuthException]
/// if it was intentionally caught on the native platform.
Exception convertPlatformException(Object exception) {
Object convertPlatformException(Object exception) {
if (exception is! Exception || exception is! PlatformException) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

PlatformException is an Exception so the first condition isn't needed

String /*!*/ message = platformException.message;
String email;
AuthCredential credential;
String? message = platformException.message;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Related to the previous comment about message now being nullable

I believe the /*!*/ was erroneous

@rrousselGit rrousselGit changed the title Migrate firebase auth to nnbd chrore: Migrate firebase auth to nnbd Jan 12, 2021
@rrousselGit rrousselGit changed the title chrore: Migrate firebase auth to nnbd chore: Migrate firebase auth to nnbd Jan 12, 2021

final additionalUserInfo = result.additionalUserInfo;
expect(additionalUserInfo, isA<Object>());
expect(additionalUserInfo, isNull);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

isA<Object> is always true. Using isNull since that is the current behaviour, but could be wrong

Comment on lines +911 to +916
verificationCompleted: (_) {},
verificationFailed: (_) {},
codeSent: (_, __) {},
codeAutoRetrievalTimeout: (_) {},
timeout: testTimeout,
autoRetrievedSmsCodeForTesting: testSmsCode,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure if this change is expected, or if some parameters could be nullable?

String type,
void Function() testMethod,
) async {
await expectLater(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same behaviour, but much better error message

There are many tests that should be changed to follow this pattern

.add(DivElement()..id = _kInvisibleElementId);

element = _kInvisibleElementId;
} else {
parameters['size'] = convertRecaptchaVerifierSize(size);
parameters['theme'] = convertRecaptchaVerifierTheme(theme);

Element el = window.document.getElementById(container);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It didn't feel correct to do nothing with el besides an assertion. This change no-longer calls getElementById when the asserts are removed

Copy link
Member

Choose a reason for hiding this comment

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

Agree 👍

@Salakar Salakar changed the title chore: Migrate firebase auth to nnbd refactor: Migrate firebase auth to nnbd Jan 15, 2021
@rrousselGit rrousselGit marked this pull request as ready for review January 19, 2021 12:02
@google-cla
Copy link

google-cla bot commented Jan 20, 2021

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@google-cla google-cla bot added cla: no and removed cla: yes labels Jan 20, 2021
@Salakar
Copy link
Member

Salakar commented Jan 20, 2021

@googlebot I consent.

@google-cla google-cla bot added cla: yes and removed cla: no labels Jan 20, 2021
@rrousselGit rrousselGit force-pushed the migrate_firebase_auth_to_nnbd branch 2 times, most recently from 1aab645 to fd784b0 Compare January 20, 2021 16:45
@rrousselGit rrousselGit merged commit 1e8f48a into master Jan 21, 2021
@rrousselGit rrousselGit deleted the migrate_firebase_auth_to_nnbd branch January 21, 2021 12:20
@firebase firebase locked and limited conversation to collaborators Feb 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants