Unverified Commit 7abee113 authored by Tong Mu's avatar Tong Mu Committed by GitHub

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

* Impl

* Escape$

* eofnl

* Make message more clear
parent dc1bdcc7
......@@ -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) {
......
......@@ -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() { }
......@@ -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')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment