Skip to content

Commit 1d64b36

Browse files
authored
[CQ] dart re-format (#7920)
Modernize dart files w/ a fresh formatting (to tall-style). To avoid future churn, we might consider formatting validation in a test or a presubmit. We might consider similar for sorting (as we do in the analyzer code base). ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read the [Flutter Style Guide] _recently_, and have followed its advice. - [x] I signed the [CLA]. - [ ] I listed at least one issue that this PR fixes in the description above. - [ ] I updated/added relevant documentation (doc comments with `///`). - [ ] I added new tests to check the change I am making, or this PR is [test-exempt]. - [ ] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/master/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/master/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/master/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/master/docs/contributing/Style-guide-for-Flutter-repo.md [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/master/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/master/docs/contributing/Chat.md
1 parent 2e620d9 commit 1d64b36

File tree

9 files changed

+299
-218
lines changed

9 files changed

+299
-218
lines changed

tool/grind.dart

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ void main(List<String> args) => grind(args);
1212
@Task('Check plugin URLs for live-ness')
1313
void checkUrls() async {
1414
log('checking URLs in FlutterBundle.properties...');
15-
var lines = await File('flutter-idea/src/io/flutter/FlutterBundle.properties')
16-
.readAsLines();
15+
var lines =
16+
await File(
17+
'flutter-idea/src/io/flutter/FlutterBundle.properties',
18+
).readAsLines();
1719
for (var line in lines) {
1820
var split = line.split('=');
1921
if (split.length == 2) {
@@ -24,8 +26,8 @@ void checkUrls() async {
2426
log('checking: $url...');
2527
if (response.statusCode != 200) {
2628
fail(
27-
'$url GET failed: [${response.statusCode}] ${response
28-
.reasonPhrase}');
29+
'$url GET failed: [${response.statusCode}] ${response.reasonPhrase}',
30+
);
2931
}
3032
}
3133
}
@@ -55,18 +57,21 @@ void outlineIcons() async {
5557
}
5658
}
5759

58-
void _createPng(File sourceSvg,
59-
String targetName, {
60-
required int? size,
61-
bool forLight = false,
62-
}) {
60+
void _createPng(
61+
File sourceSvg,
62+
String targetName, {
63+
required int? size,
64+
bool forLight = false,
65+
}) {
6366
File targetFile = joinFile(sourceSvg.parent, [targetName]);
6467

6568
String color = forLight ? '#7a7a7a' : '#9e9e9e';
6669

6770
String originalContent = sourceSvg.readAsStringSync();
68-
String newContent =
69-
originalContent.replaceAll('<svg ', '<svg fill="$color" ');
71+
String newContent = originalContent.replaceAll(
72+
'<svg ',
73+
'<svg fill="$color" ',
74+
);
7075

7176
sourceSvg.writeAsStringSync(newContent);
7277

@@ -80,8 +85,8 @@ void _createPng(File sourceSvg,
8085

8186
if (result.exitCode != 0) {
8287
print(
83-
'Error resizing image with imagemagick: ${result.stdout}\n${result
84-
.stderr}');
88+
'Error resizing image with imagemagick: ${result.stdout}\n${result.stderr}',
89+
);
8590
exit(1);
8691
}
8792
} finally {

tool/plugin/lib/build_spec.dart

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,20 @@ class BuildSpec {
3737
String? _changeLog;
3838

3939
BuildSpec.fromJson(Map<String, Object?> json, this.release)
40-
: name = json['name'] as String,
41-
channel = json['channel'] as String,
42-
version = json['version'] as String,
43-
ijVersion = json['ijVersion'] as String?,
44-
ideaProduct = json['ideaProduct'] as String,
45-
ideaVersion = json['ideaVersion'] as String,
46-
baseVersion = (json['baseVersion'] ?? json['ideaVersion']) as String,
47-
androidPluginVersion = json['androidPluginVersion'] as String,
48-
dartPluginVersion = json['dartPluginVersion'] as String,
49-
sinceBuild = json['sinceBuild'] as String,
50-
untilBuild = json['untilBuild'] as String,
51-
filesToSkip = json['filesToSkip'] as List<String>? ?? [],
52-
isUnitTestTarget = json['isUnitTestTarget'] == 'true',
53-
isTestTarget = json['isTestTarget'] == 'true';
40+
: name = json['name'] as String,
41+
channel = json['channel'] as String,
42+
version = json['version'] as String,
43+
ijVersion = json['ijVersion'] as String?,
44+
ideaProduct = json['ideaProduct'] as String,
45+
ideaVersion = json['ideaVersion'] as String,
46+
baseVersion = (json['baseVersion'] ?? json['ideaVersion']) as String,
47+
androidPluginVersion = json['androidPluginVersion'] as String,
48+
dartPluginVersion = json['dartPluginVersion'] as String,
49+
sinceBuild = json['sinceBuild'] as String,
50+
untilBuild = json['untilBuild'] as String,
51+
filesToSkip = json['filesToSkip'] as List<String>? ?? [],
52+
isUnitTestTarget = json['isUnitTestTarget'] == 'true',
53+
isTestTarget = json['isTestTarget'] == 'true';
5454

5555
bool get copyIjVersion => isAndroidStudio && ijVersion != null;
5656

tool/plugin/lib/edit.dart

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Future<int> applyEdits(BuildSpec spec, Future<int> Function() compileFn) async {
4646
// Handle skipped files.
4747
for (String file in spec.filesToSkip) {
4848
final entity =
49-
FileSystemEntity.isFileSync(file) ? File(file) : Directory(file);
49+
FileSystemEntity.isFileSync(file) ? File(file) : Directory(file);
5050
if (entity.existsSync()) {
5151
await entity.rename('$file~');
5252
log('renamed $file');
@@ -82,7 +82,7 @@ Future<int> applyEdits(BuildSpec spec, Future<int> Function() compileFn) async {
8282
for (final file in spec.filesToSkip) {
8383
final name = '$file~';
8484
final entity =
85-
FileSystemEntity.isFileSync(name) ? File(name) : Directory(name);
85+
FileSystemEntity.isFileSync(name) ? File(name) : Directory(name);
8686
if (entity.existsSync()) {
8787
await entity.rename(file);
8888
}
@@ -97,12 +97,11 @@ class EditCommand {
9797
required List<String> initials,
9898
required List<String> replacements,
9999
this.versions = const [],
100-
})
101-
: assert(initials.length == replacements.length),
102-
assert(initials.isNotEmpty),
103-
assert(versions.isNotEmpty),
104-
initials = initials.map(_platformAdaptiveString).toList(),
105-
replacements = replacements.map(_platformAdaptiveString).toList();
100+
}) : assert(initials.length == replacements.length),
101+
assert(initials.isNotEmpty),
102+
assert(versions.isNotEmpty),
103+
initials = initials.map(_platformAdaptiveString).toList(),
104+
replacements = replacements.map(_platformAdaptiveString).toList();
106105

107106
/// The target file path.
108107
final String path;

tool/plugin/lib/lint.dart

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@ class LintCommand extends Command<int> {
4141
final result = Process.runSync(
4242
'git',
4343
// Note: extra quotes added so grep doesn't match this file.
44-
['grep', 'import com.jetbrains.' 'lang.dart.'],
44+
[
45+
'grep',
46+
'import com.jetbrains.'
47+
'lang.dart.',
48+
],
4549
);
4650
final String imports = (result.stdout as String).trim();
4751

@@ -112,10 +116,7 @@ class LintCommand extends Command<int> {
112116
for (var import in proscribedImports) {
113117
print('Checking for import of "$import"...');
114118

115-
final result = Process.runSync(
116-
'git',
117-
['grep', 'import $import'],
118-
);
119+
final result = Process.runSync('git', ['grep', 'import $import']);
119120

120121
final String results = (result.stdout as String).trim();
121122
if (results.isNotEmpty) {
@@ -127,17 +128,12 @@ class LintCommand extends Command<int> {
127128
}
128129
}
129130

130-
final partialImports = [
131-
'com.sun.',
132-
];
131+
final partialImports = ['com.sun.'];
133132

134133
for (var import in partialImports) {
135134
print('Checking for import of "$import"...');
136135

137-
final result = Process.runSync(
138-
'git',
139-
['grep', 'import $import'],
140-
);
136+
final result = Process.runSync('git', ['grep', 'import $import']);
141137

142138
final String results = (result.stdout as String).trim();
143139
if (results.isNotEmpty) {

0 commit comments

Comments
 (0)