Skip to content

Commit 449904a

Browse files
authored
Require Dart 3, update lints, enable analysis language modes (#50)
1 parent ff2006b commit 449904a

15 files changed

+30
-62
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
strategy:
2121
fail-fast: false
2222
matrix:
23-
sdk: [2.12.0, dev]
23+
sdk: [3.0.0, dev]
2424
steps:
2525
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
2626
- uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f
@@ -42,7 +42,7 @@ jobs:
4242
fail-fast: false
4343
matrix:
4444
os: [ubuntu-latest]
45-
sdk: [2.12.0, dev]
45+
sdk: [3.0.0, dev]
4646
steps:
4747
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
4848
with:

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 1.1.0-wip
2+
3+
- Require Dart 3.0.0 or greater.
4+
- No longer explicitly name the `matchers.dart` library as `uri.matchers`.
5+
16
## 1.0.0
27

38
- Enable null safety for this package.

analysis_options.yaml

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,26 @@
1-
include: package:lints/recommended.yaml
1+
include: package:dart_flutter_team_lints/analysis_options.yaml
22

33
analyzer:
4-
strong-mode:
5-
implicit-casts: false
4+
language:
5+
strict-casts: true
6+
strict-inference: true
7+
strict-raw-types: true
68

79
linter:
810
rules:
9-
- always_declare_return_types
10-
- avoid_catching_errors
1111
- avoid_private_typedef_functions
1212
- avoid_redundant_argument_values
1313
- avoid_unused_constructor_parameters
1414
- cancel_subscriptions
1515
- cascade_invocations
16-
- directives_ordering
1716
- join_return_with_assignment
18-
- lines_longer_than_80_chars
1917
- missing_whitespace_between_adjacent_strings
2018
- no_runtimeType_toString
21-
- omit_local_variable_types
22-
- only_throw_errors
2319
- package_api_docs
24-
- prefer_asserts_in_initializer_lists
2520
- prefer_const_constructors
2621
- prefer_const_declarations
2722
- prefer_expression_function_bodies
2823
- prefer_final_locals
29-
- prefer_interpolation_to_compose_strings
3024
- prefer_relative_imports
31-
- prefer_single_quotes
32-
- sort_pub_dependencies
3325
- test_types_in_equals
34-
- throw_in_finally
35-
- type_annotate_public_apis
36-
- unawaited_futures
37-
- unnecessary_lambdas
38-
- unnecessary_null_aware_assignments
39-
- unnecessary_parenthesis
40-
- unnecessary_statements
41-
- use_is_even_rather_than_modulo
4226
- use_string_buffers

lib/matchers.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
library uri.matchers;
6-
75
import 'package:matcher/matcher.dart' show Matcher, anything, isA;
86

97
/// Matches the individual parts of a [Uri]. If a matcher is not specified for a

lib/src/encoding.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
library uri.encoding;
6-
75
import 'utils.dart';
86

97
const int _percent = 0x25;

lib/src/uri_builder.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
library uri.builder;
6-
75
/// A mutable holder for incrementally building [Uri]s.
86
class UriBuilder {
97
String fragment;

lib/src/uri_pattern.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
library uri.uri_pattern;
6-
75
import 'package:quiver/collection.dart' show mapsEqual;
86
import 'package:quiver/core.dart' show hash4;
97

lib/src/uri_template.dart

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
library uri.template;
6-
75
import 'dart:collection' show UnmodifiableListView;
86

97
import 'package:quiver/pattern.dart' show escapeRegex;
@@ -212,15 +210,15 @@ class UriParser extends UriPattern {
212210
/// See the RFC for more details.
213211
class UriTemplate {
214212
final String template;
215-
final List _parts;
213+
final List<Object> _parts;
216214

217215
UriTemplate(this.template) : _parts = _compile(template);
218216

219217
@override
220218
String toString() => template;
221219

222-
static UnmodifiableListView _compile(String template) {
223-
final parts = [];
220+
static UnmodifiableListView<Object> _compile(String template) {
221+
final parts = <Object>[];
224222
template.splitMapJoin(
225223
_exprRegex,
226224
onMatch: (match) {
@@ -349,7 +347,7 @@ class UriTemplate {
349347
* over to the next _compileX method.
350348
*/
351349
class _Compiler {
352-
final Iterator _parts;
350+
final Iterator<Object> _parts;
353351

354352
RegExp? pathRegex;
355353
final List<String> pathVariables = [];
@@ -412,7 +410,7 @@ class _Compiler {
412410
}
413411
}
414412

415-
void _compileQuery({Match? match, List? prevParts}) {
413+
void _compileQuery({Match? match, List<Object>? prevParts}) {
416414
void handleExpressionMatch(Match match) {
417415
final expr = match.group(3)!;
418416
for (var q in expr.split(',')) {
@@ -422,7 +420,7 @@ class _Compiler {
422420
}
423421
}
424422

425-
void handleLiteralParts(List literalParts) {
423+
void handleLiteralParts(List<Object> literalParts) {
426424
for (var i = 0; i < literalParts.length; i++) {
427425
final subpart = literalParts[i];
428426
if (subpart is String) {
@@ -464,7 +462,7 @@ class _Compiler {
464462
}
465463
}
466464

467-
void _compileFragment({Match? match, List? prevParts}) {
465+
void _compileFragment({Match? match, List<Object>? prevParts}) {
468466
final fragmentBuffer = StringBuffer();
469467

470468
void handleExpressionMatch(Match match) {
@@ -537,8 +535,8 @@ Map<String, String> _parseMap(String s, String separator) {
537535
return map;
538536
}
539537

540-
List _splitLiteral(String literal) {
541-
final subparts = [];
538+
List<Object> _splitLiteral(String literal) {
539+
final subparts = <Object>[];
542540
literal.splitMapJoin(
543541
_fragmentOrQueryRegex,
544542
onMatch: (m) {

pubspec.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
name: uri
2-
version: 1.0.1-dev
2+
version: 1.1.0-wip
33
description: >-
44
Utilities for building and parsing URIs, including support for parsing
55
URI templates as defined in RFC 6570.
66
repository: https://github.com/google/uri.dart
77
environment:
8-
sdk: '>=2.12.0 <3.0.0'
8+
sdk: ^3.0.0
99

1010
dependencies:
1111
matcher: ^0.12.10
1212
quiver: ^3.0.0
1313

1414
dev_dependencies:
15-
lints: ^1.0.0
15+
dart_flutter_team_lints: ^1.0.0
1616
test: ^1.16.0

test/encoding_test.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
library uri.encoding_test;
6-
75
import 'package:test/test.dart';
86
import 'package:uri/src/encoding.dart';
97

test/spec_test.dart

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,24 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
library uri.spec_tests;
6-
75
import 'dart:convert' show json;
86
import 'dart:io';
97

108
import 'package:test/test.dart';
119
import 'package:uri/uri.dart';
1210

13-
void runSpecTests(String testname, {String? solo}) {
14-
final testFile = File('test/uritemplate-test/$testname.json');
15-
final testJson = json.decode(testFile.readAsStringSync());
11+
void runSpecTests(String testName, {String? solo}) {
12+
final testFile = File('test/uritemplate-test/$testName.json');
13+
final testJson =
14+
json.decode(testFile.readAsStringSync()) as Map<String, Object?>;
1615

1716
for (var specGroup in testJson.keys) {
1817
group(specGroup, () {
19-
final data = testJson[specGroup];
18+
final data = testJson[specGroup] as Map<String, Object?>;
2019
final variables = data['variables'] as Map<String, Object?>;
2120
final testCases = data['testcases'] as List;
2221

23-
for (var testCase in testCases.cast<List>()) {
22+
for (var testCase in testCases.cast<List<Object?>>()) {
2423
final templateString = testCase[0] as String;
2524
if (solo != null && templateString == solo) continue;
2625
test(templateString, () {

test/uri_builder_test.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
library uri.uri_builder_test;
6-
75
import 'package:test/test.dart';
86
import 'package:uri/uri.dart';
97

test/uri_parser_test.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
library uri.uri_parser_test;
6-
75
import 'package:test/test.dart';
86
import 'package:uri/uri.dart';
97

test/uri_template_test.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
library uri.uri_template_test;
6-
75
import 'package:test/test.dart';
86
import 'package:uri/uri.dart';
97

test/uri_test.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
library uri.uri_test;
6-
75
import 'package:test/test.dart';
86
import 'package:uri/uri.dart';
97

0 commit comments

Comments
 (0)