Lint cleanup: initialize to null, return values on setter, comment syntax
diff --git a/pkgs/web_socket_channel/lib/src/copy/bytes_builder.dart b/pkgs/web_socket_channel/lib/src/copy/bytes_builder.dart
index 1d88199..429e6d1 100644
--- a/pkgs/web_socket_channel/lib/src/copy/bytes_builder.dart
+++ b/pkgs/web_socket_channel/lib/src/copy/bytes_builder.dart
@@ -14,21 +14,17 @@
import 'dart:math';
import 'dart:typed_data';
-/**
- * Builds a list of bytes, allowing bytes and lists of bytes to be added at the
- * end.
- *
- * Used to efficiently collect bytes and lists of bytes.
- */
+/// Builds a list of bytes, allowing bytes and lists of bytes to be added at the
+/// end.
+///
+/// Used to efficiently collect bytes and lists of bytes.
abstract class BytesBuilder {
- /**
- * Construct a new empty [BytesBuilder].
- *
- * If [copy] is true, the data is always copied when added to the list. If
- * 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`.
- */
+ /// Construct a new empty [BytesBuilder].
+ ///
+ /// If [copy] is true, the data is always copied when added to the list. If
+ /// 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}) {
if (copy) {
return new _CopyingBytesBuilder();
@@ -37,54 +33,38 @@
}
}
- /**
- * Appends [bytes] to the current contents of the builder.
- *
- * Each value of [bytes] will be bit-representation truncated to the range
- * 0 .. 255.
- */
+ /// Appends [bytes] to the current contents of the builder.
+ ///
+ /// Each value of [bytes] will be bit-representation truncated to the range
+ /// 0 .. 255.
void add(List<int> bytes);
- /**
- * Append [byte] to the current contents of the builder.
- *
- * The [byte] will be bit-representation truncated to the range 0 .. 255.
- */
+ /// Append [byte] to the current contents of the builder.
+ ///
+ /// The [byte] will be bit-representation truncated to the range 0 .. 255.
void addByte(int byte);
- /**
- * Returns the contents of `this` and clears `this`.
- *
- * The list returned is a view of the the internal buffer, limited to the
- * [length].
- */
+ /// Returns the contents of `this` and clears `this`.
+ ///
+ /// The list returned is a view of the the internal buffer, limited to the
+ /// [length].
List<int> takeBytes();
- /**
- * Returns a copy of the current contents of the builder.
- *
- * Leaves the contents of the builder intact.
- */
+ /// Returns a copy of the current contents of the builder.
+ ///
+ /// Leaves the contents of the builder intact.
List<int> toBytes();
- /**
- * The number of bytes in the builder.
- */
+ /// The number of bytes in the builder.
int get length;
- /**
- * Returns `true` if the buffer is empty.
- */
+ /// Returns `true` if the buffer is empty.
bool get isEmpty;
- /**
- * Returns `true` if the buffer is not empty.
- */
+ /// Returns `true` if the buffer is not empty.
bool get isNotEmpty;
- /**
- * Clear the contents of the builder.
- */
+ /// Clear the contents of the builder.
void clear();
}
diff --git a/pkgs/web_socket_channel/lib/src/copy/web_socket.dart b/pkgs/web_socket_channel/lib/src/copy/web_socket.dart
index c77dc2f..c08b9ac 100644
--- a/pkgs/web_socket_channel/lib/src/copy/web_socket.dart
+++ b/pkgs/web_socket_channel/lib/src/copy/web_socket.dart
@@ -11,9 +11,7 @@
// This is up-to-date as of sdk revision
// e41fb4cafd6052157dbc1490d437045240f4773f.
-/**
- * Web socket status codes used when closing a web socket connection.
- */
+/// Web socket status codes used when closing a web socket connection.
abstract class WebSocketStatus {
static const int NORMAL_CLOSURE = 1000;
static const int GOING_AWAY = 1001;
@@ -31,9 +29,7 @@
}
abstract class WebSocket {
- /**
- * Possible states of the connection.
- */
+ /// Possible states of the connection.
static const int CONNECTING = 0;
static const int OPEN = 1;
static const int CLOSING = 2;
diff --git a/pkgs/web_socket_channel/lib/src/copy/web_socket_impl.dart b/pkgs/web_socket_channel/lib/src/copy/web_socket_impl.dart
index e1c4d88..8996619 100644
--- a/pkgs/web_socket_channel/lib/src/copy/web_socket_impl.dart
+++ b/pkgs/web_socket_channel/lib/src/copy/web_socket_impl.dart
@@ -57,15 +57,13 @@
static const int RESERVED_F = 15;
}
-/**
- * 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.
- *
- * Important information about usage: Be sure you use cancelOnError, so the
- * socket will be closed when the processor encounter an error. Not using it
- * will lead to undefined behaviour.
- */
+/// 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.
+///
+/// Important information about usage: Be sure you use cancelOnError, so the
+/// socket will be closed when the processor encounter an error. Not using it
+/// will lead to undefined behaviour.
// TODO(ajohnsen): make this transformer reusable?
class _WebSocketProtocolTransformer
implements StreamTransformer<List<int>, dynamic>, EventSink<List<int>> {
@@ -121,9 +119,7 @@
_eventSink.close();
}
- /**
- * Process data received from the underlying communication channel.
- */
+ /// Process data received from the underlying communication channel.
void add(List<int> bytes) {
var buffer = bytes is Uint8List ? bytes : new Uint8List.fromList(bytes);
int index = 0;
@@ -386,12 +382,12 @@
class _WebSocketPing {
final List<int> payload;
- _WebSocketPing([this.payload = null]);
+ _WebSocketPing([this.payload]);
}
class _WebSocketPong {
final List<int> payload;
- _WebSocketPong([this.payload = null]);
+ _WebSocketPong([this.payload]);
}
// TODO(ajohnsen): Make this transformer reusable.
@@ -567,7 +563,7 @@
StreamSubscription _subscription;
bool _issuedPause = false;
bool _closed = false;
- Completer _closeCompleter = new Completer();
+ final Completer _closeCompleter = new Completer();
Completer _completer;
_WebSocketConsumer(this.webSocket, this.sink);
@@ -681,7 +677,8 @@
class WebSocketImpl extends Stream with _ServiceObject implements StreamSink {
// Use default Map so we keep order.
- static Map<int, WebSocketImpl> _webSockets = new Map<int, WebSocketImpl>();
+ static final Map<int, WebSocketImpl> _webSockets =
+ new Map<int, WebSocketImpl>();
static const int DEFAULT_WINDOW_BITS = 15;
static const String PER_MESSAGE_DEFLATE = "permessage-deflate";
@@ -770,7 +767,7 @@
Duration get pingInterval => _pingInterval;
- void set pingInterval(Duration interval) {
+ set pingInterval(Duration interval) {
if (_writeClosed) return;
if (_pingTimer != null) _pingTimer.cancel();
_pingInterval = interval;