Skip to content

Commit

Permalink
Require Dart 2.19, migrate to dart_flutter_team_lints, make associate…
Browse files Browse the repository at this point in the history
…d fixes (#138)
  • Loading branch information
kevmoo committed Mar 1, 2023
1 parent 4d369fd commit 1ad2f49
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
matrix:
# Add macos-latest and/or windows-latest if relevant for this package.
os: [ubuntu-latest]
sdk: [dev]
sdk: [2.19.0, dev]
steps:
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c
- uses: dart-lang/setup-dart@a57a6c04cf7d4840e88432aad6281d1e125f0d46
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 3.1.2-dev

* Require Dart 2.19

## 3.1.1

* Switch to using package:lints.
Expand Down
18 changes: 2 additions & 16 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,36 +1,22 @@
include: package:lints/recommended.yaml
include: package:dart_flutter_team_lints/analysis_options.yaml

analyzer:
language:
strict-casts: true

linter:
rules:
- avoid_catching_errors
- avoid_private_typedef_functions
- avoid_redundant_argument_values
- avoid_unused_constructor_parameters
- cancel_subscriptions
- directives_ordering
- join_return_with_assignment
- lines_longer_than_80_chars
- missing_whitespace_between_adjacent_strings
- no_runtimeType_toString
- only_throw_errors
- package_api_docs
- prefer_asserts_in_initializer_lists
- prefer_const_declarations
- prefer_expression_function_bodies
- prefer_interpolation_to_compose_strings
- prefer_relative_imports
- prefer_single_quotes
- sort_pub_dependencies
- test_types_in_equals
- throw_in_finally
- type_annotate_public_apis
- unnecessary_lambdas
- unnecessary_null_aware_assignments
- unnecessary_parenthesis
- unnecessary_statements
- use_is_even_rather_than_modulo
- use_string_buffers
- use_super_parameters
2 changes: 0 additions & 2 deletions benchmark/benchmark.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
// license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT.

library yaml.benchmark.benchmark;

import 'dart:convert';
import 'dart:io';

Expand Down
8 changes: 4 additions & 4 deletions lib/src/equality.dart
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,15 @@ class _DeepEquals {
int deepHashCode(Object? obj) {
var parents = [];

int _deepHashCode(value) {
int deepHashCodeInner(value) {
if (parents.any((parent) => identical(parent, value))) return -1;

parents.add(value);
try {
if (value is Map) {
var equality = const UnorderedIterableEquality();
return equality.hash(value.keys.map(_deepHashCode)) ^
equality.hash(value.values.map(_deepHashCode));
return equality.hash(value.keys.map(deepHashCodeInner)) ^
equality.hash(value.values.map(deepHashCodeInner));
} else if (value is Iterable) {
return const IterableEquality().hash(value.map(deepHashCode));
} else if (value is YamlScalar) {
Expand All @@ -124,5 +124,5 @@ int deepHashCode(Object? obj) {
}
}

return _deepHashCode(obj);
return deepHashCodeInner(obj);
}
2 changes: 1 addition & 1 deletion lib/src/yaml_exception.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ import 'package:source_span/source_span.dart';

/// An error thrown by the YAML processor.
class YamlException extends SourceSpanFormatException {
YamlException(String message, SourceSpan? span) : super(message, span);
YamlException(super.message, super.span);
}
12 changes: 6 additions & 6 deletions lib/src/yaml_node.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class YamlMap extends YamlNode with collection.MapMixin, UnmodifiableMapMixin {
Map get value => this;

@override
Iterable get keys => nodes.keys.map((node) => node.value);
Iterable get keys => nodes.keys.map((node) => (node as YamlNode).value);

/// Creates an empty YamlMap.
///
Expand All @@ -86,9 +86,9 @@ class YamlMap extends YamlNode with collection.MapMixin, UnmodifiableMapMixin {
YamlMapWrapper(dartMap, sourceUrl, style: style);

/// Users of the library should not use this constructor.
YamlMap.internal(Map<dynamic, YamlNode> nodes, SourceSpan span, this.style)
YamlMap.internal(Map<dynamic, YamlNode> nodes, super.span, this.style)
: nodes = UnmodifiableMapView<dynamic, YamlNode>(nodes),
super._(span);
super._();

@override
dynamic operator [](Object? key) => nodes[key]?.value;
Expand Down Expand Up @@ -136,9 +136,9 @@ class YamlList extends YamlNode with collection.ListMixin {
YamlListWrapper(dartList, sourceUrl, style: style);

/// Users of the library should not use this constructor.
YamlList.internal(List<YamlNode> nodes, SourceSpan span, this.style)
YamlList.internal(List<YamlNode> nodes, super.span, this.style)
: nodes = UnmodifiableListView<YamlNode>(nodes),
super._(span);
super._();

@override
dynamic operator [](int index) => nodes[index].value;
Expand All @@ -152,7 +152,7 @@ class YamlList extends YamlNode with collection.ListMixin {
/// A wrapped scalar value parsed from YAML.
class YamlScalar extends YamlNode {
@override
final dynamic value;
final Object? value;

This comment has been minimized.

Copy link
@devoncarew

devoncarew Mar 7, 2023

Member

We may want a minor version bump of the package here so that consumers can specify that that need this API change (I'm still running down the issues, but I think that yaml_edit needs to be updated for this change).

This comment has been minimized.

Copy link
@jonasfj

jonasfj Mar 8, 2023

Member

@devoncarew might this not a breaking change?

I'd imagine that come Dart 3, we'll want YamlNode to be sealed/final or something, so that we can pattern match on it's subclasses. So that might be another opportunity for a breaking change.

This comment has been minimized.

Copy link
@devoncarew

devoncarew Mar 8, 2023

Member

I think technically it might be? It seems unfortunate to rev the major version for such a small change though.

I think what you're getting at it that perhaps we can revert this specific part of the PR, and then batch with other significant changes in the near term (in other repos, we file next-breaking-release issues to track work like this).


/// The style used for the scalar in the original document.
final ScalarStyle style;
Expand Down
6 changes: 3 additions & 3 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
name: yaml
version: 3.1.1
version: 3.1.2-dev
description: A parser for YAML, a human-friendly data serialization standard
repository: https://github.com/dart-lang/yaml

environment:
sdk: '>=2.12.0 <3.0.0'
sdk: '>=2.19.0 <3.0.0'

dependencies:
collection: ^1.15.0
source_span: ^1.8.0
string_scanner: ^1.1.0

dev_dependencies:
lints: ^1.0.0
dart_flutter_team_lints: ^1.0.0
path: ^1.8.0
test: ^1.16.0
2 changes: 2 additions & 0 deletions test/yaml_node_wrapper_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
// license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT.

// ignore_for_file: avoid_dynamic_calls

import 'package:source_span/source_span.dart';
import 'package:test/test.dart';
import 'package:yaml/yaml.dart';
Expand Down
2 changes: 2 additions & 0 deletions test/yaml_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
// license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT.

// ignore_for_file: avoid_dynamic_calls

import 'package:test/test.dart';
import 'package:yaml/src/error_listener.dart';
import 'package:yaml/yaml.dart';
Expand Down

0 comments on commit 1ad2f49

Please sign in to comment.