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

AF-3801 fix reporter runtime error in Dart 2.1.0 #287

Merged
merged 3 commits into from
Jan 14, 2019

Conversation

robbecker-wf
Copy link
Member

@robbecker-wf robbecker-wf commented Jan 11, 2019

Overview

Under Dart 2.1.0, when running tests that use reporter.log. The quiet variable would be null somehow and cause a runtime error in the conditional check in the _log method.
I imagine this is caused by something like checked mode when running tests. I could not reproduce this runtime error when running a similar thing on the command line (prod mode).

An example failing build due to this error: https://ci.webfilings.com/build/1585120

Changes

  • Don't allow these to variables to be null

Testing

@aviary3-wk
Copy link

Security Insights

No security relevant content was detected by automated scans.

Action Items

  • Review PR for security impact; comment "security review required" if needed or unsure
  • Verify aviary.yaml coverage of security relevant code

Questions or Comments? Reach out on Slack: #support-infosec.

// This may look like a strange conditional, but please leave it.
// Somehow when using the tearoff `reporter.log` the `quiet` variable
// is null, which causes a runtime error when running tests in Dart 2.1.0
if (quiet == true && shout != true) return;
Copy link
Contributor

Choose a reason for hiding this comment

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

Could it be that Reporter isn't getting passed both arguments during intiialization?

Reporter reporter = new Reporter();

Based on the existing code,

bool color = true;
bool quiet = false;
Reporter({bool this.color, bool this.quiet});
String colorBlue(String message) => _color(_blue, message);

, I would expect new Reporter() to have both fields be null.

I feel like it should just be:

bool color;
bool quiet;

Reporter({bool this.color = true, bool this.quiet = false}); 

Could it be that it's only showing up in testing because this is being run in checked mode?

- default constructor values
- extra null checks
@@ -30,7 +30,11 @@ class Reporter {
bool color = true;
bool quiet = false;

Reporter({bool this.color, bool this.quiet});
Reporter({this.color: true, this.quiet: false}) {
Copy link
Contributor

Choose a reason for hiding this comment

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

#nit these defaults aren't necessary if we have null-awares below

Copy link
Member Author

Choose a reason for hiding this comment

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

I left them in so that when calling the constructor, the IDE would tell you what the defaults are.

@@ -30,7 +30,11 @@ class Reporter {
bool color = true;
bool quiet = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

#nit these defaults aren't necessary

Copy link
Member Author

Choose a reason for hiding this comment

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

Totally. I'll remove them.

if (quiet && !shout) return;
// Ensure that even if quiet or shout are null, the conditional
// will result in a boolean
if (quiet == true && shout != true) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we should have to worry about this case; these should never be null unless someone explicitly sets them to null, in which case the program should probably fail.

@greglittlefield-wf
Copy link
Contributor

+1

@rmconsole7-wk rmconsole7-wk changed the title fix reporter runtime error in Dart 2.1.0 AF-3801 fix reporter runtime error in Dart 2.1.0 Jan 14, 2019
@evanweible-wf
Copy link
Contributor

QA +1

  • CI passes

@Workiva/release-management-p

@rmconsole3-wf rmconsole3-wf merged commit 39c05cc into master Jan 14, 2019
@rmconsole3-wf rmconsole3-wf deleted the reporter_null_boolean branch January 14, 2019 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants