enable and fix a number of lints
diff --git a/.travis.yml b/.travis.yml
index d8ab216..1bb80fe 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,16 +1,14 @@
language: dart
-sudo: false
-dart: dev
+
+dart:
+- 2.0.0
+- dev
dart_task:
- test: --platform vm
- test: --platform firefox -j 1
- - dartanalyzer --fatal-infos --fatal-warnings
-
-matrix:
- include:
- - dart: dev
- dart_task: dartfmt
+ - dartanalyzer: --fatal-infos --fatal-warnings .
+ - dartfmt
# Only building master means that we don't run two builds for each pull request.
branches:
diff --git a/analysis_options.yaml b/analysis_options.yaml
new file mode 100644
index 0000000..cc05835
--- /dev/null
+++ b/analysis_options.yaml
@@ -0,0 +1,8 @@
+include: package:pedantic/analysis_options.yaml
+linter:
+ rules:
+ - prefer_equal_for_default_values
+ - prefer_generic_function_type_aliases
+ - slash_for_doc_comments
+ - unnecessary_const
+ - unnecessary_new
diff --git a/lib/html.dart b/lib/html.dart
index 3a34572..e2dc145 100644
--- a/lib/html.dart
+++ b/lib/html.dart
@@ -142,10 +142,10 @@
/// messages.
class BinaryType {
/// Tells the channel to emit binary messages as [Blob]s.
- static const blob = const BinaryType._("blob", "blob");
+ static const blob = BinaryType._("blob", "blob");
/// Tells the channel to emit binary messages as [Uint8List]s.
- static const list = const BinaryType._("list", "arraybuffer");
+ static const list = BinaryType._("list", "arraybuffer");
/// The name of the binary type, which matches its variable name.
final String name;
diff --git a/lib/src/channel.dart b/lib/src/channel.dart
index d701792..bbdaf34 100644
--- a/lib/src/channel.dart
+++ b/lib/src/channel.dart
@@ -90,7 +90,7 @@
///
/// [WebSocket handshake]: https://tools.ietf.org/html/rfc6455#section-4
WebSocketChannel(StreamChannel<List<int>> channel,
- {String protocol, Duration pingInterval, bool serverSide: true})
+ {String protocol, Duration pingInterval, bool serverSide = true})
: _webSocket = WebSocketImpl.fromSocket(
channel.stream, channel.sink, protocol, serverSide)
..pingInterval = pingInterval;
diff --git a/lib/src/copy/bytes_builder.dart b/lib/src/copy/bytes_builder.dart
index dfa392b..fed15ad 100644
--- a/lib/src/copy/bytes_builder.dart
+++ b/lib/src/copy/bytes_builder.dart
@@ -24,7 +24,7 @@
/// it [copy] is false, the data is only copied if needed. That means that if
/// the lists are changed after added to the [BytesBuilder], it may effect the
/// output. Default is `true`.
- factory BytesBuilder({bool copy: true}) {
+ factory BytesBuilder({bool copy = true}) {
if (copy) {
return _CopyingBytesBuilder();
} else {
diff --git a/lib/src/copy/web_socket_impl.dart b/lib/src/copy/web_socket_impl.dart
index 36ebd23..6ac07cf 100644
--- a/lib/src/copy/web_socket_impl.dart
+++ b/lib/src/copy/web_socket_impl.dart
@@ -52,11 +52,6 @@
static const int RESERVED_F = 15;
}
-class _EncodedString {
- final List<int> bytes;
- _EncodedString(this.bytes);
-}
-
/// The web socket protocol transformer handles the protocol byte stream
/// which is supplied through the `handleData`. As the protocol is processed,
/// it'll output frame data as either a List<int> or String.
@@ -334,7 +329,7 @@
case _WebSocketOpcode.CLOSE:
closeCode = WebSocketStatus.NO_STATUS_RECEIVED;
var payload = _payload.takeBytes();
- if (payload.length > 0) {
+ if (payload.isNotEmpty) {
if (payload.length == 1) {
throw WebSocketChannelException("Protocol error");
}
@@ -426,9 +421,6 @@
} else if (message is List<int>) {
opcode = _WebSocketOpcode.BINARY;
data = message;
- } else if (message is _EncodedString) {
- opcode = _WebSocketOpcode.TEXT;
- data = message.bytes;
} else {
throw ArgumentError(message);
}
diff --git a/pubspec.yaml b/pubspec.yaml
index 8f1bf89..d4aee51 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,5 +1,5 @@
name: web_socket_channel
-version: 1.0.9
+version: 1.0.10-dev
description: StreamChannel wrappers for WebSockets. This package provides a cross-platform WebSocketChannel API, a cross-platform implementation of that API that communicates over an underlying StreamChannel, IOWebSocketChannel that wraps dart:io's WebSocket class, and a HtmlWebSocketChannel that wrap's dart:html's.
author: Dart Team <misc@dartlang.org>
@@ -14,4 +14,5 @@
stream_channel: ^1.2.0
dev_dependencies:
+ pedantic:
test: ^1.2.0
diff --git a/test/io_test.dart b/test/io_test.dart
index 187c1c9..f8f6325 100644
--- a/test/io_test.dart
+++ b/test/io_test.dart
@@ -82,7 +82,7 @@
});
var channel = IOWebSocketChannel.connect("ws://localhost:${server.port}");
- channel.sink.close(5678, "raisin");
+ await channel.sink.close(5678, "raisin");
});
test(".connect wraps a connection error in WebSocketChannelException",
diff --git a/test/web_socket_test.dart b/test/web_socket_test.dart
index dab9656..0d63323 100644
--- a/test/web_socket_test.dart
+++ b/test/web_socket_test.dart
@@ -76,7 +76,7 @@
var message = await webSocket.stream.first;
expect(message, equals("ping"));
webSocket.sink.add("pong");
- webSocket.sink.close();
+ await webSocket.sink.close();
});
var webSocket = await WebSocket.connect('ws://localhost:${server.port}');