forked from firka/flutter
[License] Enable empty_catches lint
This commit is contained in:
@@ -16,6 +16,7 @@ linter:
|
||||
- close_sinks
|
||||
- control_flow_in_finally
|
||||
- empty_statements
|
||||
- empty_catches
|
||||
- hash_and_equals
|
||||
# - invariant_booleans # Produces false positives, see https://github.com/flutter/flutter/issues/5790
|
||||
- iterable_contains_unrelated_type
|
||||
|
||||
@@ -332,6 +332,8 @@ mixin Latin1TextFile implements TextFile {
|
||||
cache(UTF8Of(this), () => utf8.decode(readBytes()));
|
||||
isUTF8 = true;
|
||||
} on FormatException {
|
||||
// Exceptions are fine/expected for non-UTF8 text, which we test for
|
||||
// immediately below.
|
||||
}
|
||||
if (isUTF8)
|
||||
throw '$fullName contains valid UTF-8 and is probably not actually encoded as Win1252';
|
||||
|
||||
@@ -327,19 +327,19 @@ abstract class License implements Comparable<License> {
|
||||
try {
|
||||
latin1Encoded = latin1.encode(body);
|
||||
isUTF8 = false;
|
||||
} on ArgumentError { }
|
||||
} on ArgumentError { /* Fall through to next encoding check. */ }
|
||||
if (!isUTF8) {
|
||||
bool isAscii = false;
|
||||
try {
|
||||
ascii.decode(latin1Encoded);
|
||||
isAscii = true;
|
||||
} on FormatException { }
|
||||
} on FormatException { /* Fall through to next encoding check */ }
|
||||
if (isAscii)
|
||||
return;
|
||||
try {
|
||||
utf8.decode(latin1Encoded);
|
||||
isUTF8 = true;
|
||||
} on FormatException { }
|
||||
} on FormatException { /* We check isUTF8 below and throw if necessary */ }
|
||||
if (isUTF8)
|
||||
throw 'tried to create a License object with text that appears to have been misdecoded as Latin1 instead of as UTF-8:\n$body';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user