From 7abee113e8e46c071c85572fa256c9a9d1cce4f2 Mon Sep 17 00:00:00 2001 From: Tong Mu Date: Tue, 9 Mar 2021 13:21:45 -0800 Subject: [PATCH] [Analyze] Make deprecation note analyzer clearer on quote misuse (#77653) * Impl * Escape$ * eofnl * Make message more clear --- dev/bots/analyze.dart | 9 +++++++-- .../root/packages/foo/deprecation.dart | 6 ++++++ dev/bots/test/analyze_test.dart | 1 + 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/dev/bots/analyze.dart b/dev/bots/analyze.dart index b31f040c9c..aeef8fc15c 100644 --- a/dev/bots/analyze.dart +++ b/dev/bots/analyze.dart @@ -171,8 +171,13 @@ Future 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) { 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 9d74f5b720..fb4f43e01c 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 @@ 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() { } diff --git a/dev/bots/test/analyze_test.dart b/dev/bots/test/analyze_test.dart index d3799b39db..024656ecf1 100644 --- a/dev/bots/test/analyze_test.dart +++ b/dev/bots/test/analyze_test.dart @@ -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')