Skip to content

Commit

Permalink
update lints, require Dart 3 (#101)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevmoo committed Jul 18, 2023
1 parent d17e3ed commit 799b398
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 42 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-package.yml
Expand Up @@ -16,7 +16,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
sdk: [2.18.0, dev]
sdk: [3.0.0, dev]
steps:
# These are the latest versions of the github actions; dependabot will
# send PRs to keep these up-to-date.
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -3,6 +3,7 @@
* Update video/mp4 mimeType lookup by header bytes.
* Add m4b mimeType lookup by extension.
* Add `text/markdown` mimeType lookup by extension.
* Require Dart 3.0.0.

## 1.0.4

Expand Down
19 changes: 2 additions & 17 deletions analysis_options.yaml
@@ -1,5 +1,5 @@
# https://dart.dev/guides/language/analysis-options
include: package:lints/recommended.yaml
include: package:dart_flutter_team_lints/analysis_options.yaml

analyzer:
language:
Expand All @@ -9,11 +9,8 @@ analyzer:

linter:
rules:
- always_declare_return_types
- avoid_bool_literals_in_conditional_expressions
- avoid_catching_errors
- avoid_classes_with_only_static_members
- avoid_dynamic_calls
- avoid_private_typedef_functions
- avoid_redundant_argument_values
- avoid_returning_null_for_future
Expand All @@ -22,33 +19,21 @@ linter:
- avoid_void_async
- cancel_subscriptions
- comment_references
- directives_ordering
- join_return_with_assignment
- lines_longer_than_80_chars
- literal_only_boolean_expressions
- missing_whitespace_between_adjacent_strings
- no_adjacent_strings_in_list
- 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_relative_imports
- prefer_single_quotes
- sort_pub_dependencies
- test_types_in_equals
- throw_in_finally
- type_annotate_public_apis
- unawaited_futures
- unnecessary_await_in_return
- unnecessary_lambdas
- unnecessary_parenthesis
- unnecessary_breaks
- unnecessary_raw_strings
- unnecessary_statements
- use_if_null_to_convert_nulls_to_bools
- use_raw_strings
- use_string_buffers
Expand Down
17 changes: 0 additions & 17 deletions lib/src/bound_multipart_stream.dart
Expand Up @@ -150,13 +150,10 @@ class BoundMultipartStream {
switch (_controllerState) {
case _controllerStateActive:
if (_subscription.isPaused) _subscription.resume();
break;
case _controllerStatePaused:
if (!_subscription.isPaused) _subscription.pause();
break;
case _controllerStateCanceled:
_subscription.cancel();
break;
default:
throw StateError('This code should never be reached.');
}
Expand Down Expand Up @@ -214,7 +211,6 @@ class BoundMultipartStream {
_index = _index - _boundaryIndex;
_boundaryIndex = 0;
}
break;

case _boundaryEndingCode:
if (byte == char_code.cr) {
Expand All @@ -224,7 +220,6 @@ class BoundMultipartStream {
} else {
_expectWhitespace(byte);
}
break;

case _boundaryEndCode:
_expectByteValue(byte, char_code.lf);
Expand All @@ -234,7 +229,6 @@ class BoundMultipartStream {
_tryPropagateControllerState();
}
_state = _headerStartCode;
break;

case _headerStartCode:
_headers = <String, String>{};
Expand All @@ -245,7 +239,6 @@ class BoundMultipartStream {
_headerField.add(_toLowerCase(byte));
_state = _headerFieldCode;
}
break;

case _headerFieldCode:
if (byte == char_code.colon) {
Expand All @@ -256,7 +249,6 @@ class BoundMultipartStream {
}
_headerField.add(_toLowerCase(byte));
}
break;

case _headerValueStartCode:
if (byte == char_code.cr) {
Expand All @@ -266,20 +258,17 @@ class BoundMultipartStream {
_headerValue.add(byte);
_state = _headerValueCode;
}
break;

case _headerValueCode:
if (byte == char_code.cr) {
_state = _headerValueFoldingOrEndingCode;
} else {
_headerValue.add(byte);
}
break;

case _headerValueFoldingOrEndingCode:
_expectByteValue(byte, char_code.lf);
_state = _headerValueFoldOrEndCode;
break;

case _headerValueFoldOrEndCode:
if (byte == char_code.sp || byte == char_code.ht) {
Expand All @@ -298,7 +287,6 @@ class BoundMultipartStream {
_state = _headerFieldCode;
}
}
break;

case _headerEndingCode:
_expectByteValue(byte, char_code.lf);
Expand All @@ -314,7 +302,6 @@ class BoundMultipartStream {
_headers = null;
_state = _contentCode;
contentStartIndex = _index + 1;
break;

case _contentCode:
if (byte == _boundary[_boundaryIndex]) {
Expand All @@ -337,20 +324,17 @@ class BoundMultipartStream {
contentStartIndex ??= _index;
_boundaryIndex = 0;
}
break;

case _lastBoundaryDash2Code:
_expectByteValue(byte, char_code.dash);
_state = _lastBoundaryEndingCode;
break;

case _lastBoundaryEndingCode:
if (byte == char_code.cr) {
_state = _lastBoundaryEndCode;
} else {
_expectWhitespace(byte);
}
break;

case _lastBoundaryEndCode:
_expectByteValue(byte, char_code.lf);
Expand All @@ -360,7 +344,6 @@ class BoundMultipartStream {
_tryPropagateControllerState();
}
_state = _doneCode;
break;

default:
// Should be unreachable.
Expand Down
2 changes: 0 additions & 2 deletions lib/src/magic_number.dart
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 mime.magic_number;

class MagicNumber {
final String mimeType;
final List<int> numbers;
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Expand Up @@ -6,8 +6,8 @@ description: >-
repository: https://github.com/dart-lang/mime

environment:
sdk: '>=2.18.0 <3.0.0'
sdk: ^3.0.0

dev_dependencies:
lints: ^2.0.0
dart_flutter_team_lints: ^1.0.0
test: ^1.16.0
3 changes: 0 additions & 3 deletions test/mime_multipart_transformer_test.dart
Expand Up @@ -51,7 +51,6 @@ void _runParseTest(
expect(data, equals(expectedParts?[part]!.codeUnits));
}
}));
break;

case TestMode.delayListen:
futures.add(
Expand All @@ -68,7 +67,6 @@ void _runParseTest(
),
),
);
break;

case TestMode.pauseResume:
final completer = Completer<void>();
Expand All @@ -86,7 +84,6 @@ void _runParseTest(
completer.complete();
});
addTearDown(subscription.cancel);
break;
}
}, onError: (Object error) {
// ignore: only_throw_errors
Expand Down

0 comments on commit 799b398

Please sign in to comment.