Skip to content

Add "implicit-dynamic: false" strong mode analyzer option support for generated files #73

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

Closed
wants to merge 7 commits into from
Closed

Add "implicit-dynamic: false" strong mode analyzer option support for generated files #73

wants to merge 7 commits into from

Conversation

sasha-caleo
Copy link
Contributor

No description provided.

@kevmoo
Copy link
Collaborator

kevmoo commented Nov 23, 2017

@caleo-git please rebase and squash. Also, you should update analysis options

analyzer:
  strong-mode:
    implicit-casts: false
    implicit-dynamic: false

Or we're not going to be able to track this

… into add-super-strong-mode-support

# Conflicts:
#	json_serializable/lib/src/type_helpers/iterable_helper.dart
#	json_serializable/pubspec.yaml
#	json_serializable/test/test_files/json_test_example.non_nullable.wrapped.g.dart
#	json_serializable/test/test_files/json_test_example.wrapped.g.dart
#	json_serializable/test/test_files/kitchen_sink.non_nullable.wrapped.dart
#	json_serializable/test/test_files/kitchen_sink.non_nullable.wrapped.g.dart
#	json_serializable/test/test_files/kitchen_sink.wrapped.dart
#	json_serializable/test/test_files/kitchen_sink.wrapped.g.dart
… into add-super-strong-mode-support

# Conflicts:
#	json_serializable/lib/src/type_helpers/iterable_helper.dart
#	json_serializable/pubspec.yaml
#	json_serializable/test/test_files/json_test_example.non_nullable.wrapped.g.dart
#	json_serializable/test/test_files/json_test_example.wrapped.g.dart
#	json_serializable/test/test_files/kitchen_sink.non_nullable.wrapped.dart
#	json_serializable/test/test_files/kitchen_sink.non_nullable.wrapped.g.dart
#	json_serializable/test/test_files/kitchen_sink.wrapped.dart
#	json_serializable/test/test_files/kitchen_sink.wrapped.g.dart
…nto add-super-strong-mode-support

# Conflicts:
#	json_serializable/test/test_files/json_test_example.non_nullable.wrapped.g.dart
#	json_serializable/test/test_files/json_test_example.wrapped.g.dart
#	json_serializable/test/test_files/kitchen_sink.non_nullable.wrapped.g.dart
#	json_serializable/test/test_files/kitchen_sink.wrapped.dart
#	json_serializable/test/test_files/kitchen_sink.wrapped.g.dart
@sasha-caleo
Copy link
Contributor Author

@kevmoo I've enabled "implicit-dynamic: false" option, so now changes are ready for review

@sasha-caleo
Copy link
Contributor Author

@kevmoo When you will be able to check this pull request?

Copy link
Collaborator

@kevmoo kevmoo left a comment

Choose a reason for hiding this comment

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

@nshahan – thoughts on this CL? Trying to decide if I like the extra noise...

@@ -94,7 +94,7 @@ class JsonSerializableGenerator
// Explicitly using `LinkedHashMap` – we want these ordered.
var fields = new LinkedHashMap<String, FieldElement>.fromIterable(
fieldsList,
key: (f) => (f as FieldElement).name);
key: (FieldElement f) => f.name);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should be key: (Object f) => (f as FieldElement).name);

or you get https://travis-ci.org/dart-lang/json_serializable/jobs/308340768#L588

uses_dynamic_as_bottom

@kevmoo
Copy link
Collaborator

kevmoo commented Dec 12, 2017

@jakemac53 – thoughts on this?

@nshahan
Copy link

nshahan commented Dec 12, 2017

@kevmoo I don't have much context here. In what settings are you getting the extra noise?

Copy link
Collaborator

@jakemac53 jakemac53 left a comment

Choose a reason for hiding this comment

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

Not sure how I feel about this in general - I don't feel it is harmful and it does solve a real need.

At the same time I feel like this is highlighting a more general issue of how analyzer settings are applied to generated files. It is only a matter of time before we start getting similar cls to solve other random lints and other things which are not actual errors - and that isn't a scalable approach for code generators as a whole.

Possibly we need something from the analyzer so we can annotate these files as generated and disable all non-default checks that the user has opted into explicitly for their package.

(e as Map<String, dynamic>).keys,
(e as Map).values.map((e) =>
e == null ? null : new Map<String, List<List<DateTime>>>.fromIterables((e as Map<String, dynamic>).keys, (e as Map).values.map((e) => (e as List)?.map((e) => (e as List)?.map((e) => e == null ? null : DateTime.parse(e as String))?.toList())?.toList())))))
: new Map<String, Map<String, List<List<DateTime>>>>.fromIterables((e as Map<String, dynamic>).keys, (e as Map).values.map((dynamic e) => e == null ? null : new Map<String, List<List<DateTime>>>.fromIterables((e as Map<String, dynamic>).keys, (e as Map).values.map((dynamic e) => (e as List)?.map((dynamic e) => (e as List)?.map((dynamic e) => e == null ? null : DateTime.parse(e as String))?.toList())?.toList())))))
Copy link
Collaborator

Choose a reason for hiding this comment

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

wow lol... presumably dartfmt is just giving up here?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yup!

@kevmoo
Copy link
Collaborator

kevmoo commented Dec 16, 2017

@caleo-git – this adds a LOT of noise to the code.

How important is implicit-dynamic: false to you? Why are you setting it?

@sasha-caleo
Copy link
Contributor Author

@kevmoo We are preparing migration to Dart 2.0 for our project. So we would like to have strong mode support for generated files.

@matanlurey
Copy link
Member

@caleo-git implicit-dynamic has no (direct) connection for Dart 2.0 or strong-mode; it is an (optional) lint that doesn't have the full support of the Dart team at this time, and it would be very difficult to make guarantees that generated code will conform to it.

@kevmoo
Copy link
Collaborator

kevmoo commented Jan 8, 2018

What @matanlurey said. Closing for now. Happy to set up time to talk about this on VC...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants