Skip to content

Commit

Permalink
Fix most of the hints - thanks to dart fix (google#81)
Browse files Browse the repository at this point in the history
* Fix most of the hints - thanks to `dart fix`

* oops
  • Loading branch information
kevmoo authored Nov 2, 2020
1 parent 65beae4 commit 9d12116
Show file tree
Hide file tree
Showing 26 changed files with 63 additions and 55 deletions.
4 changes: 2 additions & 2 deletions acyclic_steps/lib/src/fluent_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ class StepBuilder {
/// the expression defining a step. See [Step.define] for how to define steps.
StepBuilder1<A> dep<A>(Step<A> stepA) {
ArgumentError.checkNotNull(stepA, 'stepA');
return StepBuilder1._(this._name, stepA);
return StepBuilder1._(_name, stepA);
}

/// Add dependency on an arbitrary number of steps [dependencies] and return
Expand All @@ -333,7 +333,7 @@ class StepBuilder {
StepBuilderN<S> deps<S>(Iterable<Step<S>> dependencies) {
ArgumentError.checkNotNull(dependencies, 'dependencies');
final dependencies_ = List<Step<S>>.from(dependencies);
return StepBuilderN._(this._name, dependencies_);
return StepBuilderN._(_name, dependencies_);
}

/// Build a step without dependencies.
Expand Down
2 changes: 1 addition & 1 deletion canonical_json/lib/canonical_json.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,4 @@ export 'src/exceptions.dart' show InvalidCanonicalJsonException;
/// }
/// }
/// ```
const Codec<Object, List<int>> canonicalJson = const CanonicalJsonCodec();
const Codec<Object, List<int>> canonicalJson = CanonicalJsonCodec();
9 changes: 6 additions & 3 deletions canonical_json/lib/src/decoder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,11 @@ class CanonicalJsonDecoder extends Converter<List<int>, Object> {
}

class _InvalidCanonicalJsonException extends InvalidCanonicalJsonException {
@override
final List<int> input;
@override
final int offset;
@override
final String message;

_InvalidCanonicalJsonException(this.input, this.offset, this.message);
Expand All @@ -52,7 +55,7 @@ class Decoder {
if (_data.length < _offset + constant.length) {
return false;
}
for (int i = 0; i < constant.length; i++) {
for (var i = 0; i < constant.length; i++) {
if (_data[_offset + i] != constant.codeUnitAt(i)) {
return false;
}
Expand Down Expand Up @@ -113,7 +116,7 @@ class Decoder {
/// Read an integer, assumes _value is in the range 0-9.
int _readInt() {
assert(char('1') <= _value && _value <= char('9'));
int result = 0;
var result = 0;
do {
result = result * 10 + _value.toUnsigned(8) - char('0');
_offset++;
Expand Down Expand Up @@ -198,7 +201,7 @@ class Decoder {
} while (_try(','));
_require('}', 'expected "," or "}" in map');
// Validate that keys are sorted
for (int i = 1; i < entries.length; i++) {
for (var i = 1; i < entries.length; i++) {
if (RawMapEntry.compare(entries[i - 1], entries[i]) > 0) {
throw _fail('keys in map must be sorted', entries[i].offset);
}
Expand Down
4 changes: 2 additions & 2 deletions canonical_json/lib/src/encoder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void _encode(Uint8Buffer output, Object input, Object original) {
// Handle lists by calling recursively.
if (input is List<Object>) {
output.add(char('['));
for (int i = 0; i < input.length; i++) {
for (var i = 0; i < input.length; i++) {
if (i > 0) {
output.add(char(','));
}
Expand All @@ -87,7 +87,7 @@ void _encode(Uint8Buffer output, Object input, Object original) {
final entries = RawMapEntry.fromMap(input).toList();
entries.sort(RawMapEntry.compare);
output.add(char('{'));
bool first = true;
var first = true;
for (final entry in entries) {
if (!first) {
output.add(char(','));
Expand Down
2 changes: 1 addition & 1 deletion canonical_json/lib/src/fast_unorm.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import 'package:unorm_dart/unorm_dart.dart' show nfc;
///
/// [1] http://www.macchiato.com/unicode/nfc-faq#TOC-Parsing-tokens-is-very-performance-sensitive-won-t-normalizing-be-too-costly-
String fastNfc(String s) {
for (int i = 0; i < s.length; i++) {
for (var i = 0; i < s.length; i++) {
if (s.codeUnitAt(i) >= 300) {
return nfc(s);
}
Expand Down
2 changes: 1 addition & 1 deletion canonical_json/lib/src/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class RawMapEntry {
static int compare(RawMapEntry a, RawMapEntry b) {
assert(a != null && b != null, 'a and b should never be null');
final N = math.min(a.key.length, b.key.length);
for (int i = 0; i < N; i++) {
for (var i = 0; i < N; i++) {
final r = a.key[i].compareTo(b.key[i]);
if (r != 0) {
return r;
Expand Down
4 changes: 2 additions & 2 deletions canonical_json/test/canonical_json_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void main() {
testValue('int (2)', -42);

final prng = Random(42);
for (int i = 0; i < 50; i++) {
for (var i = 0; i < 50; i++) {
final chars = '{}[]abcd \0""""\\\\\\\\\$\$\'\''.split('');
chars.shuffle(prng);
testValue('shuffled string ($i)', chars.join(''));
Expand Down Expand Up @@ -131,7 +131,7 @@ void main() {
}));

test('unicode normalization form C', () {
final nonFormC = "A\u0308\uFB03n";
final nonFormC = 'A\u0308\uFB03n';
final data = canonicalJson.encode(nonFormC);
final value = canonicalJson.decode(data);
expect(value, isNot(equals(nonFormC)));
Expand Down
2 changes: 1 addition & 1 deletion http_methods/example/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import 'package:http_methods/http_methods.dart';

void main() {
print('All HTTP verbs are:');
for (String method in httpMethods) {
for (var method in httpMethods) {
if (isIdempotentHttpMethod(method)) {
print('${method.padLeft(20)} is idempotent');
} else {
Expand Down
6 changes: 5 additions & 1 deletion neat_periodic_task/lib/neat_periodic_task.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ abstract class NeatStatusProvider {
class _InMemoryNeatStatusProvider implements NeatStatusProvider {
List<int> _value;

@override
Future<List<int>> get() async => _value;
@override
Future<bool> set(List<int> status) async {
_value = status;
return true;
Expand All @@ -85,8 +87,10 @@ class _NeatStatusProviderWithRetry extends NeatStatusProvider {
final NeatStatusProvider _provider;
final RetryOptions _r;
_NeatStatusProviderWithRetry(this._provider, this._r);
@override
Future<List<int>> get() =>
_r.retry(() => _provider.get(), retryIf: (e) => e is Exception);
@override
Future<bool> set(List<int> status) =>
_r.retry(() => _provider.set(status), retryIf: (e) => e is Exception);
}
Expand Down Expand Up @@ -247,7 +251,7 @@ class NeatPeriodicTaskScheduler {

// If delay isn't past yet, we sleep.
if (elapsed < delay) {
Duration d = delay ~/ 2;
var d = delay ~/ 2;
// Always sleep at least minCycle to ensure the iteration doesn't spin too
// fast as we approach the next iteration.
if (d < _minCycle) {
Expand Down
8 changes: 5 additions & 3 deletions neat_periodic_task/test/neat_periodic_task_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,18 @@ class _StatusStore {
}

class _StatusStoreNeatStatusProvider implements NeatStatusProvider {
_StatusStore _store;
final _StatusStore _store;
List<int> _lastRead;
_StatusStoreNeatStatusProvider(this._store);

@override
Future<List<int>> get() async {
await Future.delayed(Duration(milliseconds: 1));
_lastRead = _store._value;
return _lastRead;
}

@override
Future<bool> set(List<int> status) async {
await Future.delayed(Duration(milliseconds: 1));
if (_store._value == null ||
Expand All @@ -53,7 +55,7 @@ void main() {
Logger.root.onRecord.listen((r) => print(r));

test('schedule periodic task', () async {
int count = 0;
var count = 0;
final scheduler = NeatPeriodicTaskScheduler(
name: 'test-task',
interval: Duration(milliseconds: 500),
Expand All @@ -79,7 +81,7 @@ void main() {
test('schedule periodic task with racing', () async {
final statusStore = _StatusStore();

int count = 0;
var count = 0;
final schedulerA = NeatPeriodicTaskScheduler(
name: 'machine-A',
interval: Duration(milliseconds: 500),
Expand Down
4 changes: 2 additions & 2 deletions pem/example/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ import 'package:pem/pem.dart';

void main() {
// Parse private key from PEM string.
final privateKeydata = PemCodec(PemLabel.privateKey).decode("""
final privateKeydata = PemCodec(PemLabel.privateKey).decode('''
-----BEGIN PRIVATE KEY-----
MIGEAgEAMBAGByqGSM49AgEGBSuBBAAKBG0wawIBAQQgVcB/UNPxalR9zDYAjQIf
jojUDiQuGnSJrFEEzZPT/92hRANCAASc7UJtgnF/abqWM60T3XNJEzBv5ez9TdwK
H0M6xpM2q+53wmsN/eYLdgtjgBd3DBmHtPilCkiFICXyaA8z9LkJ
-----END PRIVATE KEY-----
""");
''');

// Print number of bytes in the key, we could obviously also pass it to
// another library to use the key.
Expand Down
10 changes: 5 additions & 5 deletions pem/lib/pem.dart
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ String encodePemBlock(PemLabel label, List<int> data) {
final L = _labels[label].first;
s.writeln('-----BEGIN $L-----');
final lines = base64.encode(data);
for (int i = 0; i < lines.length; i += 64) {
for (var i = 0; i < lines.length; i += 64) {
s.writeln(lines.substring(i, math.min(lines.length, i + 64)));
}
s.writeln('-----END $L-----');
Expand Down Expand Up @@ -304,9 +304,9 @@ class PemCodec extends Codec<List<int>, String> {
/// block.
@override
Converter<String, List<int>> get decoder => _PemDecoder(
this.label,
this._strict,
this._unsafeIgnoreLabel,
label,
_strict,
_unsafeIgnoreLabel,
);

/// Return a [Converter] for decoding a single PEM block.
Expand All @@ -316,7 +316,7 @@ class PemCodec extends Codec<List<int>, String> {
///
/// [1]: https://tools.ietf.org/html/rfc7468
@override
Converter<List<int>, String> get encoder => _PemEncoder(this.label);
Converter<List<int>, String> get encoder => _PemEncoder(label);
}

class _PemDecoder extends Converter<String, List<int>> {
Expand Down
8 changes: 4 additions & 4 deletions pem/test/testcases.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// limitations under the License.

/// Strict test cases.
const strictTestCases = """
const strictTestCases = '''
-----BEGIN CERTIFICATE-----
MIICLDCCAdKgAwIBAgIBADAKBggqhkjOPQQDAjB9MQswCQYDVQQGEwJCRTEPMA0G
A1UEChMGR251VExTMSUwIwYDVQQLExxHbnVUTFMgY2VydGlmaWNhdGUgYXV0aG9y
Expand Down Expand Up @@ -117,13 +117,13 @@ MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEn1LlwLN/KBYQRVH6HfIMTzfEqJOVztLe
kLchp2hi78cCaMY81FBlYs8J9l7krc+M4aBeCGYFjba+hiXttJWPL7ydlE+5UG4U
Nkn3Eos8EiZByi9DVsyfy9eejh+8AXgp
-----END PUBLIC KEY-----
""";
''';

/// Test cases for non-strict parsing mode.
///
/// These are useful as when passed in textual format, it's easy to introduce
/// extract whitespace, indentation, tabs, CR LF, etc.
const laxTestCases = """
const laxTestCases = '''
-----BEGIN CERTIFICATE-----
MIICLDCCAdKgAwIBAgIBADAKBggqhkjOPQQDAjB9MQswCQYDVQQGEwJCRTEPMA0G
A1UEChMG R251VExTMSUwIwYDVQQLExxHbnVUTFMgY2VydGlm aWNhdGUgYXV0aG9y
Expand Down Expand Up @@ -238,4 +238,4 @@ dEQc8B8jAcnuOrfU
\n\r\tkLchp2hi78cCaMY81FBlYs8J9l7krc+M4aBeCGYFjba+hiXttJWPL7ydlE+5UG4U
\n\r\tNkn3Eos8EiZByi9DVsyfy9eejh+8AXgp
\n\r\t-----END PUBLIC KEY-----
""";
''';
2 changes: 1 addition & 1 deletion retry/lib/retry.dart
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class RetryOptions {
FutureOr<bool> Function(Exception) retryIf,
FutureOr<void> Function(Exception) onRetry,
}) async {
int attempt = 0;
var attempt = 0;
// ignore: literal_only_boolean_expressions
while (true) {
attempt++; // first invocation is the first attempt
Expand Down
14 changes: 7 additions & 7 deletions retry/test/retry_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ void main() {
25600,
];
var r = RetryOptions();
for (int i = 0; i < ivt.length; i++) {
for (var i = 0; i < ivt.length; i++) {
final d = r.delay(i).inMilliseconds;
expect(d, inInclusiveRange(ivt[i] * 0.74, ivt[i] * 1.26));
}
Expand All @@ -44,7 +44,7 @@ void main() {
});

test('retry (success)', () async {
int count = 0;
var count = 0;
final r = RetryOptions();
final f = r.retry(() {
count++;
Expand All @@ -55,7 +55,7 @@ void main() {
});

test('retry (unhandled exception)', () async {
int count = 0;
var count = 0;
final r = RetryOptions(
maxAttempts: 5,
);
Expand All @@ -68,7 +68,7 @@ void main() {
});

test('retry (retryIf, exhaust retries)', () async {
int count = 0;
var count = 0;
final r = RetryOptions(
maxAttempts: 5,
maxDelay: Duration(),
Expand All @@ -82,7 +82,7 @@ void main() {
});

test('retry (success after 2)', () async {
int count = 0;
var count = 0;
final r = RetryOptions(
maxAttempts: 5,
maxDelay: Duration(),
Expand All @@ -99,7 +99,7 @@ void main() {
});

test('retry (no retryIf)', () async {
int count = 0;
var count = 0;
final r = RetryOptions(
maxAttempts: 5,
maxDelay: Duration(),
Expand All @@ -116,7 +116,7 @@ void main() {
});

test('retry (unhandled on 2nd try)', () async {
int count = 0;
var count = 0;
final r = RetryOptions(
maxAttempts: 5,
maxDelay: Duration(),
Expand Down
6 changes: 2 additions & 4 deletions safe_url_check/lib/safe_url_check.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,8 @@ Future<bool> safeUrlCheck(

try {
// Create client if one wasn't given.
HttpClient c = client;
if (c == null) {
c = HttpClient();
}
var c = client;
c ??= HttpClient();
try {
return await _safeUrlCheck(
url,
Expand Down
2 changes: 1 addition & 1 deletion sanitize_html/lib/src/html_formatter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class _HtmlFormatter {

void _writeNodes(List<Node> nodes) {
if (nodes == null || nodes.isEmpty) return;
for (Node node in nodes) {
for (var node in nodes) {
if (node is Element) {
_writeElement(node);
} else if (node is Text) {
Expand Down
2 changes: 1 addition & 1 deletion sanitize_html/lib/src/sane_html_validator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ class SaneHtmlValidator {
if (node.hasChildNodes()) {
// doing it in reverse order, because we could otherwise skip one, when a
// node is removed...
for (int i = node.nodes.length - 1; i >= 0; i--) {
for (var i = node.nodes.length - 1; i >= 0; i--) {
_sanitize(node.nodes[i]);
}
}
Expand Down
4 changes: 2 additions & 2 deletions shelf_router/lib/src/router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ String params(Request request, String name) {

final p = request.context['shelf_router/params'];
if (!(p is Map<String, String>)) {
throw new Exception('no such parameter $name');
throw Exception('no such parameter $name');
}
final value = (p as Map<String, String>)[name];
if (value == null) {
throw new Exception('no such parameter $name');
throw Exception('no such parameter $name');
}
return value;
}
Expand Down
Loading

0 comments on commit 9d12116

Please sign in to comment.