Enable and fix a number of lints (#49)

- moved char codes to top-level fields
- removed gratuitous library directives

Co-authored-by: Jacob MacDonald <jakemac@google.com>
diff --git a/analysis_options.yaml b/analysis_options.yaml
index 7f965d2..7d7abe2 100644
--- a/analysis_options.yaml
+++ b/analysis_options.yaml
@@ -4,6 +4,7 @@
     implicit-casts: false
 linter:
   rules:
+    - avoid_dynamic_calls
     - avoid_empty_else
     - avoid_init_to_null
     - avoid_null_checks_in_equality_operators
@@ -11,8 +12,9 @@
     - await_only_futures
     - camel_case_types
     - cancel_subscriptions
-    #- constant_identifier_names
     - control_flow_in_finally
+    - constant_identifier_names
+    - depend_on_referenced_packages
     - directives_ordering
     - empty_catches
     - empty_constructor_bodies
@@ -29,6 +31,7 @@
     - package_names
     - package_prefixed_library_names
     - prefer_equal_for_default_values
+    - prefer_expression_function_bodies
     - prefer_final_fields
     - prefer_generic_function_type_aliases
     - prefer_is_not_empty
@@ -39,5 +42,6 @@
     - unnecessary_brace_in_string_interps
     - unnecessary_const
     - unnecessary_new
+    - unnecessary_parenthesis
     - unrelated_type_equality_checks
     - valid_regexps
diff --git a/lib/src/bound_multipart_stream.dart b/lib/src/bound_multipart_stream.dart
index 73bc495..ae46499 100644
--- a/lib/src/bound_multipart_stream.dart
+++ b/lib/src/bound_multipart_stream.dart
@@ -5,39 +5,20 @@
 import 'dart:async';
 import 'dart:convert';
 
-import 'char_code.dart';
+import 'char_code.dart' as char_code;
 import 'mime_shared.dart';
 
 /// Bytes for '()<>@,;:\\"/[]?={} \t'.
-const _SEPARATORS = [
-  40,
-  41,
-  60,
-  62,
-  64,
-  44,
-  59,
-  58,
-  92,
-  34,
-  47,
-  91,
-  93,
-  63,
-  61,
-  123,
-  125,
-  32,
-  9
-];
+const _separators = {
+  40, 41, 60, 62, 64, 44, 59, 58, 92, 34, 47, 91, 93, 63, 61, 123, 125, 32, 9 //
+};
 
-bool _isTokenChar(int byte) {
-  return byte > 31 && byte < 128 && !_SEPARATORS.contains(byte);
-}
+bool _isTokenChar(int byte) =>
+    byte > 31 && byte < 128 && !_separators.contains(byte);
 
 int _toLowerCase(int byte) {
-  const delta = CharCode.LOWER_A - CharCode.UPPER_A;
-  return (CharCode.UPPER_A <= byte && byte <= CharCode.UPPER_Z)
+  const delta = char_code.lowerA - char_code.upperA;
+  return (char_code.upperA <= byte && byte <= char_code.upperZ)
       ? byte + delta
       : byte;
 }
@@ -49,7 +30,7 @@
 }
 
 void _expectWhitespace(int byte) {
-  if (byte != CharCode.SP && byte != CharCode.HT) {
+  if (byte != char_code.sp && byte != char_code.ht) {
     throw MimeMultipartException('Failed to parse multipart mime 2');
   }
 }
@@ -62,30 +43,37 @@
   _MimeMultipart(this.headers, this._stream);
 
   @override
-  StreamSubscription<List<int>> listen(void Function(List<int> data)? onData,
-      {void Function()? onDone, Function? onError, bool? cancelOnError}) {
-    return _stream.listen(onData,
-        onDone: onDone, onError: onError, cancelOnError: cancelOnError);
-  }
+  StreamSubscription<List<int>> listen(
+    void Function(List<int> data)? onData, {
+    void Function()? onDone,
+    Function? onError,
+    bool? cancelOnError,
+  }) =>
+      _stream.listen(
+        onData,
+        onDone: onDone,
+        onError: onError,
+        cancelOnError: cancelOnError,
+      );
 }
 
 class BoundMultipartStream {
-  static const int _START = 0;
-  static const int _BOUNDARY_ENDING = 1;
-  static const int _BOUNDARY_END = 2;
-  static const int _HEADER_START = 3;
-  static const int _HEADER_FIELD = 4;
-  static const int _HEADER_VALUE_START = 5;
-  static const int _HEADER_VALUE = 6;
-  static const int _HEADER_VALUE_FOLDING_OR_ENDING = 7;
-  static const int _HEADER_VALUE_FOLD_OR_END = 8;
-  static const int _HEADER_ENDING = 9;
-  static const int _CONTENT = 10;
-  static const int _LAST_BOUNDARY_DASH2 = 11;
-  static const int _LAST_BOUNDARY_ENDING = 12;
-  static const int _LAST_BOUNDARY_END = 13;
-  static const int _DONE = 14;
-  static const int _FAIL = 15;
+  static const int _startCode = 0;
+  static const int _boundaryEndingCode = 1;
+  static const int _boundaryEndCode = 2;
+  static const int _headerStartCode = 3;
+  static const int _headerFieldCode = 4;
+  static const int _headerValueStartCode = 5;
+  static const int _headerValueCode = 6;
+  static const int _headerValueFoldingOrEndingCode = 7;
+  static const int _headerValueFoldOrEndCode = 8;
+  static const int _headerEndingCode = 9;
+  static const int _contentCode = 10;
+  static const int _lastBoundaryDash2Code = 11;
+  static const int _lastBoundaryEndingCode = 12;
+  static const int _lastBoundaryEndCode = 13;
+  static const int _doneCode = 14;
+  static const int _failCode = 15;
 
   final List<int> _boundary;
   final List<int> _headerField = [];
@@ -94,12 +82,12 @@
   // The following states belong to `_controller`, state changes will not be
   // immediately acted upon but rather only after the current
   // `_multipartController` is done.
-  static const int _CONTROLLER_STATE_IDLE = 0;
-  static const int _CONTROLLER_STATE_ACTIVE = 1;
-  static const int _CONTROLLER_STATE_PAUSED = 2;
-  static const int _CONTROLLER_STATE_CANCELED = 3;
+  static const int _controllerStateIdle = 0;
+  static const int _controllerStateActive = 1;
+  static const int _controllerStatePaused = 2;
+  static const int _controllerStateCanceled = 3;
 
-  int _controllerState = _CONTROLLER_STATE_IDLE;
+  int _controllerState = _controllerStateIdle;
 
   final _controller = StreamController<MimeMultipart>(sync: true);
 
@@ -110,7 +98,7 @@
   StreamController<List<int>>? _multipartController;
   Map<String, String>? _headers;
 
-  int _state = _START;
+  int _state = _startCode;
   int _boundaryIndex = 2;
 
   /// Current index into [_buffer].
@@ -125,11 +113,11 @@
       ..onPause = _pauseStream
       ..onResume = _resumeStream
       ..onCancel = () {
-        _controllerState = _CONTROLLER_STATE_CANCELED;
+        _controllerState = _controllerStateCanceled;
         _tryPropagateControllerState();
       }
       ..onListen = () {
-        _controllerState = _CONTROLLER_STATE_ACTIVE;
+        _controllerState = _controllerStateActive;
         _subscription = stream.listen((data) {
           assert(_buffer == _placeholderBuffer);
           _subscription.pause();
@@ -137,7 +125,7 @@
           _index = 0;
           _parse();
         }, onDone: () {
-          if (_state != _DONE) {
+          if (_state != _doneCode) {
             _controller
                 .addError(MimeMultipartException('Bad multipart ending'));
           }
@@ -147,26 +135,26 @@
   }
 
   void _resumeStream() {
-    assert(_controllerState == _CONTROLLER_STATE_PAUSED);
-    _controllerState = _CONTROLLER_STATE_ACTIVE;
+    assert(_controllerState == _controllerStatePaused);
+    _controllerState = _controllerStateActive;
     _tryPropagateControllerState();
   }
 
   void _pauseStream() {
-    _controllerState = _CONTROLLER_STATE_PAUSED;
+    _controllerState = _controllerStatePaused;
     _tryPropagateControllerState();
   }
 
   void _tryPropagateControllerState() {
     if (_multipartController == null) {
       switch (_controllerState) {
-        case _CONTROLLER_STATE_ACTIVE:
+        case _controllerStateActive:
           if (_subscription.isPaused) _subscription.resume();
           break;
-        case _CONTROLLER_STATE_PAUSED:
+        case _controllerStatePaused:
           if (!_subscription.isPaused) _subscription.pause();
           break;
-        case _CONTROLLER_STATE_CANCELED:
+        case _controllerStateCanceled:
           _subscription.cancel();
           break;
         default:
@@ -185,7 +173,7 @@
     // boundary prefix. Will be zero or position if the content starts
     // in the current buffer.
     var contentStartIndex =
-        _state == _CONTENT && _boundaryIndex == 0 ? 0 : null;
+        _state == _contentCode && _boundaryIndex == 0 ? 0 : null;
 
     // Function to report content data for the current part. The data
     // reported is from the current content start index up til the
@@ -209,15 +197,16 @@
       }
     }
 
-    while (_index < _buffer.length && _state != _FAIL && _state != _DONE) {
+    while (
+        _index < _buffer.length && _state != _failCode && _state != _doneCode) {
       var byte =
           _index < 0 ? _boundary[boundaryPrefix + _index] : _buffer[_index];
       switch (_state) {
-        case _START:
+        case _startCode:
           if (byte == _boundary[_boundaryIndex]) {
             _boundaryIndex++;
             if (_boundaryIndex == _boundary.length) {
-              _state = _BOUNDARY_ENDING;
+              _state = _boundaryEndingCode;
               _boundaryIndex = 0;
             }
           } else {
@@ -227,40 +216,40 @@
           }
           break;
 
-        case _BOUNDARY_ENDING:
-          if (byte == CharCode.CR) {
-            _state = _BOUNDARY_END;
-          } else if (byte == CharCode.DASH) {
-            _state = _LAST_BOUNDARY_DASH2;
+        case _boundaryEndingCode:
+          if (byte == char_code.cr) {
+            _state = _boundaryEndCode;
+          } else if (byte == char_code.dash) {
+            _state = _lastBoundaryDash2Code;
           } else {
             _expectWhitespace(byte);
           }
           break;
 
-        case _BOUNDARY_END:
-          _expectByteValue(byte, CharCode.LF);
+        case _boundaryEndCode:
+          _expectByteValue(byte, char_code.lf);
           _multipartController?.close();
           if (_multipartController != null) {
             _multipartController = null;
             _tryPropagateControllerState();
           }
-          _state = _HEADER_START;
+          _state = _headerStartCode;
           break;
 
-        case _HEADER_START:
+        case _headerStartCode:
           _headers = <String, String>{};
-          if (byte == CharCode.CR) {
-            _state = _HEADER_ENDING;
+          if (byte == char_code.cr) {
+            _state = _headerEndingCode;
           } else {
             // Start of new header field.
             _headerField.add(_toLowerCase(byte));
-            _state = _HEADER_FIELD;
+            _state = _headerFieldCode;
           }
           break;
 
-        case _HEADER_FIELD:
-          if (byte == CharCode.COLON) {
-            _state = _HEADER_VALUE_START;
+        case _headerFieldCode:
+          if (byte == char_code.colon) {
+            _state = _headerValueStartCode;
           } else {
             if (!_isTokenChar(byte)) {
               throw MimeMultipartException('Invalid header field name');
@@ -269,50 +258,50 @@
           }
           break;
 
-        case _HEADER_VALUE_START:
-          if (byte == CharCode.CR) {
-            _state = _HEADER_VALUE_FOLDING_OR_ENDING;
-          } else if (byte != CharCode.SP && byte != CharCode.HT) {
+        case _headerValueStartCode:
+          if (byte == char_code.cr) {
+            _state = _headerValueFoldingOrEndingCode;
+          } else if (byte != char_code.sp && byte != char_code.ht) {
             // Start of new header value.
             _headerValue.add(byte);
-            _state = _HEADER_VALUE;
+            _state = _headerValueCode;
           }
           break;
 
-        case _HEADER_VALUE:
-          if (byte == CharCode.CR) {
-            _state = _HEADER_VALUE_FOLDING_OR_ENDING;
+        case _headerValueCode:
+          if (byte == char_code.cr) {
+            _state = _headerValueFoldingOrEndingCode;
           } else {
             _headerValue.add(byte);
           }
           break;
 
-        case _HEADER_VALUE_FOLDING_OR_ENDING:
-          _expectByteValue(byte, CharCode.LF);
-          _state = _HEADER_VALUE_FOLD_OR_END;
+        case _headerValueFoldingOrEndingCode:
+          _expectByteValue(byte, char_code.lf);
+          _state = _headerValueFoldOrEndCode;
           break;
 
-        case _HEADER_VALUE_FOLD_OR_END:
-          if (byte == CharCode.SP || byte == CharCode.HT) {
-            _state = _HEADER_VALUE_START;
+        case _headerValueFoldOrEndCode:
+          if (byte == char_code.sp || byte == char_code.ht) {
+            _state = _headerValueStartCode;
           } else {
             var headerField = utf8.decode(_headerField);
             var headerValue = utf8.decode(_headerValue);
             _headers![headerField.toLowerCase()] = headerValue;
             _headerField.clear();
             _headerValue.clear();
-            if (byte == CharCode.CR) {
-              _state = _HEADER_ENDING;
+            if (byte == char_code.cr) {
+              _state = _headerEndingCode;
             } else {
               // Start of new header field.
               _headerField.add(_toLowerCase(byte));
-              _state = _HEADER_FIELD;
+              _state = _headerFieldCode;
             }
           }
           break;
 
-        case _HEADER_ENDING:
-          _expectByteValue(byte, CharCode.LF);
+        case _headerEndingCode:
+          _expectByteValue(byte, char_code.lf);
           _multipartController = StreamController(
               sync: true,
               onListen: () {
@@ -323,11 +312,11 @@
           _controller
               .add(_MimeMultipart(_headers!, _multipartController!.stream));
           _headers = null;
-          _state = _CONTENT;
+          _state = _contentCode;
           contentStartIndex = _index + 1;
           break;
 
-        case _CONTENT:
+        case _contentCode:
           if (byte == _boundary[_boundaryIndex]) {
             _boundaryIndex++;
             if (_boundaryIndex == _boundary.length) {
@@ -340,7 +329,7 @@
               _multipartController = null;
               _tryPropagateControllerState();
               _boundaryIndex = 0;
-              _state = _BOUNDARY_ENDING;
+              _state = _boundaryEndingCode;
             }
           } else {
             // Restart matching of the boundary.
@@ -350,27 +339,27 @@
           }
           break;
 
-        case _LAST_BOUNDARY_DASH2:
-          _expectByteValue(byte, CharCode.DASH);
-          _state = _LAST_BOUNDARY_ENDING;
+        case _lastBoundaryDash2Code:
+          _expectByteValue(byte, char_code.dash);
+          _state = _lastBoundaryEndingCode;
           break;
 
-        case _LAST_BOUNDARY_ENDING:
-          if (byte == CharCode.CR) {
-            _state = _LAST_BOUNDARY_END;
+        case _lastBoundaryEndingCode:
+          if (byte == char_code.cr) {
+            _state = _lastBoundaryEndCode;
           } else {
             _expectWhitespace(byte);
           }
           break;
 
-        case _LAST_BOUNDARY_END:
-          _expectByteValue(byte, CharCode.LF);
+        case _lastBoundaryEndCode:
+          _expectByteValue(byte, char_code.lf);
           _multipartController?.close();
           if (_multipartController != null) {
             _multipartController = null;
             _tryPropagateControllerState();
           }
-          _state = _DONE;
+          _state = _doneCode;
           break;
 
         default:
@@ -384,7 +373,7 @@
     }
 
     // Report any known content.
-    if (_state == _CONTENT && contentStartIndex != null) {
+    if (_state == _contentCode && contentStartIndex != null) {
       reportData();
     }
 
diff --git a/lib/src/char_code.dart b/lib/src/char_code.dart
index f455e68..4cca1b1 100644
--- a/lib/src/char_code.dart
+++ b/lib/src/char_code.dart
@@ -1,16 +1,13 @@
 // Copyright (c) 2014, the Dart project authors.  Please see the AUTHORS file
 // 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.char_code;
 
-class CharCode {
-  static const int HT = 9;
-  static const int LF = 10;
-  static const int CR = 13;
-  static const int SP = 32;
-  static const int DASH = 45;
-  static const int COLON = 58;
-  static const int UPPER_A = 65;
-  static const int UPPER_Z = 90;
-  static const int LOWER_A = 97;
-}
+const int ht = 9;
+const int lf = 10;
+const int cr = 13;
+const int sp = 32;
+const int dash = 45;
+const int colon = 58;
+const int upperA = 65;
+const int upperZ = 90;
+const int lowerA = 97;
diff --git a/lib/src/default_extension_map.dart b/lib/src/default_extension_map.dart
index d951b23..fa5c99a 100644
--- a/lib/src/default_extension_map.dart
+++ b/lib/src/default_extension_map.dart
@@ -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.extension_map;
-
 const Map<String, String> defaultExtensionMap = <String, String>{
   '123': 'application/vnd.lotus-1-2-3',
   '3dml': 'text/vnd.in3d.3dml',
diff --git a/lib/src/magic_number.dart b/lib/src/magic_number.dart
index 8933677..9db370f 100644
--- a/lib/src/magic_number.dart
+++ b/lib/src/magic_number.dart
@@ -26,9 +26,9 @@
   }
 }
 
-const int DEFAULT_MAGIC_NUMBERS_MAX_LENGTH = 12;
+const int initialMagicNumbersMaxLength = 12;
 
-const List<MagicNumber> DEFAULT_MAGIC_NUMBERS = [
+const List<MagicNumber> initialMagicNumbers = [
   MagicNumber('application/pdf', [0x25, 0x50, 0x44, 0x46]),
   MagicNumber('application/postscript', [0x25, 0x51]),
   MagicNumber('image/gif', [0x47, 0x49, 0x46, 0x38, 0x37, 0x61]),
diff --git a/lib/src/mime_multipart_transformer.dart b/lib/src/mime_multipart_transformer.dart
index 1869480..a3da857 100644
--- a/lib/src/mime_multipart_transformer.dart
+++ b/lib/src/mime_multipart_transformer.dart
@@ -1,13 +1,12 @@
 // Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file
 // 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.multipart_transformer;
 
 import 'dart:async';
 import 'dart:typed_data';
 
 import 'bound_multipart_stream.dart';
-import 'char_code.dart';
+import 'char_code.dart' as char_code;
 import 'mime_shared.dart';
 
 Uint8List _getBoundary(String boundary) {
@@ -16,10 +15,10 @@
   var boundaryList = Uint8List(4 + charCodes.length);
   // Set-up the matching boundary preceding it with CRLF and two
   // dashes.
-  boundaryList[0] = CharCode.CR;
-  boundaryList[1] = CharCode.LF;
-  boundaryList[2] = CharCode.DASH;
-  boundaryList[3] = CharCode.DASH;
+  boundaryList[0] = char_code.cr;
+  boundaryList[1] = char_code.lf;
+  boundaryList[2] = char_code.dash;
+  boundaryList[3] = char_code.dash;
   boundaryList.setRange(4, 4 + charCodes.length, charCodes);
   return boundaryList;
 }
@@ -38,7 +37,6 @@
       : _boundary = _getBoundary(boundary);
 
   @override
-  Stream<MimeMultipart> bind(Stream<List<int>> stream) {
-    return BoundMultipartStream(_boundary, stream).stream;
-  }
+  Stream<MimeMultipart> bind(Stream<List<int>> stream) =>
+      BoundMultipartStream(_boundary, stream).stream;
 }
diff --git a/lib/src/mime_shared.dart b/lib/src/mime_shared.dart
index 61e81f2..2a29ae0 100644
--- a/lib/src/mime_shared.dart
+++ b/lib/src/mime_shared.dart
@@ -1,7 +1,6 @@
 // Copyright (c) 2014, the Dart project authors.  Please see the AUTHORS file
 // 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.shared;
 
 class MimeMultipartException implements Exception {
   final String message;
diff --git a/lib/src/mime_type.dart b/lib/src/mime_type.dart
index 14db942..e72806e 100644
--- a/lib/src/mime_type.dart
+++ b/lib/src/mime_type.dart
@@ -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.mime_type;
-
 import 'default_extension_map.dart';
 import 'magic_number.dart';
 
@@ -54,7 +52,7 @@
   /// Create a new [MimeTypeResolver] containing the default scope.
   MimeTypeResolver()
       : _useDefault = true,
-        _magicNumbersMaxLength = DEFAULT_MAGIC_NUMBERS_MAX_LENGTH;
+        _magicNumbersMaxLength = initialMagicNumbersMaxLength;
 
   /// Get the maximum number of bytes required to match all magic numbers, when
   /// performing [lookup] with headerBytes present.
@@ -75,7 +73,7 @@
       result = _matchMagic(headerBytes, _magicNumbers);
       if (result != null) return result;
       if (_useDefault) {
-        result = _matchMagic(headerBytes, DEFAULT_MAGIC_NUMBERS);
+        result = _matchMagic(headerBytes, initialMagicNumbers);
         if (result != null) return result;
       }
     }
diff --git a/test/mime_multipart_transformer_test.dart b/test/mime_multipart_transformer_test.dart
index d503bcb..4e5ed04 100644
--- a/test/mime_multipart_transformer_test.dart
+++ b/test/mime_multipart_transformer_test.dart
@@ -20,12 +20,16 @@
   controller.close();
 }
 
-enum TestMode { IMMEDIATE_LISTEN, DELAY_LISTEN, PAUSE_RESUME }
+enum TestMode { immediateListen, delayListen, pauseResume }
 
-void _runParseTest(String message, String boundary, TestMode mode,
-    [List<Map>? expectedHeaders,
-    List? expectedParts,
-    bool expectError = false]) {
+void _runParseTest(
+  String message,
+  String boundary,
+  TestMode mode, [
+  List<Map>? expectedHeaders,
+  List<String?>? expectedParts,
+  bool expectError = false,
+]) {
   Future testWrite(List<int> data, [int chunkSize = -1]) {
     var controller = StreamController<List<int>>(sync: true);
 
@@ -40,41 +44,48 @@
         expect(multipart.headers, equals(expectedHeaders[part]));
       }
       switch (mode) {
-        case TestMode.IMMEDIATE_LISTEN:
+        case TestMode.immediateListen:
           futures.add(multipart.fold<List<int>>(
               [], (buffer, data) => buffer..addAll(data)).then((data) {
             if (expectedParts?[part] != null) {
-              expect(data, equals(expectedParts?[part].codeUnits));
+              expect(data, equals(expectedParts?[part]!.codeUnits));
             }
           }));
           break;
 
-        case TestMode.DELAY_LISTEN:
-          futures.add(Future(() {
-            return multipart.fold<List<int>>(
-                [], (buffer, data) => buffer..addAll(data)).then((data) {
-              if (expectedParts?[part] != null) {
-                expect(data, equals(expectedParts?[part].codeUnits));
-              }
-            });
-          }));
+        case TestMode.delayListen:
+          futures.add(
+            Future(
+              () => multipart.fold<List<int>>(
+                [],
+                (buffer, data) => buffer..addAll(data),
+              ).then(
+                (data) {
+                  if (expectedParts?[part] != null) {
+                    expect(data, equals(expectedParts?[part]!.codeUnits));
+                  }
+                },
+              ),
+            ),
+          );
           break;
 
-        case TestMode.PAUSE_RESUME:
+        case TestMode.pauseResume:
           var completer = Completer();
           futures.add(completer.future);
           var buffer = [];
-          var subscription;
+          late StreamSubscription subscription;
           subscription = multipart.listen((data) {
             buffer.addAll(data);
             subscription.pause();
             Future(() => subscription.resume());
           }, onDone: () {
             if (expectedParts?[part] != null) {
-              expect(buffer, equals(expectedParts?[part].codeUnits));
+              expect(buffer, equals(expectedParts?[part]!.codeUnits));
             }
             completer.complete();
           });
+          addTearDown(subscription.cancel);
           break;
       }
     }, onError: (Object error) {
@@ -102,12 +113,13 @@
       if (expectedHeaders != null) {
         expect(multipart.headers, equals(expectedHeaders[0]));
       }
-      return (multipart
-          .fold<List<int>>([], (b, d) => b..addAll(d)).then((data) {
-        if (expectedParts != null && expectedParts[0] != null) {
-          expect(data, equals(expectedParts[0].codeUnits));
-        }
-      }));
+      return multipart.fold<List<int>>([], (b, d) => b..addAll(d)).then(
+        (data) {
+          if (expectedParts != null && expectedParts[0] != null) {
+            expect(data, equals(expectedParts[0]!.codeUnits));
+          }
+        },
+      );
     }).then((_) {
       completer.complete();
     });
@@ -123,7 +135,7 @@
     var controller = StreamController<List<int>>(sync: true);
     var stream =
         controller.stream.transform(MimeMultipartTransformer(boundary));
-    var subscription;
+    late StreamSubscription subscription;
     var i = 0;
     var futures = <Future>[];
     subscription = stream.listen((multipart) {
@@ -137,11 +149,11 @@
         expect(multipart.headers, equals(expectedHeaders[partIndex]));
       }
       futures.add(
-          (multipart.fold<List<int>>([], (b, d) => b..addAll(d)).then((data) {
+          multipart.fold<List<int>>([], (b, d) => b..addAll(d)).then((data) {
         if (expectedParts != null && expectedParts[partIndex] != null) {
-          expect(data, equals(expectedParts[partIndex].codeUnits));
+          expect(data, equals(expectedParts[partIndex]!.codeUnits));
         }
-      })));
+      }));
 
       if (partIndex == (parts - 1)) {
         subscription.cancel();
@@ -199,13 +211,13 @@
 
 void _testParse(String message, String boundary,
     [List<Map>? expectedHeaders,
-    List? expectedParts,
+    List<String?>? expectedParts,
     bool expectError = false]) {
-  _runParseTest(message, boundary, TestMode.IMMEDIATE_LISTEN, expectedHeaders,
+  _runParseTest(message, boundary, TestMode.immediateListen, expectedHeaders,
       expectedParts, expectError);
-  _runParseTest(message, boundary, TestMode.DELAY_LISTEN, expectedHeaders,
+  _runParseTest(message, boundary, TestMode.delayListen, expectedHeaders,
       expectedParts, expectError);
-  _runParseTest(message, boundary, TestMode.PAUSE_RESUME, expectedHeaders,
+  _runParseTest(message, boundary, TestMode.pauseResume, expectedHeaders,
       expectedParts, expectError);
 }
 
diff --git a/test/mime_type_test.dart b/test/mime_type_test.dart
index a116bf3..4dfdb13 100644
--- a/test/mime_type_test.dart
+++ b/test/mime_type_test.dart
@@ -117,11 +117,12 @@
   });
 
   test('default magic number', () {
-    var actualMaxBytes = DEFAULT_MAGIC_NUMBERS.fold(0, (num previous, magic) {
-      return math.max(previous, magic.numbers.length);
-    });
+    var actualMaxBytes = initialMagicNumbers.fold<int>(
+      0,
+      (previous, magic) => math.max(previous, magic.numbers.length),
+    );
 
-    expect(defaultMagicNumbersMaxLength, actualMaxBytes);
+    expect(initialMagicNumbersMaxLength, actualMaxBytes);
   });
 
   group('extensionFromMime', () {