enable unnecessary_string_escapes and use_raw_strings (#68302) (#69025)

This commit is contained in:
Alexandre Ardhuin 2020-10-26 20:42:05 +01:00 committed by GitHub
parent 6d271b9106
commit 17cdf5559d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
27 changed files with 1529 additions and 1503 deletions

View File

@ -209,7 +209,7 @@ linter:
- unnecessary_parenthesis - unnecessary_parenthesis
# - unnecessary_raw_strings # not yet tested # - unnecessary_raw_strings # not yet tested
- unnecessary_statements - unnecessary_statements
# - unnecessary_string_escapes # not yet tested - unnecessary_string_escapes
- unnecessary_string_interpolations - unnecessary_string_interpolations
- unnecessary_this - unnecessary_this
- unrelated_type_equality_checks - unrelated_type_equality_checks
@ -219,7 +219,7 @@ linter:
- use_is_even_rather_than_modulo - use_is_even_rather_than_modulo
# - use_key_in_widget_constructors # not yet tested # - use_key_in_widget_constructors # not yet tested
- use_late_for_private_fields_and_variables - use_late_for_private_fields_and_variables
# - use_raw_strings # not yet tested - use_raw_strings
- use_rethrow_when_possible - use_rethrow_when_possible
# - use_setters_to_change_properties # not yet tested # - use_setters_to_change_properties # not yet tested
# - use_string_buffers # has false positives: https://github.com/dart-lang/sdk/issues/34182 # - use_string_buffers # has false positives: https://github.com/dart-lang/sdk/issues/34182

View File

@ -390,6 +390,19 @@ class $classNamePrefix$camelCaseName extends $superClass {''';
/// foo$bar = 'foo\$bar' /// foo$bar = 'foo\$bar'
/// ``` /// ```
String generateString(String value) { String generateString(String value) {
if (<String>['\n', '\f', '\t', '\r', '\b'].every((String pattern) => !value.contains(pattern))) {
final bool hasDollar = value.contains(r'$');
final bool hasBackslash = value.contains(r'\');
final bool hasQuote = value.contains("'");
final bool hasDoubleQuote = value.contains('"');
if (!hasQuote) {
return hasBackslash || hasDollar ? "r'$value'" : "'$value'";
}
if (!hasDoubleQuote) {
return hasBackslash || hasDollar ? 'r"$value"' : '"$value"';
}
}
const String backslash = '__BACKSLASH__'; const String backslash = '__BACKSLASH__';
assert( assert(
!value.contains(backslash), !value.contains(backslash),
@ -401,17 +414,17 @@ String generateString(String value) {
value = value value = value
// Replace backslashes with a placeholder for now to properly parse // Replace backslashes with a placeholder for now to properly parse
// other special characters. // other special characters.
.replaceAll('\\', backslash) .replaceAll(r'\', backslash)
.replaceAll('\$', '\\\$') .replaceAll(r'$', r'\$')
.replaceAll("'", "\\'") .replaceAll("'", r"\'")
.replaceAll('"', '\\"') .replaceAll('"', r'\"')
.replaceAll('\n', '\\n') .replaceAll('\n', r'\n')
.replaceAll('\f', '\\f') .replaceAll('\f', r'\f')
.replaceAll('\t', '\\t') .replaceAll('\t', r'\t')
.replaceAll('\r', '\\r') .replaceAll('\r', r'\r')
.replaceAll('\b', '\\b') .replaceAll('\b', r'\b')
// Reintroduce escaped backslashes into generated Dart string. // Reintroduce escaped backslashes into generated Dart string.
.replaceAll(backslash, '\\\\'); .replaceAll(backslash, r'\\');
return "'$value'"; return "'$value'";
} }

View File

@ -565,7 +565,7 @@ class Actions extends StatefulWidget {
if (action == null) { if (action == null) {
throw FlutterError('Unable to find an action for a $type in an $Actions widget ' throw FlutterError('Unable to find an action for a $type in an $Actions widget '
'in the given context.\n' 'in the given context.\n'
"$Actions.find() was called on a context that doesn\'t contain an " "$Actions.find() was called on a context that doesn't contain an "
'$Actions widget with a mapping for the given intent type.\n' '$Actions widget with a mapping for the given intent type.\n'
'The context used was:\n' 'The context used was:\n'
' $context\n' ' $context\n'

View File

@ -151,7 +151,7 @@ Future<void> main() async {
FlutterError.dumpErrorToConsole(FlutterErrorDetails( FlutterError.dumpErrorToConsole(FlutterErrorDetails(
exception: getAssertionErrorWithoutMessage(), exception: getAssertionErrorWithoutMessage(),
)); ));
expect(console.join('\n'), matches("Another exception was thrown: '[^']+flutter/test/foundation/error_reporting_test\\.dart': Failed assertion: line [0-9]+ pos [0-9]+: 'false': is not true\\.")); expect(console.join('\n'), matches(r"Another exception was thrown: '[^']+flutter/test/foundation/error_reporting_test\.dart': Failed assertion: line [0-9]+ pos [0-9]+: 'false': is not true\."));
console.clear(); console.clear();
FlutterError.resetErrorCount(); FlutterError.resetErrorCount();
}); });

View File

@ -160,9 +160,9 @@ const String asyncStackString = '''
#37 _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:307:19) #37 _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:307:19)
#38 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:174:12)'''; #38 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:174:12)''';
const String mangledStackString = ''' const String mangledStackString = r'''
dart:async/future_impl.dart 23:44 _Completer.completeError dart:async/future_impl.dart 23:44 _Completer.completeError
test\\bindings_async_gap_test.dart 42:17 main.<fn>.<fn> test\bindings_async_gap_test.dart 42:17 main.<fn>.<fn>
package:flutter_test/src/binding.dart 744:19 TestWidgetsFlutterBinding._runTestBody package:flutter_test/src/binding.dart 744:19 TestWidgetsFlutterBinding._runTestBody
===== asynchronous gap =========================== ===== asynchronous gap ===========================
dart:async/zone.dart 1121:19 _CustomZone.registerUnaryCallback dart:async/zone.dart 1121:19 _CustomZone.registerUnaryCallback

View File

@ -199,7 +199,7 @@ void main() {
'args': <dynamic>[ 'args': <dynamic>[
1, 1,
jsonDecode( jsonDecode(
'{"action": "actionCommand", "data": {\"input_context\" : \"abcdefg\"}}') '{"action": "actionCommand", "data": {"input_context" : "abcdefg"}}')
], ],
'method': 'TextInputClient.performPrivateCommand', 'method': 'TextInputClient.performPrivateCommand',
}); });
@ -226,7 +226,7 @@ void main() {
'args': <dynamic>[ 'args': <dynamic>[
1, 1,
jsonDecode( jsonDecode(
'{"action": "actionCommand", "data": {\"input_context\" : 0.5}}') '{"action": "actionCommand", "data": {"input_context" : 0.5}}')
], ],
'method': 'TextInputClient.performPrivateCommand', 'method': 'TextInputClient.performPrivateCommand',
}); });
@ -254,7 +254,7 @@ void main() {
'args': <dynamic>[ 'args': <dynamic>[
1, 1,
jsonDecode( jsonDecode(
'{"action": "actionCommand", "data": {\"input_context\" : ["abc", "efg"]}}') '{"action": "actionCommand", "data": {"input_context" : ["abc", "efg"]}}')
], ],
'method': 'TextInputClient.performPrivateCommand', 'method': 'TextInputClient.performPrivateCommand',
}); });
@ -283,7 +283,7 @@ void main() {
'args': <dynamic>[ 'args': <dynamic>[
1, 1,
jsonDecode( jsonDecode(
'{"action": "actionCommand", "data": {\"input_context\" : "abc"}}') '{"action": "actionCommand", "data": {"input_context" : "abc"}}')
], ],
'method': 'TextInputClient.performPrivateCommand', 'method': 'TextInputClient.performPrivateCommand',
}); });
@ -312,7 +312,7 @@ void main() {
'args': <dynamic>[ 'args': <dynamic>[
1, 1,
jsonDecode( jsonDecode(
'{"action": "actionCommand", "data": {\"input_context\" : [0.5, 0.8]}}') '{"action": "actionCommand", "data": {"input_context" : [0.5, 0.8]}}')
], ],
'method': 'TextInputClient.performPrivateCommand', 'method': 'TextInputClient.performPrivateCommand',
}); });

View File

@ -23,7 +23,7 @@ import 'common.dart';
/// Magical timeout value that's different from the default. /// Magical timeout value that's different from the default.
const Duration _kTestTimeout = Duration(milliseconds: 1234); const Duration _kTestTimeout = Duration(milliseconds: 1234);
const String _kSerializedTestTimeout = '1234'; const String _kSerializedTestTimeout = '1234';
const String _kWebScriptPrefix = "window.\$flutterDriver('"; const String _kWebScriptPrefix = r"window.$flutterDriver('";
const String _kWebScriptSuffix = "')"; const String _kWebScriptSuffix = "')";
void main() { void main() {

View File

@ -347,7 +347,7 @@ class _WindowsUtils extends OperatingSystemUtils {
// `where` could be missing if system32 is not on the PATH. // `where` could be missing if system32 is not on the PATH.
throwToolExit( throwToolExit(
'Cannot find the executable for `where`. This can happen if the System32 ' 'Cannot find the executable for `where`. This can happen if the System32 '
'folder (e.g. C:\\Windows\\System32 ) is removed from the PATH environment ' r'folder (e.g. C:\Windows\System32 ) is removed from the PATH environment '
'variable. Ensure that this is present and then try again after restarting ' 'variable. Ensure that this is present and then try again after restarting '
'the terminal and/or IDE.' 'the terminal and/or IDE.'
); );

View File

@ -110,7 +110,7 @@ class AttachCommand extends FlutterCommand {
final String name = 'attach'; final String name = 'attach';
@override @override
final String description = ''' final String description = r'''
Attach to a running app. Attach to a running app.
For attaching to Android or iOS devices, simply using `flutter attach` is For attaching to Android or iOS devices, simply using `flutter attach` is
@ -118,13 +118,13 @@ usually sufficient. The tool will search for a running Flutter app or module,
if available. Otherwise, the tool will wait for the next Flutter app or module if available. Otherwise, the tool will wait for the next Flutter app or module
to launch before attaching. to launch before attaching.
For Fuchsia, the module name must be provided, e.g. `\$flutter attach For Fuchsia, the module name must be provided, e.g. `$flutter attach
--module=mod_name`. This can be called either before or after the application --module=mod_name`. This can be called either before or after the application
is started. is started.
If the app or module is already running and the specific observatory port is If the app or module is already running and the specific observatory port is
known, it can be explicitly provided to attach via the command-line, e.g. known, it can be explicitly provided to attach via the command-line, e.g.
`\$ flutter attach --debug-port 12345`'''; `$ flutter attach --debug-port 12345`''';
int get debugPort { int get debugPort {
if (argResults['debug-port'] == null) { if (argResults['debug-port'] == null) {

View File

@ -591,7 +591,7 @@ class FuchsiaDevice extends Device {
if (_cachedHostAddress != null) { if (_cachedHostAddress != null) {
return _cachedHostAddress; return _cachedHostAddress;
} }
final RunResult result = await shell('echo \$SSH_CONNECTION'); final RunResult result = await shell(r'echo $SSH_CONNECTION');
void fail() { void fail() {
throwToolExit('Failed to get local address, aborting.\n$result'); throwToolExit('Failed to get local address, aborting.\n$result');
} }

View File

@ -91,9 +91,9 @@ class RemoveFrameworkLinkAndEmbeddingMigration extends IOSMigrator {
} }
// Embed and thin frameworks in a script instead of using Xcode's link / embed build phases. // Embed and thin frameworks in a script instead of using Xcode's link / embed build phases.
const String thinBinaryScript = 'xcode_backend.sh\\" thin'; const String thinBinaryScript = r'xcode_backend.sh\" thin';
if (line.contains(thinBinaryScript) && !line.contains(' embed')) { if (line.contains(thinBinaryScript) && !line.contains(' embed')) {
return line.replaceFirst(thinBinaryScript, 'xcode_backend.sh\\" embed_and_thin'); return line.replaceFirst(thinBinaryScript, r'xcode_backend.sh\" embed_and_thin');
} }
if (line.contains('/* App.framework ') || line.contains('/* Flutter.framework ')) { if (line.contains('/* App.framework ') || line.contains('/* Flutter.framework ')) {

View File

@ -181,7 +181,7 @@ List<String> _xcodeBuildSettingsLines({
// iOS does not link on Flutter in any build phase. Add the linker flag. // iOS does not link on Flutter in any build phase. Add the linker flag.
if (!useMacOSConfig) { if (!useMacOSConfig) {
xcodeBuildSettings.add('OTHER_LDFLAGS=\$(inherited) -framework Flutter'); xcodeBuildSettings.add(r'OTHER_LDFLAGS=$(inherited) -framework Flutter');
} }
if (!project.isModule) { if (!project.isModule) {

View File

@ -23,8 +23,8 @@ import 'package:intl/intl.dart' as intl;
/// Callers can lookup localized strings with an instance of @(class) returned /// Callers can lookup localized strings with an instance of @(class) returned
/// by `@(class).of(context)`. /// by `@(class).of(context)`.
/// ///
/// Applications need to include `@(class).delegate()` in their app\'s /// Applications need to include `@(class).delegate()` in their app's
/// localizationDelegates list, and the locales they support in the app\'s /// localizationDelegates list, and the locales they support in the app's
/// supportedLocales list. For example: /// supportedLocales list. For example:
/// ///
/// ``` /// ```
@ -215,17 +215,17 @@ const String loadBodyDeferredLoadingTemplate = '''return @(lookupName)(locale);'
// DELEGATE LOOKUP TEMPLATES // DELEGATE LOOKUP TEMPLATES
const String lookupFunctionTemplate = ''' const String lookupFunctionTemplate = r'''
@(class) @(lookupName)(Locale locale) { @(class) @(lookupName)(Locale locale) {
@(lookupBody) @(lookupBody)
assert(false, '@(class).delegate failed to load unsupported locale "\$locale"'); assert(false, '@(class).delegate failed to load unsupported locale "$locale"');
return null; return null;
}'''; }''';
const String lookupFunctionDeferredLoadingTemplate = ''' const String lookupFunctionDeferredLoadingTemplate = r'''
Future<@(class)> @(lookupName)(Locale locale) { Future<@(class)> @(lookupName)(Locale locale) {
@(lookupBody) @(lookupBody)
assert(false, '@(class).delegate failed to load unsupported locale "\$locale"'); assert(false, '@(class).delegate failed to load unsupported locale "$locale"');
return null; return null;
}'''; }''';

View File

@ -261,6 +261,19 @@ String describeLocale(String tag) {
/// foo$bar = 'foo\$bar' /// foo$bar = 'foo\$bar'
/// ``` /// ```
String generateString(String value) { String generateString(String value) {
if (<String>['\n', '\f', '\t', '\r', '\b'].every((String pattern) => !value.contains(pattern))) {
final bool hasDollar = value.contains(r'$');
final bool hasBackslash = value.contains(r'\');
final bool hasQuote = value.contains("'");
final bool hasDoubleQuote = value.contains('"');
if (!hasQuote) {
return hasBackslash || hasDollar ? "r'$value'" : "'$value'";
}
if (!hasDoubleQuote) {
return hasBackslash || hasDollar ? 'r"$value"' : '"$value"';
}
}
const String backslash = '__BACKSLASH__'; const String backslash = '__BACKSLASH__';
assert( assert(
!value.contains(backslash), !value.contains(backslash),
@ -272,17 +285,17 @@ String generateString(String value) {
value = value value = value
// Replace backslashes with a placeholder for now to properly parse // Replace backslashes with a placeholder for now to properly parse
// other special characters. // other special characters.
.replaceAll('\\', backslash) .replaceAll(r'\', backslash)
.replaceAll('\$', '\\\$') .replaceAll(r'$', r'\$')
.replaceAll("'", "\\'") .replaceAll("'", r"\'")
.replaceAll('"', '\\"') .replaceAll('"', r'\"')
.replaceAll('\n', '\\n') .replaceAll('\n', r'\n')
.replaceAll('\f', '\\f') .replaceAll('\f', r'\f')
.replaceAll('\t', '\\t') .replaceAll('\t', r'\t')
.replaceAll('\r', '\\r') .replaceAll('\r', r'\r')
.replaceAll('\b', '\\b') .replaceAll('\b', r'\b')
// Reintroduce escaped backslashes into generated Dart string. // Reintroduce escaped backslashes into generated Dart string.
.replaceAll(backslash, '\\\\'); .replaceAll(backslash, r'\\');
return "'$value'"; return "'$value'";
} }

View File

@ -312,17 +312,17 @@ void main() {
expect(configLines, containsAll(<String>[ expect(configLines, containsAll(<String>[
'file(TO_CMAKE_PATH "$_kTestFlutterRoot" FLUTTER_ROOT)', 'file(TO_CMAKE_PATH "$_kTestFlutterRoot" FLUTTER_ROOT)',
'file(TO_CMAKE_PATH "${fileSystem.currentDirectory.path}" PROJECT_DIR)', 'file(TO_CMAKE_PATH "${fileSystem.currentDirectory.path}" PROJECT_DIR)',
' "DART_DEFINES=\\"foo.bar%3D2,fizz.far%3D3\\""', r' "DART_DEFINES=\"foo.bar%3D2,fizz.far%3D3\""',
' "DART_OBFUSCATION=\\"true\\""', r' "DART_OBFUSCATION=\"true\""',
' "EXTRA_FRONT_END_OPTIONS=\\"--enable-experiment%3Dnon-nullable\\""', r' "EXTRA_FRONT_END_OPTIONS=\"--enable-experiment%3Dnon-nullable\""',
' "EXTRA_GEN_SNAPSHOT_OPTIONS=\\"--enable-experiment%3Dnon-nullable\\""', r' "EXTRA_GEN_SNAPSHOT_OPTIONS=\"--enable-experiment%3Dnon-nullable\""',
' "SPLIT_DEBUG_INFO=\\"foo/\\""', r' "SPLIT_DEBUG_INFO=\"foo/\""',
' "TRACK_WIDGET_CREATION=\\"true\\""', r' "TRACK_WIDGET_CREATION=\"true\""',
' "TREE_SHAKE_ICONS=\\"true\\""', r' "TREE_SHAKE_ICONS=\"true\""',
' "FLUTTER_ROOT=\\"$_kTestFlutterRoot\\""', ' "FLUTTER_ROOT=\\"$_kTestFlutterRoot\\""',
' "PROJECT_DIR=\\"${fileSystem.currentDirectory.path}\\""', ' "PROJECT_DIR=\\"${fileSystem.currentDirectory.path}\\""',
' "FLUTTER_TARGET=\\"lib/other.dart\\""', r' "FLUTTER_TARGET=\"lib/other.dart\""',
' "BUNDLE_SKSL_PATH=\\"foo/bar.sksl.json\\""', r' "BUNDLE_SKSL_PATH=\"foo/bar.sksl.json\""',
])); ]));
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
FileSystem: () => fileSystem, FileSystem: () => fileSystem,

View File

@ -71,7 +71,7 @@ void main() {
if (platform.isWindows) { if (platform.isWindows) {
flutterRootUri flutterRootUri
..write('/') ..write('/')
..write(canonicalizedFlutterRootPath.replaceAll('\\', '/')); ..write(canonicalizedFlutterRootPath.replaceAll(r'\', '/'));
} else { } else {
flutterRootUri.write(canonicalizedFlutterRootPath); flutterRootUri.write(canonicalizedFlutterRootPath);
} }

View File

@ -163,7 +163,7 @@ void main() {
await expectLater( await expectLater(
() async => await realCommandRunner.fetchRemoteRevision(), () async => await realCommandRunner.fetchRemoteRevision(),
throwsToolExit( throwsToolExit(
message: 'Unable to upgrade Flutter: no origin repository configured\.', message: 'Unable to upgrade Flutter: no origin repository configured.',
), ),
); );
expect(processManager.hasRemainingExpectations, isFalse); expect(processManager.hasRemainingExpectations, isFalse);

View File

@ -37,7 +37,7 @@ final Platform linuxPlatform = FakePlatform(
final Platform windowsPlatform = FakePlatform( final Platform windowsPlatform = FakePlatform(
operatingSystem: 'windows', operatingSystem: 'windows',
environment: <String, String>{ environment: <String, String>{
'LOCALAPPDATA': 'C:\\Users\\Dash\\AppData\\Local', 'LOCALAPPDATA': r'C:\Users\Dash\AppData\Local',
} }
); );
@ -193,11 +193,11 @@ void main() {
}); });
testUsingContext('Can discover Android Studio 4.1 location on Windows', () { testUsingContext('Can discover Android Studio 4.1 location on Windows', () {
windowsFileSystem.file('C:\\Users\\Dash\\AppData\\Local\\Google\\AndroidStudio4.1\\.home') windowsFileSystem.file(r'C:\Users\Dash\AppData\Local\Google\AndroidStudio4.1\.home')
..createSync(recursive: true) ..createSync(recursive: true)
..writeAsStringSync('C:\\Program Files\\AndroidStudio'); ..writeAsStringSync(r'C:\Program Files\AndroidStudio');
windowsFileSystem windowsFileSystem
.directory('C:\\Program Files\\AndroidStudio') .directory(r'C:\Program Files\AndroidStudio')
.createSync(recursive: true); .createSync(recursive: true);
final AndroidStudio studio = AndroidStudio.allInstalled().single; final AndroidStudio studio = AndroidStudio.allInstalled().single;

View File

@ -29,9 +29,9 @@ final Platform linuxPlatform = FakePlatform(
final Platform windowsPlatform = FakePlatform( final Platform windowsPlatform = FakePlatform(
operatingSystem: 'windows', operatingSystem: 'windows',
environment: <String, String>{ environment: <String, String>{
'USERPROFILE': 'C:\\Users\\foo', 'USERPROFILE': r'C:\Users\foo',
'APPDATA': 'C:\\Users\\foo\\AppData\\Roaming', 'APPDATA': r'C:\Users\foo\AppData\Roaming',
'LOCALAPPDATA': 'C:\\Users\\foo\\AppData\\Local' 'LOCALAPPDATA': r'C:\Users\foo\AppData\Local'
}, },
); );
@ -163,9 +163,9 @@ void main() {
}); });
testWithoutContext('legacy intellij(<2020) plugins check on windows', () async { testWithoutContext('legacy intellij(<2020) plugins check on windows', () async {
const String cachePath = 'C:\\Users\\foo\\.IntelliJIdea2019.10\\system'; const String cachePath = r'C:\Users\foo\.IntelliJIdea2019.10\system';
const String installPath = 'C:\\Program Files\\JetBrains\\IntelliJ IDEA Ultimate Edition 2019.10.1'; const String installPath = r'C:\Program Files\JetBrains\IntelliJ IDEA Ultimate Edition 2019.10.1';
const String pluginPath = 'C:\\Users\\foo\\.IntelliJIdea2019.10\\config\\plugins'; const String pluginPath = r'C:\Users\foo\.IntelliJIdea2019.10\config\plugins';
final FileSystem fileSystem = MemoryFileSystem.test(style: FileSystemStyle.windows); final FileSystem fileSystem = MemoryFileSystem.test(style: FileSystemStyle.windows);
final Directory cacheDirectory = fileSystem.directory(cachePath) final Directory cacheDirectory = fileSystem.directory(cachePath)
@ -190,9 +190,9 @@ void main() {
}); });
testWithoutContext('intellij(2020.1 ~ 2020.2) plugins check on windows (installed via JetBrains ToolBox app)', () async { testWithoutContext('intellij(2020.1 ~ 2020.2) plugins check on windows (installed via JetBrains ToolBox app)', () async {
const String cachePath = 'C:\\Users\\foo\\AppData\\Local\\JetBrains\\IntelliJIdea2020.10'; const String cachePath = r'C:\Users\foo\AppData\Local\JetBrains\IntelliJIdea2020.10';
const String installPath = 'C:\\Users\\foo\\AppData\\Local\\JetBrains\\Toolbox\\apps\\IDEA-U\\ch-0\\201.0000.00'; const String installPath = r'C:\Users\foo\AppData\Local\JetBrains\Toolbox\apps\IDEA-U\ch-0\201.0000.00';
const String pluginPath = 'C:\\Users\\foo\\AppData\\Roaming\\JetBrains\\IntelliJIdea2020.10\\plugins'; const String pluginPath = r'C:\Users\foo\AppData\Roaming\JetBrains\IntelliJIdea2020.10\plugins';
final FileSystem fileSystem = MemoryFileSystem.test(style: FileSystemStyle.windows); final FileSystem fileSystem = MemoryFileSystem.test(style: FileSystemStyle.windows);
final Directory cacheDirectory = fileSystem.directory(cachePath) final Directory cacheDirectory = fileSystem.directory(cachePath)
@ -202,8 +202,8 @@ void main() {
.writeAsStringSync(installPath, flush: true); .writeAsStringSync(installPath, flush: true);
final Directory installedDirectory = fileSystem.directory(installPath); final Directory installedDirectory = fileSystem.directory(installPath);
installedDirectory.createSync(recursive: true); installedDirectory.createSync(recursive: true);
createIntellijFlutterPluginJar(pluginPath + '\\flutter-intellij\\lib\\flutter-intellij.jar', fileSystem, version: '50.0'); createIntellijFlutterPluginJar(pluginPath + r'\flutter-intellij\lib\flutter-intellij.jar', fileSystem, version: '50.0');
createIntellijDartPluginJar(pluginPath + '\\Dart\\lib\\Dart.jar', fileSystem); createIntellijDartPluginJar(pluginPath + r'\Dart\lib\Dart.jar', fileSystem);
final Iterable<DoctorValidator> installed = IntelliJValidatorOnWindows.installed( final Iterable<DoctorValidator> installed = IntelliJValidatorOnWindows.installed(
fileSystem: fileSystem, fileSystem: fileSystem,
@ -217,9 +217,9 @@ void main() {
}); });
testWithoutContext('intellij(>=2020.3) plugins check on windows (installed via JetBrains ToolBox app and plugins)', () async { testWithoutContext('intellij(>=2020.3) plugins check on windows (installed via JetBrains ToolBox app and plugins)', () async {
const String cachePath = 'C:\\Users\\foo\\AppData\\Local\\JetBrains\\IntelliJIdea2020.10'; const String cachePath = r'C:\Users\foo\AppData\Local\JetBrains\IntelliJIdea2020.10';
const String installPath = 'C:\\Users\\foo\\AppData\\Local\\JetBrains\\Toolbox\\apps\\IDEA-U\\ch-0\\201.0000.00'; const String installPath = r'C:\Users\foo\AppData\Local\JetBrains\Toolbox\apps\IDEA-U\ch-0\201.0000.00';
const String pluginPath = 'C:\\Users\\foo\\AppData\\Local\\JetBrains\\Toolbox\\apps\\IDEA-U\\ch-0\\201.0000.00.plugins'; const String pluginPath = r'C:\Users\foo\AppData\Local\JetBrains\Toolbox\apps\IDEA-U\ch-0\201.0000.00.plugins';
final FileSystem fileSystem = MemoryFileSystem.test(style: FileSystemStyle.windows); final FileSystem fileSystem = MemoryFileSystem.test(style: FileSystemStyle.windows);
final Directory cacheDirectory = fileSystem.directory(cachePath) final Directory cacheDirectory = fileSystem.directory(cachePath)
@ -229,8 +229,8 @@ void main() {
.writeAsStringSync(installPath, flush: true); .writeAsStringSync(installPath, flush: true);
final Directory installedDirectory = fileSystem.directory(installPath); final Directory installedDirectory = fileSystem.directory(installPath);
installedDirectory.createSync(recursive: true); installedDirectory.createSync(recursive: true);
createIntellijFlutterPluginJar(pluginPath + '\\flutter-intellij\\lib\\flutter-intellij.jar', fileSystem, version: '50.0'); createIntellijFlutterPluginJar(pluginPath + r'\flutter-intellij\lib\flutter-intellij.jar', fileSystem, version: '50.0');
createIntellijDartPluginJar(pluginPath + '\\Dart\\lib\\Dart.jar', fileSystem); createIntellijDartPluginJar(pluginPath + r'\Dart\lib\Dart.jar', fileSystem);
final Iterable<DoctorValidator> installed = IntelliJValidatorOnWindows.installed( final Iterable<DoctorValidator> installed = IntelliJValidatorOnWindows.installed(
fileSystem: fileSystem, fileSystem: fileSystem,
@ -244,9 +244,9 @@ void main() {
}); });
testWithoutContext('intellij(2020.1~) plugins check on windows (installed via installer)', () async { testWithoutContext('intellij(2020.1~) plugins check on windows (installed via installer)', () async {
const String cachePath = 'C:\\Users\\foo\\AppData\\Local\\JetBrains\\IdeaIC2020.10'; const String cachePath = r'C:\Users\foo\AppData\Local\JetBrains\IdeaIC2020.10';
const String installPath = 'C:\\Program Files\\JetBrains\\IntelliJ IDEA Community Edition 2020.10.1'; const String installPath = r'C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2020.10.1';
const String pluginPath = 'C:\\Users\\foo\\AppData\\Roaming\\JetBrains\\IdeaIC2020.10\\plugins'; const String pluginPath = r'C:\Users\foo\AppData\Roaming\JetBrains\IdeaIC2020.10\plugins';
final FileSystem fileSystem = MemoryFileSystem.test(style: FileSystemStyle.windows); final FileSystem fileSystem = MemoryFileSystem.test(style: FileSystemStyle.windows);
final Directory cacheDirectory = fileSystem.directory(cachePath) final Directory cacheDirectory = fileSystem.directory(cachePath)
@ -256,8 +256,8 @@ void main() {
.writeAsStringSync(installPath, flush: true); .writeAsStringSync(installPath, flush: true);
final Directory installedDirectory = fileSystem.directory(installPath); final Directory installedDirectory = fileSystem.directory(installPath);
installedDirectory.createSync(recursive: true); installedDirectory.createSync(recursive: true);
createIntellijFlutterPluginJar(pluginPath + '\\flutter-intellij\\lib\\flutter-intellij.jar', fileSystem, version: '50.0'); createIntellijFlutterPluginJar(pluginPath + r'\flutter-intellij\lib\flutter-intellij.jar', fileSystem, version: '50.0');
createIntellijDartPluginJar(pluginPath + '\\Dart\\lib\\Dart.jar', fileSystem); createIntellijDartPluginJar(pluginPath + r'\Dart\lib\Dart.jar', fileSystem);
final Iterable<DoctorValidator> installed = IntelliJValidatorOnWindows.installed( final Iterable<DoctorValidator> installed = IntelliJValidatorOnWindows.installed(
fileSystem: fileSystem, fileSystem: fileSystem,

View File

@ -99,8 +99,8 @@ void main () {
}); });
testWithoutContext('skips migrating script with embed', () { testWithoutContext('skips migrating script with embed', () {
const String contents = ''' const String contents = r'''
shellScript = "/bin/sh \"\$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\\" embed\\n/bin/sh \"\$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\\" thin"; shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed\n/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" thin";
'''; ''';
xcodeProjectInfoFile.writeAsStringSync(contents); xcodeProjectInfoFile.writeAsStringSync(contents);
@ -116,7 +116,7 @@ shellScript = "/bin/sh \"\$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend
}); });
testWithoutContext('Xcode project is migrated', () { testWithoutContext('Xcode project is migrated', () {
xcodeProjectInfoFile.writeAsStringSync(''' xcodeProjectInfoFile.writeAsStringSync(r'''
prefix 3B80C3941E831B6300D905FE prefix 3B80C3941E831B6300D905FE
3B80C3951E831B6300D905FE suffix 3B80C3951E831B6300D905FE suffix
741F496821356857001E2961 741F496821356857001E2961
@ -128,7 +128,7 @@ keep this 1
741F496221355F47001E2961 741F496221355F47001E2961
9740EEBA1CF902C7004384FC 9740EEBA1CF902C7004384FC
741F495E21355F27001E2961 741F495E21355F27001E2961
shellScript = "/bin/sh \"\$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\\" thin"; shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" thin";
keep this 2 keep this 2
'''); ''');
@ -141,9 +141,9 @@ keep this 2
expect(iosProjectMigration.migrate(), isTrue); expect(iosProjectMigration.migrate(), isTrue);
verifyNever(mockUsage.sendEvent(any, any, label: anyNamed('label'), value: anyNamed('value'))); verifyNever(mockUsage.sendEvent(any, any, label: anyNamed('label'), value: anyNamed('value')));
expect(xcodeProjectInfoFile.readAsStringSync(), ''' expect(xcodeProjectInfoFile.readAsStringSync(), r'''
keep this 1 keep this 1
shellScript = "/bin/sh "\$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\\" embed_and_thin"; shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin";
keep this 2 keep this 2
'''); ''');
expect(testLogger.statusText, contains('Upgrading project.pbxproj')); expect(testLogger.statusText, contains('Upgrading project.pbxproj'));

View File

@ -726,14 +726,14 @@ Dec 20 17:04:32 md32-11-vm1 Another App[88374]: Ignore this text'''
'--predicate', '--predicate',
logPredicate, logPredicate,
], ],
stdout: ''' stdout: r'''
},{ },{
"traceID" : 37579774151491588, "traceID" : 37579774151491588,
"eventMessage" : "Single line message", "eventMessage" : "Single line message",
"eventType" : "logEvent" "eventType" : "logEvent"
},{ },{
"traceID" : 37579774151491588, "traceID" : 37579774151491588,
"eventMessage" : "Multi line message\\n continues...\\n continues..." "eventMessage" : "Multi line message\n continues...\n continues..."
},{ },{
"traceID" : 37579774151491588, "traceID" : 37579774151491588,
"eventMessage" : "Single line message, not the part of the above", "eventMessage" : "Single line message, not the part of the above",

View File

@ -565,13 +565,13 @@ Information about project "Runner":
expect(config.existsSync(), isTrue); expect(config.existsSync(), isTrue);
final String contents = config.readAsStringSync(); final String contents = config.readAsStringSync();
expect(contents.contains('OTHER_LDFLAGS=\$(inherited) -framework Flutter'), isTrue); expect(contents.contains(r'OTHER_LDFLAGS=$(inherited) -framework Flutter'), isTrue);
final File buildPhaseScript = fs.file('path/to/project/ios/Flutter/flutter_export_environment.sh'); final File buildPhaseScript = fs.file('path/to/project/ios/Flutter/flutter_export_environment.sh');
expect(buildPhaseScript.existsSync(), isTrue); expect(buildPhaseScript.existsSync(), isTrue);
final String buildPhaseScriptContents = buildPhaseScript.readAsStringSync(); final String buildPhaseScriptContents = buildPhaseScript.readAsStringSync();
expect(buildPhaseScriptContents.contains('OTHER_LDFLAGS=\$(inherited) -framework Flutter'), isTrue); expect(buildPhaseScriptContents.contains(r'OTHER_LDFLAGS=$(inherited) -framework Flutter'), isTrue);
}); });
testUsingOsxContext('do not set OTHER_LDFLAGS for macOS', () async { testUsingOsxContext('do not set OTHER_LDFLAGS for macOS', () async {

View File

@ -759,7 +759,7 @@ void main() {
"underlyingErrors" : [ "underlyingErrors" : [
{ {
"code" : 5, "code" : 5,
"failureReason" : "allowsSecureServices: 1. isConnected: 0. Platform: <DVTPlatform:0x7f804ce32880:'com.apple.platform.iphoneos':<DVTFilePath:0x7f804ce32800:'\/Users\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform'>>. DTDKDeviceIdentifierIsIDID: 0", "failureReason" : "allowsSecureServices: 1. isConnected: 0. Platform: <DVTPlatform:0x7f804ce32880:'com.apple.platform.iphoneos':<DVTFilePath:0x7f804ce32800:'/Users/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform'>>. DTDKDeviceIdentifierIsIDID: 0",
"description" : "📱<DVTiOSDevice (0x7f801f190450), iPhone, iPhone, 13.3 (17C54), d83d5bc53967baa0ee18626ba87b6254b2ab5418> -- Failed _shouldMakeReadyForDevelopment check even though device is not locked by passcode.", "description" : "📱<DVTiOSDevice (0x7f801f190450), iPhone, iPhone, 13.3 (17C54), d83d5bc53967baa0ee18626ba87b6254b2ab5418> -- Failed _shouldMakeReadyForDevelopment check even though device is not locked by passcode.",
"recoverySuggestion" : "", "recoverySuggestion" : "",
"domain" : "com.apple.platform.iphoneos" "domain" : "com.apple.platform.iphoneos"

View File

@ -1014,9 +1014,9 @@ flutter:
expect(pluginMakefile.existsSync(), isTrue); expect(pluginMakefile.existsSync(), isTrue);
final String contents = pluginMakefile.readAsStringSync(); final String contents = pluginMakefile.readAsStringSync();
expect(contents, contains('some_plugin')); expect(contents, contains('some_plugin'));
expect(contents, contains('target_link_libraries(\${BINARY_NAME} PRIVATE \${plugin}_plugin)')); expect(contents, contains(r'target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin)'));
expect(contents, contains('list(APPEND PLUGIN_BUNDLED_LIBRARIES \$<TARGET_FILE:\${plugin}_plugin>)')); expect(contents, contains(r'list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>)'));
expect(contents, contains('list(APPEND PLUGIN_BUNDLED_LIBRARIES \${\${plugin}_bundled_libraries})')); expect(contents, contains(r'list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})'));
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
FileSystem: () => fs, FileSystem: () => fs,
ProcessManager: () => FakeProcessManager.any(), ProcessManager: () => FakeProcessManager.any(),

View File

@ -34,7 +34,7 @@ void main() {
_flutter.lastErrorInfo.contains( _flutter.lastErrorInfo.contains(
// Looks for stack trace entry of the form: // Looks for stack trace entry of the form:
// test/integration.shard/test_driver.dart 379:18 FlutterTestDriver._waitFor.<fn> // test/integration.shard/test_driver.dart 379:18 FlutterTestDriver._waitFor.<fn>
RegExp('^(.+)\/([^\/]+)\.dart \d*:\d*\s*.*\$') RegExp(r'^(.+)\/([^\/]+)\.dart \d*:\d*\s*.*\$')
), ),
isFalse isFalse
); );