[Analyze] Make deprecation note analyzer clearer on quote misuse (#77653)
* Impl
* Escape$
* eofnl
* Make message more clear
diff --git a/dev/bots/analyze.dart b/dev/bots/analyze.dart
index b31f040..aeef8fc 100644
--- a/dev/bots/analyze.dart
+++ b/dev/bots/analyze.dart
@@ -171,8 +171,13 @@
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) {
diff --git a/dev/bots/test/analyze-test-input/root/packages/foo/deprecation.dart b/dev/bots/test/analyze-test-input/root/packages/foo/deprecation.dart
index 9d74f5b..fb4f43e 100644
--- a/dev/bots/test/analyze-test-input/root/packages/foo/deprecation.dart
+++ b/dev/bots/test/analyze-test-input/root/packages/foo/deprecation.dart
@@ -94,3 +94,9 @@
'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() { }
diff --git a/dev/bots/test/analyze_test.dart b/dev/bots/test/analyze_test.dart
index d3799b3..024656e 100644
--- a/dev/bots/test/analyze_test.dart
+++ b/dev/bots/test/analyze_test.dart
@@ -52,6 +52,7 @@
'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')