Skip to content

Fixes to lints and fuzzy arrows #39

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
merged 3 commits into from
Sep 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ linter:
- comment_references
- control_flow_in_finally
- empty_statements
#- hash_and_equals
- hash_and_equals
- implementation_imports
- test_types_in_equals
- throw_in_finally
Expand Down
6 changes: 3 additions & 3 deletions lib/src/json_literal_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,21 @@ String _jsonLiteralAsDart(dynamic value, bool asConst) {
return '${asConst ? 'const' : ''}[$listItems]';
}

if (value is Map) return _jsonMapAsDart(value, asConst);
if (value is Map<String, dynamic>) return _jsonMapAsDart(value, asConst);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are these types of checks any more sane than they used to be (won't this return true for Map<dynamic, dynamic>)?

I guess you are just trying to avoid the explicit cast given the tighter type on _jsonMapAsDart, but this sends a bit of the wrong signal imo... I would rather see the cast when you pass the value in to _jsonMapAsDart as its a bit more obvious that you are explicitly casting it and it could technically fail.


throw new StateError(
'Should never get here – with ${value.runtimeType} - `$value`.');
}

String _jsonMapAsDart(Map value, bool asConst) {
String _jsonMapAsDart(Map<String, dynamic> value, bool asConst) {
var buffer = new StringBuffer();
if (asConst) {
buffer.write('const ');
}
buffer.write('{');

var first = true;
value.forEach((String k, v) {
value.forEach((k, v) {
if (first) {
first = false;
} else {
Expand Down
6 changes: 3 additions & 3 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: json_serializable
version: 0.2.3+1
version: 0.2.4-dev
author: Dart Team <misc@dartlang.org>
description: Generates utilities to aid in serializing to/from JSON.
homepage: https://github.com/dart-lang/json_serializable
Expand All @@ -12,8 +12,8 @@ dependencies:
path: ^1.3.2
source_gen: ^0.7.0
dev_dependencies:
build_runner: ^0.4.0
build_test: ^0.6.0
build_runner: '>=0.4.0 <0.6.0'
build_test: '>=0.6.0 <0.9.0'
collection: ^1.14.0
dart_style: ^1.0.0
test: ^0.12.3
2 changes: 1 addition & 1 deletion test/test_files/bathtub.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

// ignore_for_file: annotate_overrides
// ignore_for_file: annotate_overrides, hash_and_equals
library json_serializable.test.bathtub;

import 'package:json_serializable/annotations.dart';
Expand Down
5 changes: 3 additions & 2 deletions test/test_files/json_test_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

// ignore_for_file: annotate_overrides
// ignore_for_file: annotate_overrides, hash_and_equals
library json_serializable.test.example;

import 'dart:collection';
Expand Down Expand Up @@ -30,7 +30,8 @@ class Person extends Object with _$PersonSerializerMixin {
firstName == other.firstName &&
middleName == other.middleName &&
lastName == other.lastName &&
dateOfBirth == other.dateOfBirth;
dateOfBirth == other.dateOfBirth &&
house == other.house;
}

enum Category { top, bottom, strange, charmed, up, down }
Expand Down
2 changes: 1 addition & 1 deletion test/test_files/kitchen_sink.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

// ignore_for_file: annotate_overrides
// ignore_for_file: annotate_overrides, hash_and_equals
library json_serializable.test.kitche_sink;

import 'package:collection/collection.dart';
Expand Down