Skip to content

Commit 49bde5b

Browse files
authored
Enable and fix standard lints, test on oldest supported SDK (flutter#20)
1 parent 6467500 commit 49bde5b

20 files changed

+113
-73
lines changed

.travis.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,15 @@ language: dart
22

33
dart:
44
- dev
5-
- stable
5+
- 2.0.0
66

77
dart_task:
88
- test: --platform vm
99
- test: --platform chrome
10-
- dartanalyzer
11-
- dartfmt
10+
- dartanalyzer: --fatal-warnings --fatal-infos .
1211

1312
matrix:
14-
exclude:
13+
include:
1514
- dart: dev
1615
dart_task: dartfmt
1716

analysis_options.yaml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
include: package:pedantic/analysis_options.yaml
2+
analyzer:
3+
strong-mode:
4+
implicit-casts: false
5+
linter:
6+
rules:
7+
- avoid_empty_else
8+
- avoid_init_to_null
9+
- avoid_null_checks_in_equality_operators
10+
- avoid_unused_constructor_parameters
11+
- await_only_futures
12+
- camel_case_types
13+
- cancel_subscriptions
14+
- constant_identifier_names
15+
- control_flow_in_finally
16+
- directives_ordering
17+
- empty_catches
18+
- empty_constructor_bodies
19+
- empty_statements
20+
- hash_and_equals
21+
- implementation_imports
22+
- iterable_contains_unrelated_type
23+
- library_names
24+
- library_prefixes
25+
- list_remove_unrelated_type
26+
- non_constant_identifier_names
27+
- overridden_fields
28+
- package_api_docs
29+
- package_names
30+
- package_prefixed_library_names
31+
- prefer_equal_for_default_values
32+
- prefer_final_fields
33+
- prefer_generic_function_type_aliases
34+
- prefer_is_not_empty
35+
- slash_for_doc_comments
36+
- test_types_in_equals
37+
- throw_in_finally
38+
- type_init_formals
39+
- unnecessary_brace_in_string_interps
40+
- unnecessary_const
41+
- unnecessary_new
42+
- unrelated_type_equality_checks
43+
- valid_regexps

codereview.settings

Lines changed: 0 additions & 3 deletions
This file was deleted.

lib/src/accumulator_sink.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import 'dart:collection';
99
/// See also [ChunkedConversionSink.withCallback].
1010
class AccumulatorSink<T> implements Sink<T> {
1111
/// An unmodifiable list of events passed to this sink so far.
12-
List<T> get events => new UnmodifiableListView(_events);
12+
List<T> get events => UnmodifiableListView(_events);
1313
final _events = <T>[];
1414

1515
/// Whether [close] has been called.
@@ -25,7 +25,7 @@ class AccumulatorSink<T> implements Sink<T> {
2525

2626
void add(T event) {
2727
if (_isClosed) {
28-
throw new StateError("Can't add to a closed sink.");
28+
throw StateError("Can't add to a closed sink.");
2929
}
3030

3131
_events.add(event);

lib/src/byte_accumulator_sink.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ class ByteAccumulatorSink extends ByteConversionSinkBase {
1515
///
1616
/// The returned [Uint8List] is viewing a shared buffer, so it should not be
1717
/// changed and any bytes outside the view should not be accessed.
18-
Uint8List get bytes => new Uint8List.view(_buffer.buffer, 0, _buffer.length);
18+
Uint8List get bytes => Uint8List.view(_buffer.buffer, 0, _buffer.length);
1919

20-
final _buffer = new Uint8Buffer();
20+
final _buffer = Uint8Buffer();
2121

2222
/// Whether [close] has been called.
2323
bool get isClosed => _isClosed;
@@ -32,15 +32,15 @@ class ByteAccumulatorSink extends ByteConversionSinkBase {
3232

3333
void add(List<int> bytes) {
3434
if (_isClosed) {
35-
throw new StateError("Can't add to a closed sink.");
35+
throw StateError("Can't add to a closed sink.");
3636
}
3737

3838
_buffer.addAll(bytes);
3939
}
4040

4141
void addSlice(List<int> chunk, int start, int end, bool isLast) {
4242
if (_isClosed) {
43-
throw new StateError("Can't add to a closed sink.");
43+
throw StateError("Can't add to a closed sink.");
4444
}
4545

4646
_buffer.addAll(chunk, start, end);

lib/src/hex.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ library convert.hex;
66

77
import 'dart:convert';
88

9-
import 'hex/encoder.dart';
109
import 'hex/decoder.dart';
10+
import 'hex/encoder.dart';
1111

12-
export 'hex/encoder.dart' hide hexEncoder;
1312
export 'hex/decoder.dart' hide hexDecoder;
13+
export 'hex/encoder.dart' hide hexEncoder;
1414

1515
/// The canonical instance of [HexCodec].
16-
const hex = const HexCodec._();
16+
const hex = HexCodec._();
1717

1818
/// A codec that converts byte arrays to and from hexadecimal strings, following
1919
/// [the Base16 spec][rfc].

lib/src/hex/decoder.dart

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import 'dart:typed_data';
1010
import '../utils.dart';
1111

1212
/// The canonical instance of [HexDecoder].
13-
const hexDecoder = const HexDecoder._();
13+
const hexDecoder = HexDecoder._();
1414

1515
/// A converter that decodes hexadecimal strings into byte arrays.
1616
///
@@ -22,17 +22,17 @@ class HexDecoder extends Converter<String, List<int>> {
2222

2323
List<int> convert(String string) {
2424
if (!string.length.isEven) {
25-
throw new FormatException(
25+
throw FormatException(
2626
"Invalid input length, must be even.", string, string.length);
2727
}
2828

29-
var bytes = new Uint8List(string.length ~/ 2);
29+
var bytes = Uint8List(string.length ~/ 2);
3030
_decode(string.codeUnits, 0, string.length, bytes, 0);
3131
return bytes;
3232
}
3333

3434
StringConversionSink startChunkedConversion(Sink<List<int>> sink) =>
35-
new _HexDecoderSink(sink);
35+
_HexDecoderSink(sink);
3636
}
3737

3838
/// A conversion sink for chunked hexadecimal decoding.
@@ -61,11 +61,11 @@ class _HexDecoderSink extends StringConversionSinkBase {
6161
Uint8List bytes;
6262
int bytesStart;
6363
if (_lastDigit == null) {
64-
bytes = new Uint8List((end - start) ~/ 2);
64+
bytes = Uint8List((end - start) ~/ 2);
6565
bytesStart = 0;
6666
} else {
6767
var hexPairs = (end - start - 1) ~/ 2;
68-
bytes = new Uint8List(1 + hexPairs);
68+
bytes = Uint8List(1 + hexPairs);
6969
bytes[0] = _lastDigit + digitForCodeUnit(codeUnits, start);
7070
start++;
7171
bytesStart = 1;
@@ -78,15 +78,15 @@ class _HexDecoderSink extends StringConversionSinkBase {
7878
}
7979

8080
ByteConversionSink asUtf8Sink(bool allowMalformed) =>
81-
new _HexDecoderByteSink(_sink);
81+
_HexDecoderByteSink(_sink);
8282

8383
void close() => _close();
8484

8585
/// Like [close], but includes [string] and [index] in the [FormatException]
8686
/// if one is thrown.
8787
void _close([String string, int index]) {
8888
if (_lastDigit != null) {
89-
throw new FormatException(
89+
throw FormatException(
9090
"Input ended with incomplete encoded byte.", string, index);
9191
}
9292

@@ -121,11 +121,11 @@ class _HexDecoderByteSink extends ByteConversionSinkBase {
121121
Uint8List bytes;
122122
int bytesStart;
123123
if (_lastDigit == null) {
124-
bytes = new Uint8List((end - start) ~/ 2);
124+
bytes = Uint8List((end - start) ~/ 2);
125125
bytesStart = 0;
126126
} else {
127127
var hexPairs = (end - start - 1) ~/ 2;
128-
bytes = new Uint8List(1 + hexPairs);
128+
bytes = Uint8List(1 + hexPairs);
129129
bytes[0] = _lastDigit + digitForCodeUnit(chunk, start);
130130
start++;
131131
bytesStart = 1;
@@ -143,7 +143,7 @@ class _HexDecoderByteSink extends ByteConversionSinkBase {
143143
/// if one is thrown.
144144
void _close([List<int> chunk, int index]) {
145145
if (_lastDigit != null) {
146-
throw new FormatException(
146+
throw FormatException(
147147
"Input ended with incomplete encoded byte.", chunk, index);
148148
}
149149

lib/src/hex/encoder.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import 'dart:typed_data';
1010
import 'package:charcode/ascii.dart';
1111

1212
/// The canonical instance of [HexEncoder].
13-
const hexEncoder = const HexEncoder._();
13+
const hexEncoder = HexEncoder._();
1414

1515
/// A converter that encodes byte arrays into hexadecimal strings.
1616
///
@@ -22,7 +22,7 @@ class HexEncoder extends Converter<List<int>, String> {
2222
String convert(List<int> bytes) => _convert(bytes, 0, bytes.length);
2323

2424
ByteConversionSink startChunkedConversion(Sink<String> sink) =>
25-
new _HexEncoderSink(sink);
25+
_HexEncoderSink(sink);
2626
}
2727

2828
/// A conversion sink for chunked hexadecimal encoding.
@@ -51,7 +51,7 @@ String _convert(List<int> bytes, int start, int end) {
5151
// A Uint8List is more efficient than a StringBuffer given that we know that
5252
// we're only emitting ASCII-compatible characters, and that we know the
5353
// length ahead of time.
54-
var buffer = new Uint8List((end - start) * 2);
54+
var buffer = Uint8List((end - start) * 2);
5555
var bufferIndex = 0;
5656

5757
// A bitwise OR of all bytes in [bytes]. This allows us to check for
@@ -69,13 +69,13 @@ String _convert(List<int> bytes, int start, int end) {
6969
buffer[bufferIndex++] = _codeUnitForDigit(byte & 0x0F);
7070
}
7171

72-
if (byteOr >= 0 && byteOr <= 255) return new String.fromCharCodes(buffer);
72+
if (byteOr >= 0 && byteOr <= 255) return String.fromCharCodes(buffer);
7373

7474
// If there was an invalid byte, find it and throw an exception.
7575
for (var i = start; i < end; i++) {
7676
var byte = bytes[i];
7777
if (byte >= 0 && byte <= 0xff) continue;
78-
throw new FormatException(
78+
throw FormatException(
7979
"Invalid byte ${byte < 0 ? "-" : ""}0x${byte.abs().toRadixString(16)}.",
8080
bytes,
8181
i);

lib/src/identity_codec.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ class _IdentityConverter<T> extends Converter<T, T> {
1717
class IdentityCodec<T> extends Codec<T, T> {
1818
const IdentityCodec();
1919

20-
Converter<T, T> get decoder => new _IdentityConverter<T>();
21-
Converter<T, T> get encoder => new _IdentityConverter<T>();
20+
Converter<T, T> get decoder => _IdentityConverter<T>();
21+
Converter<T, T> get encoder => _IdentityConverter<T>();
2222

2323
/// Fuse with an other codec.
2424
///

lib/src/percent.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ library convert.percent;
66

77
import 'dart:convert';
88

9-
import 'percent/encoder.dart';
109
import 'percent/decoder.dart';
10+
import 'percent/encoder.dart';
1111

12-
export 'percent/encoder.dart' hide percentEncoder;
1312
export 'percent/decoder.dart' hide percentDecoder;
13+
export 'percent/encoder.dart' hide percentEncoder;
1414

1515
/// The canonical instance of [PercentCodec].
16-
const percent = const PercentCodec._();
16+
const percent = PercentCodec._();
1717

1818
// TODO(nweiz): Add flags to support generating and interpreting "+" as a space
1919
// character. Also add an option for custom sets of unreserved characters.

0 commit comments

Comments
 (0)