Skip to content

Commit

Permalink
Lint cleanup: initialize to null, return values on setter, comment sy…
Browse files Browse the repository at this point in the history
…ntax
  • Loading branch information
kevmoo committed Aug 4, 2017
1 parent bc2dcd4 commit 441883b
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 71 deletions.
76 changes: 28 additions & 48 deletions lib/src/copy/bytes_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -37,54 +33,38 @@ abstract class BytesBuilder {
}
}

/**
* 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();
}

Expand Down
8 changes: 2 additions & 6 deletions lib/src/copy/web_socket.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -31,9 +29,7 @@ abstract class WebSocketStatus {
}

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;
Expand Down
31 changes: 14 additions & 17 deletions lib/src/copy/web_socket_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,13 @@ class _WebSocketOpcode {
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>> {
Expand Down Expand Up @@ -121,9 +119,7 @@ class _WebSocketProtocolTransformer
_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;
Expand Down Expand Up @@ -386,12 +382,12 @@ class _WebSocketProtocolTransformer

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.
Expand Down Expand Up @@ -567,7 +563,7 @@ class _WebSocketConsumer implements StreamConsumer {
StreamSubscription _subscription;
bool _issuedPause = false;
bool _closed = false;
Completer _closeCompleter = new Completer();
final Completer _closeCompleter = new Completer();
Completer _completer;

_WebSocketConsumer(this.webSocket, this.sink);
Expand Down Expand Up @@ -681,7 +677,8 @@ class _WebSocketConsumer implements StreamConsumer {

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";

Expand Down Expand Up @@ -770,7 +767,7 @@ class WebSocketImpl extends Stream with _ServiceObject implements StreamSink {

Duration get pingInterval => _pingInterval;

void set pingInterval(Duration interval) {
set pingInterval(Duration interval) {
if (_writeClosed) return;
if (_pingTimer != null) _pingTimer.cancel();
_pingInterval = interval;
Expand Down

0 comments on commit 441883b

Please # to comment.