[Analyze] Make deprecation note analyzer clearer on quote misuse (#77653)

* Impl

* Escape$

* eofnl

* Make message more clear
This commit is contained in:
Tong Mu
2021-03-09 13:21:45 -08:00
committed by GitHub
parent dc1bdcc757
commit 7abee113e8
3 changed files with 14 additions and 2 deletions

View File

@@ -171,8 +171,13 @@ Future<void> verifyDeprecations(String workingDirectory, { int minimumMatches =
String message;
do {
final Match match2 = _deprecationPattern2.firstMatch(lines[lineNumber]);
if (match2 == null)
throw 'Deprecation notice does not match required pattern.';
if (match2 == null) {
String possibleReason = '';
if (lines[lineNumber].trimLeft().startsWith('"')) {
possibleReason = ' You might have used double quotes (") for the string instead of single quotes (\').';
}
throw 'Deprecation notice does not match required pattern.$possibleReason';
}
if (!lines[lineNumber].startsWith("$indent '"))
throw 'Unexpected deprecation notice indent.';
if (message == null) {

View File

@@ -94,3 +94,9 @@ void test16() { }
'This feature was deprecated after v1.20.0-1.0.pre.'
)
void test17() { }
@Deprecated(
"Double quotes' test (should fail). "
'This feature was deprecated after v2.1.0-11.0.pre.'
)
void test18() { }

View File

@@ -52,6 +52,7 @@ void main() {
'test/analyze-test-input/root/packages/foo/deprecation.dart:70: Deprecation notice does not accurately indicate a dev branch version number; please see RELEASES_URL to find the latest dev build version number.\n'
'test/analyze-test-input/root/packages/foo/deprecation.dart:76: Deprecation notice does not accurately indicate a dev branch version number; please see RELEASES_URL to find the latest dev build version number.\n'
'test/analyze-test-input/root/packages/foo/deprecation.dart:82: Deprecation notice does not accurately indicate a dev branch version number; please see RELEASES_URL to find the latest dev build version number.\n'
'test/analyze-test-input/root/packages/foo/deprecation.dart:99: Deprecation notice does not match required pattern. You might have used double quotes (") for the string instead of single quotes (\').\n'
.replaceAll('/', Platform.isWindows ? r'\' : '/')
.replaceAll('STYLE_GUIDE_URL', 'https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo')
.replaceAll('RELEASES_URL', 'https://flutter.dev/docs/development/tools/sdk/releases')