Skip to content

Commit

Permalink
Require Dart 3, update lints, enable analysis language modes (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
parlough authored Jun 15, 2023
1 parent ff2006b commit 449904a
Show file tree
Hide file tree
Showing 15 changed files with 30 additions and 62 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
strategy:
fail-fast: false
matrix:
sdk: [2.12.0, dev]
sdk: [3.0.0, dev]
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
- uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f
Expand All @@ -42,7 +42,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
sdk: [2.12.0, dev]
sdk: [3.0.0, dev]
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
with:
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 1.1.0-wip

- Require Dart 3.0.0 or greater.
- No longer explicitly name the `matchers.dart` library as `uri.matchers`.

## 1.0.0

- Enable null safety for this package.
Expand Down
26 changes: 5 additions & 21 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,42 +1,26 @@
include: package:lints/recommended.yaml
include: package:dart_flutter_team_lints/analysis_options.yaml

analyzer:
strong-mode:
implicit-casts: false
language:
strict-casts: true
strict-inference: true
strict-raw-types: true

linter:
rules:
- always_declare_return_types
- avoid_catching_errors
- avoid_private_typedef_functions
- avoid_redundant_argument_values
- avoid_unused_constructor_parameters
- cancel_subscriptions
- cascade_invocations
- directives_ordering
- join_return_with_assignment
- lines_longer_than_80_chars
- missing_whitespace_between_adjacent_strings
- no_runtimeType_toString
- omit_local_variable_types
- only_throw_errors
- package_api_docs
- prefer_asserts_in_initializer_lists
- prefer_const_constructors
- prefer_const_declarations
- prefer_expression_function_bodies
- prefer_final_locals
- 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
- unawaited_futures
- unnecessary_lambdas
- unnecessary_null_aware_assignments
- unnecessary_parenthesis
- unnecessary_statements
- use_is_even_rather_than_modulo
- use_string_buffers
2 changes: 0 additions & 2 deletions lib/matchers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// 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.

library uri.matchers;

import 'package:matcher/matcher.dart' show Matcher, anything, isA;

/// Matches the individual parts of a [Uri]. If a matcher is not specified for a
Expand Down
2 changes: 0 additions & 2 deletions lib/src/encoding.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// 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.

library uri.encoding;

import 'utils.dart';

const int _percent = 0x25;
Expand Down
2 changes: 0 additions & 2 deletions lib/src/uri_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// 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.

library uri.builder;

/// A mutable holder for incrementally building [Uri]s.
class UriBuilder {
String fragment;
Expand Down
2 changes: 0 additions & 2 deletions lib/src/uri_pattern.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// 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.

library uri.uri_pattern;

import 'package:quiver/collection.dart' show mapsEqual;
import 'package:quiver/core.dart' show hash4;

Expand Down
20 changes: 9 additions & 11 deletions lib/src/uri_template.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// 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.

library uri.template;

import 'dart:collection' show UnmodifiableListView;

import 'package:quiver/pattern.dart' show escapeRegex;
Expand Down Expand Up @@ -212,15 +210,15 @@ class UriParser extends UriPattern {
/// See the RFC for more details.
class UriTemplate {
final String template;
final List _parts;
final List<Object> _parts;

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

@override
String toString() => template;

static UnmodifiableListView _compile(String template) {
final parts = [];
static UnmodifiableListView<Object> _compile(String template) {
final parts = <Object>[];
template.splitMapJoin(
_exprRegex,
onMatch: (match) {
Expand Down Expand Up @@ -349,7 +347,7 @@ class UriTemplate {
* over to the next _compileX method.
*/
class _Compiler {
final Iterator _parts;
final Iterator<Object> _parts;

RegExp? pathRegex;
final List<String> pathVariables = [];
Expand Down Expand Up @@ -412,7 +410,7 @@ class _Compiler {
}
}

void _compileQuery({Match? match, List? prevParts}) {
void _compileQuery({Match? match, List<Object>? prevParts}) {
void handleExpressionMatch(Match match) {
final expr = match.group(3)!;
for (var q in expr.split(',')) {
Expand All @@ -422,7 +420,7 @@ class _Compiler {
}
}

void handleLiteralParts(List literalParts) {
void handleLiteralParts(List<Object> literalParts) {
for (var i = 0; i < literalParts.length; i++) {
final subpart = literalParts[i];
if (subpart is String) {
Expand Down Expand Up @@ -464,7 +462,7 @@ class _Compiler {
}
}

void _compileFragment({Match? match, List? prevParts}) {
void _compileFragment({Match? match, List<Object>? prevParts}) {
final fragmentBuffer = StringBuffer();

void handleExpressionMatch(Match match) {
Expand Down Expand Up @@ -537,8 +535,8 @@ Map<String, String> _parseMap(String s, String separator) {
return map;
}

List _splitLiteral(String literal) {
final subparts = [];
List<Object> _splitLiteral(String literal) {
final subparts = <Object>[];
literal.splitMapJoin(
_fragmentOrQueryRegex,
onMatch: (m) {
Expand Down
6 changes: 3 additions & 3 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
name: uri
version: 1.0.1-dev
version: 1.1.0-wip
description: >-
Utilities for building and parsing URIs, including support for parsing
URI templates as defined in RFC 6570.
repository: https://github.com/google/uri.dart
environment:
sdk: '>=2.12.0 <3.0.0'
sdk: ^3.0.0

dependencies:
matcher: ^0.12.10
quiver: ^3.0.0

dev_dependencies:
lints: ^1.0.0
dart_flutter_team_lints: ^1.0.0
test: ^1.16.0
2 changes: 0 additions & 2 deletions test/encoding_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// 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.

library uri.encoding_test;

import 'package:test/test.dart';
import 'package:uri/src/encoding.dart';

Expand Down
13 changes: 6 additions & 7 deletions test/spec_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,24 @@
// 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.

library uri.spec_tests;

import 'dart:convert' show json;
import 'dart:io';

import 'package:test/test.dart';
import 'package:uri/uri.dart';

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

for (var specGroup in testJson.keys) {
group(specGroup, () {
final data = testJson[specGroup];
final data = testJson[specGroup] as Map<String, Object?>;
final variables = data['variables'] as Map<String, Object?>;
final testCases = data['testcases'] as List;

for (var testCase in testCases.cast<List>()) {
for (var testCase in testCases.cast<List<Object?>>()) {
final templateString = testCase[0] as String;
if (solo != null && templateString == solo) continue;
test(templateString, () {
Expand Down
2 changes: 0 additions & 2 deletions test/uri_builder_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// 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.

library uri.uri_builder_test;

import 'package:test/test.dart';
import 'package:uri/uri.dart';

Expand Down
2 changes: 0 additions & 2 deletions test/uri_parser_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// 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.

library uri.uri_parser_test;

import 'package:test/test.dart';
import 'package:uri/uri.dart';

Expand Down
2 changes: 0 additions & 2 deletions test/uri_template_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// 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.

library uri.uri_template_test;

import 'package:test/test.dart';
import 'package:uri/uri.dart';

Expand Down
2 changes: 0 additions & 2 deletions test/uri_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// 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.

library uri.uri_test;

import 'package:test/test.dart';
import 'package:uri/uri.dart';

Expand Down

0 comments on commit 449904a

Please sign in to comment.