Unverified Commit 5c28e3ee authored by Alexandre Ardhuin's avatar Alexandre Ardhuin Committed by GitHub

unnecessary escapes fixes (#50178)

* unnecessary escapes fixes

* replace some strings with raw strings

* update regexp

* address review comments
parent b8199abd
...@@ -128,7 +128,7 @@ void main() { ...@@ -128,7 +128,7 @@ void main() {
// If the next line fails, your device may not support regexp search. // If the next line fails, your device may not support regexp search.
final String observatoryLine = await device.adb(<String>['logcat', '-e', 'Observatory listening on http:', '-m', '1', '-T', currentTime]); final String observatoryLine = await device.adb(<String>['logcat', '-e', 'Observatory listening on http:', '-m', '1', '-T', currentTime]);
print('Found observatory line: $observatoryLine'); print('Found observatory line: $observatoryLine');
final String observatoryUri = RegExp('Observatory listening on ((http|\/\/)[a-zA-Z0-9:/=_\\-\.\\[\\]]+)').firstMatch(observatoryLine)[1]; final String observatoryUri = RegExp(r'Observatory listening on ((http|//)[a-zA-Z0-9:/=_\-\.\[\]]+)').firstMatch(observatoryLine)[1];
print('Extracted observatory port: $observatoryUri'); print('Extracted observatory port: $observatoryUri');
section('Launching attach with given port'); section('Launching attach with given port');
......
...@@ -47,7 +47,7 @@ void main() { ...@@ -47,7 +47,7 @@ void main() {
await device.shellExec('am', <String>['start', '-n', _kActivityId]); await device.shellExec('am', <String>['start', '-n', _kActivityId]);
final String observatoryLine = await device.adb(<String>['logcat', '-e', 'Observatory listening on http:', '-m', '1', '-T', currentTime]); final String observatoryLine = await device.adb(<String>['logcat', '-e', 'Observatory listening on http:', '-m', '1', '-T', currentTime]);
print('Found observatory line: $observatoryLine'); print('Found observatory line: $observatoryLine');
final String observatoryUri = RegExp('Observatory listening on ((http|\/\/)[a-zA-Z0-9:/=_\\-\.\\[\\]]+)').firstMatch(observatoryLine)[1]; final String observatoryUri = RegExp(r'Observatory listening on ((http|//)[a-zA-Z0-9:/=_\-\.\[\]]+)').firstMatch(observatoryLine)[1];
print('Extracted observatory port: $observatoryUri'); print('Extracted observatory port: $observatoryUri');
final Process attachProcess = final Process attachProcess =
await _run(device: device, command: <String>['attach', '--debug-uri', await _run(device: device, command: <String>['attach', '--debug-uri',
......
...@@ -589,7 +589,7 @@ String extractCloudAuthTokenArg(List<String> rawArgs) { ...@@ -589,7 +589,7 @@ String extractCloudAuthTokenArg(List<String> rawArgs) {
final RegExp _obsRegExp = final RegExp _obsRegExp =
RegExp('An Observatory debugger .* is available at: '); RegExp('An Observatory debugger .* is available at: ');
final RegExp _obsPortRegExp = RegExp('(\\S+:(\\d+)/\\S*)\$'); final RegExp _obsPortRegExp = RegExp('(\\S+:(\\d+)/\\S*)\$');
final RegExp _obsUriRegExp = RegExp('((http|\/\/)[a-zA-Z0-9:/=_\\-\.\\[\\]]+)'); final RegExp _obsUriRegExp = RegExp(r'((http|//)[a-zA-Z0-9:/=_\-\.\[\]]+)');
/// Tries to extract a port from the string. /// Tries to extract a port from the string.
/// ///
......
...@@ -55,7 +55,7 @@ TaskFunction createHotModeTest({String deviceIdOverride, Map<String, String> env ...@@ -55,7 +55,7 @@ TaskFunction createHotModeTest({String deviceIdOverride, Map<String, String> env
.transform<String>(utf8.decoder) .transform<String>(utf8.decoder)
.transform<String>(const LineSplitter()) .transform<String>(const LineSplitter())
.listen((String line) { .listen((String line) {
if (line.contains('\] Reloaded ')) { if (line.contains('] Reloaded ')) {
if (hotReloadCount == 0) { if (hotReloadCount == 0) {
// Update the file and reload again. // Update the file and reload again.
final File appDartSource = file(path.join( final File appDartSource = file(path.join(
...@@ -108,7 +108,7 @@ TaskFunction createHotModeTest({String deviceIdOverride, Map<String, String> env ...@@ -108,7 +108,7 @@ TaskFunction createHotModeTest({String deviceIdOverride, Map<String, String> env
.transform<String>(utf8.decoder) .transform<String>(utf8.decoder)
.transform<String>(const LineSplitter()) .transform<String>(const LineSplitter())
.listen((String line) { .listen((String line) {
if (line.contains('\] Reloaded ')) { if (line.contains('] Reloaded ')) {
process.stdin.writeln('q'); process.stdin.writeln('q');
} }
print('stdout: $line'); print('stdout: $line');
......
...@@ -32,7 +32,7 @@ TaskFunction createRunWithoutLeakTest(dynamic dir) { ...@@ -32,7 +32,7 @@ TaskFunction createRunWithoutLeakTest(dynamic dir) {
.transform<String>(utf8.decoder) .transform<String>(utf8.decoder)
.transform<String>(const LineSplitter()) .transform<String>(const LineSplitter())
.listen((String line) { .listen((String line) {
if (line.contains('\] For a more detailed help message, press "h". To detach, press "d"; to quit, press "q"')) { if (line.contains('] For a more detailed help message, press "h". To detach, press "d"; to quit, press "q"')) {
process.stdin.writeln('q'); process.stdin.writeln('q');
} }
print('stdout: $line'); print('stdout: $line');
......
...@@ -168,7 +168,7 @@ String getFullTag() { ...@@ -168,7 +168,7 @@ String getFullTag() {
} }
Match parseFullTag(String version) { Match parseFullTag(String version) {
final RegExp versionPattern = RegExp('^v([0-9]+)\.([0-9]+)\.([0-9]+)-([0-9]+)-g([a-f0-9]+)\$'); final RegExp versionPattern = RegExp(r'^v([0-9]+)\.([0-9]+)\.([0-9]+)-([0-9]+)-g([a-f0-9]+)$');
return versionPattern.matchAsPrefix(version); return versionPattern.matchAsPrefix(version);
} }
......
...@@ -75,7 +75,7 @@ bool isPluralVariation(String key, Map<String, dynamic> bundle) { ...@@ -75,7 +75,7 @@ bool isPluralVariation(String key, Map<String, dynamic> bundle) {
void updateMissingResources(String localizationPath, String groupPrefix) { void updateMissingResources(String localizationPath, String groupPrefix) {
final Directory localizationDir = Directory(localizationPath); final Directory localizationDir = Directory(localizationPath);
final RegExp filenamePattern = RegExp('${groupPrefix}_(\\w+)\.arb'); final RegExp filenamePattern = RegExp('${groupPrefix}_(\\w+)\\.arb');
final Set<String> requiredKeys = resourceKeys(loadBundle(File(path.join(localizationPath, '${groupPrefix}_en.arb')))); final Set<String> requiredKeys = resourceKeys(loadBundle(File(path.join(localizationPath, '${groupPrefix}_en.arb'))));
......
...@@ -66,8 +66,8 @@ import 'messages_all.dart'; ...@@ -66,8 +66,8 @@ import 'messages_all.dart';
/// Callers can lookup localized strings with an instance of @(className) returned /// Callers can lookup localized strings with an instance of @(className) returned
/// by `@(className).of(context)`. /// by `@(className).of(context)`.
/// ///
/// Applications need to include `@(className).delegate()` in their app\'s /// Applications need to include `@(className).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:
/// ///
/// ``` /// ```
......
...@@ -952,12 +952,12 @@ void main() { ...@@ -952,12 +952,12 @@ void main() {
return Intl.plural( return Intl.plural(
count, count,
locale: _localeName, locale: _localeName,
name: \'helloWorlds\', name: 'helloWorlds',
args: <Object>[count, currentDate], args: <Object>[count, currentDate],
one: \'Hello World, today is \${currentDateString}\', one: 'Hello World, today is \${currentDateString}',
two: \'Hello two worlds, today is \${currentDateString}\', two: 'Hello two worlds, today is \${currentDateString}',
many: \'Hello all \${count} worlds, today is \${currentDateString}\', many: 'Hello all \${count} worlds, today is \${currentDateString}',
other: \'Hello other \${count} worlds, today is \${currentDateString}\' other: 'Hello other \${count} worlds, today is \${currentDateString}'
); );
} }
return helloWorlds(count, currentDateString); return helloWorlds(count, currentDateString);
...@@ -1334,12 +1334,12 @@ void main() { ...@@ -1334,12 +1334,12 @@ void main() {
return Intl.plural( return Intl.plural(
count, count,
locale: _localeName, locale: _localeName,
name: \'helloWorlds\', name: 'helloWorlds',
args: <Object>[count, currentDate], args: <Object>[count, currentDate],
one: \'Hello World, today is \${currentDateString}\', one: 'Hello World, today is \${currentDateString}',
two: \'Hello two worlds, today is \${currentDateString}\', two: 'Hello two worlds, today is \${currentDateString}',
many: \'Hello all \${count} worlds, today is \${currentDateString}\', many: 'Hello all \${count} worlds, today is \${currentDateString}',
other: \'Hello other \${count} worlds, today is \${currentDateString}\' other: 'Hello other \${count} worlds, today is \${currentDateString}'
); );
} }
return helloWorlds(count, currentDateString); return helloWorlds(count, currentDateString);
...@@ -1393,12 +1393,12 @@ void main() { ...@@ -1393,12 +1393,12 @@ void main() {
return Intl.plural( return Intl.plural(
count, count,
locale: _localeName, locale: _localeName,
name: \'helloWorlds\', name: 'helloWorlds',
args: <Object>[count, population], args: <Object>[count, population],
one: \'Hello World of \${populationString} citizens\', one: 'Hello World of \${populationString} citizens',
two: \'Hello two worlds with \${populationString} total citizens\', two: 'Hello two worlds with \${populationString} total citizens',
many: \'Hello all \${count} worlds, with a total of \${populationString} citizens\', many: 'Hello all \${count} worlds, with a total of \${populationString} citizens',
other: \'Hello other \${count} worlds, with a total of \${populationString} citizens\' other: 'Hello other \${count} worlds, with a total of \${populationString} citizens'
); );
} }
return helloWorlds(count, populationString); return helloWorlds(count, populationString);
......
...@@ -292,7 +292,7 @@ class SvgPath { ...@@ -292,7 +292,7 @@ class SvgPath {
final List<SvgPathCommand> commands; final List<SvgPathCommand> commands;
final double opacity; final double opacity;
static const String _pathCommandAtom = ' *([a-zA-Z]) *([\-\.0-9 ,]*)'; static const String _pathCommandAtom = r' *([a-zA-Z]) *([\-\.0-9 ,]*)';
static final RegExp _pathCommandValidator = RegExp('^($_pathCommandAtom)*\$'); static final RegExp _pathCommandValidator = RegExp('^($_pathCommandAtom)*\$');
static final RegExp _pathCommandMatcher = RegExp(_pathCommandAtom); static final RegExp _pathCommandMatcher = RegExp(_pathCommandAtom);
......
...@@ -66,11 +66,11 @@ class ShortAppBar extends StatelessWidget { ...@@ -66,11 +66,11 @@ class ShortAppBar extends StatelessWidget {
} }
class FruitPage extends StatelessWidget { class FruitPage extends StatelessWidget {
static final String paragraph1 = '''Have you ever held a quince? It\'s strange; static final String paragraph1 = '''Have you ever held a quince? It's strange;
covered in a fuzz somewhere between peach skin and a spider web. And it\'s covered in a fuzz somewhere between peach skin and a spider web. And it's
hard as soft lumber. You\'d be forgiven for thinking it\'s veneered Larch-wood. hard as soft lumber. You'd be forgiven for thinking it's veneered Larch-wood.
But inhale the aroma and you\'ll instantly know you have something wonderful. But inhale the aroma and you'll instantly know you have something wonderful.
Its scent can fill a room for days. And all this before you\'ve even cooked it. Its scent can fill a room for days. And all this before you've even cooked it.
'''.replaceAll('\n', ''); '''.replaceAll('\n', '');
static final String paragraph2 = '''Pomegranates on the other hand have become static final String paragraph2 = '''Pomegranates on the other hand have become
......
...@@ -642,7 +642,7 @@ ${globals.terminal.bolden('Consuming the Module')} ...@@ -642,7 +642,7 @@ ${globals.terminal.bolden('Consuming the Module')}
for (final String buildMode in buildModes) { for (final String buildMode in buildModes) {
globals.printStatus(''' globals.printStatus('''
${buildMode}Implementation \'$androidPackage:flutter_$buildMode:$buildNumber\''''); ${buildMode}Implementation '$androidPackage:flutter_$buildMode:$buildNumber\'''');
} }
globals.printStatus(''' globals.printStatus('''
......
...@@ -128,7 +128,7 @@ distributionUrl=https\\://services.gradle.org/distributions/gradle-$gradleVersio ...@@ -128,7 +128,7 @@ distributionUrl=https\\://services.gradle.org/distributions/gradle-$gradleVersio
} }
const String _defaultGradleVersion = '5.6.2'; const String _defaultGradleVersion = '5.6.2';
final RegExp _androidPluginRegExp = RegExp('com\.android\.tools\.build\:gradle\:(\\d+\.\\d+\.\\d+\)'); final RegExp _androidPluginRegExp = RegExp(r'com\.android\.tools\.build:gradle:\(\d+\.\d+\.\d+\)');
/// Returns the Gradle version that the current Android plugin depends on when found, /// Returns the Gradle version that the current Android plugin depends on when found,
/// otherwise it returns a default version. /// otherwise it returns a default version.
......
...@@ -350,7 +350,7 @@ List<String> _wrapTextAsLines(String text, { int start = 0, int columnWidth, @re ...@@ -350,7 +350,7 @@ List<String> _wrapTextAsLines(String text, { int start = 0, int columnWidth, @re
// reconstitute the original string. This is useful for manipulating "visible" // reconstitute the original string. This is useful for manipulating "visible"
// characters in the presence of ANSI control codes. // characters in the presence of ANSI control codes.
List<_AnsiRun> splitWithCodes(String input) { List<_AnsiRun> splitWithCodes(String input) {
final RegExp characterOrCode = RegExp('(\u001b\[[0-9;]*m|.)', multiLine: true); final RegExp characterOrCode = RegExp('(\u001b\\[[0-9;]*m|.)', multiLine: true);
List<_AnsiRun> result = <_AnsiRun>[]; List<_AnsiRun> result = <_AnsiRun>[];
final StringBuffer current = StringBuffer(); final StringBuffer current = StringBuffer();
for (final Match match in characterOrCode.allMatches(input)) { for (final Match match in characterOrCode.allMatches(input)) {
......
...@@ -82,7 +82,7 @@ class _FuchsiaLogReader extends DeviceLogReader { ...@@ -82,7 +82,7 @@ class _FuchsiaLogReader extends DeviceLogReader {
// the correct fuchsia module. // the correct fuchsia module.
final RegExp matchRegExp = _app == null final RegExp matchRegExp = _app == null
? _flutterLogOutput ? _flutterLogOutput
: RegExp('INFO: ${_app.name}(\.cmx)?\\(flutter\\): '); : RegExp('INFO: ${_app.name}(\\.cmx)?\\(flutter\\): ');
return Stream<String>.eventTransformed( return Stream<String>.eventTransformed(
lines, lines,
(EventSink<String> output) => _FuchsiaLogSink(output, matchRegExp, startTime), (EventSink<String> output) => _FuchsiaLogSink(output, matchRegExp, startTime),
......
...@@ -603,7 +603,7 @@ class AndroidProject extends FlutterProjectPlatform { ...@@ -603,7 +603,7 @@ class AndroidProject extends FlutterProjectPlatform {
String get pluginConfigKey => AndroidPlugin.kConfigKey; String get pluginConfigKey => AndroidPlugin.kConfigKey;
static final RegExp _applicationIdPattern = RegExp('^\\s*applicationId\\s+[\'"](.*)[\'"]\\s*\$'); static final RegExp _applicationIdPattern = RegExp('^\\s*applicationId\\s+[\'"](.*)[\'"]\\s*\$');
static final RegExp _kotlinPluginPattern = RegExp('^\\s*apply plugin\:\\s+[\'"]kotlin-android[\'"]\\s*\$'); static final RegExp _kotlinPluginPattern = RegExp('^\\s*apply plugin\\:\\s+[\'"]kotlin-android[\'"]\\s*\$');
static final RegExp _groupPattern = RegExp('^\\s*group\\s+[\'"](.*)[\'"]\\s*\$'); static final RegExp _groupPattern = RegExp('^\\s*group\\s+[\'"](.*)[\'"]\\s*\$');
/// The Gradle root directory of the Android host app. This is the directory /// The Gradle root directory of the Android host app. This is the directory
......
...@@ -94,7 +94,7 @@ class ProtocolDiscovery { ...@@ -94,7 +94,7 @@ class ProtocolDiscovery {
} }
Match _getPatternMatch(String line) { Match _getPatternMatch(String line) {
final RegExp r = RegExp('${RegExp.escape(serviceName)} listening on ((http|\/\/)[a-zA-Z0-9:/=_\\-\.\\[\\]]+)'); final RegExp r = RegExp(RegExp.escape(serviceName) + r' listening on ((http|//)[a-zA-Z0-9:/=_\-\.\[\]]+)');
return r.firstMatch(line); return r.firstMatch(line);
} }
......
...@@ -193,7 +193,7 @@ class WebDevices extends PollingDeviceDiscovery { ...@@ -193,7 +193,7 @@ class WebDevices extends PollingDeviceDiscovery {
@visibleForTesting @visibleForTesting
String parseVersionForWindows(String input) { String parseVersionForWindows(String input) {
return input.split(RegExp('\w')).last; return input.split(RegExp(r'\w')).last;
} }
......
...@@ -408,7 +408,7 @@ class FuchsiaRemoteConnection { ...@@ -408,7 +408,7 @@ class FuchsiaRemoteConnection {
// loopback device, so connecting to the IPv4 loopback would fail when the // loopback device, so connecting to the IPv4 loopback would fail when the
// target address is IPv6 link-local. // target address is IPv6 link-local.
final String addr = _useIpV6Loopback final String addr = _useIpV6Loopback
? 'http://\[$_ipv6Loopback\]:$port' ? 'http://[$_ipv6Loopback]:$port'
: 'http://$_ipv4Loopback:$port'; : 'http://$_ipv4Loopback:$port';
final Uri uri = Uri.parse(addr); final Uri uri = Uri.parse(addr);
return uri; return uri;
......
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