@@ -44,13 +44,13 @@ Future<void> main(List<String> arguments) async {
44
44
);
45
45
dart = path.join (dartSdk, 'bin' , Platform .isWindows ? 'dart.exe' : 'dart' );
46
46
pub = path.join (dartSdk, 'bin' , Platform .isWindows ? 'pub.bat' : 'pub' );
47
- print ( '$ clock STARTING ANALYSIS' );
47
+ printProgress ( ' STARTING ANALYSIS' );
48
48
await run (arguments);
49
49
if (hasError) {
50
- print ( '$ clock ${bold }Test failed.$reset ' );
50
+ printProgress ( ' ${bold }Test failed.$reset ' );
51
51
reportErrorsAndExit ();
52
52
}
53
- print ( '$ clock ${bold }Analysis successful.$reset ' );
53
+ printProgress ( ' ${bold }Analysis successful.$reset ' );
54
54
}
55
55
56
56
/// Scans [arguments] for an argument of the form `--dart-sdk` or
@@ -88,85 +88,85 @@ Future<void> run(List<String> arguments) async {
88
88
foundError (< String > ['The analyze.dart script must be run with --enable-asserts.' ]);
89
89
}
90
90
91
- print ( '$ clock No Double.clamp' );
91
+ printProgress ( ' No Double.clamp' );
92
92
await verifyNoDoubleClamp (flutterRoot);
93
93
94
- print ( '$ clock All tool test files end in _test.dart...' );
94
+ printProgress ( ' All tool test files end in _test.dart...' );
95
95
await verifyToolTestsEndInTestDart (flutterRoot);
96
96
97
- print ( '$ clock No sync*/async*' );
97
+ printProgress ( ' No sync*/async*' );
98
98
await verifyNoSyncAsyncStar (flutterPackages);
99
99
await verifyNoSyncAsyncStar (flutterExamples, minimumMatches: 200 );
100
100
101
- print ( '$ clock No runtimeType in toString...' );
101
+ printProgress ( ' No runtimeType in toString...' );
102
102
await verifyNoRuntimeTypeInToString (flutterRoot);
103
103
104
- print ( '$ clock Debug mode instead of checked mode...' );
104
+ printProgress ( ' Debug mode instead of checked mode...' );
105
105
await verifyNoCheckedMode (flutterRoot);
106
106
107
- print ( '$ clock Links for creating GitHub issues' );
107
+ printProgress ( ' Links for creating GitHub issues' );
108
108
await verifyIssueLinks (flutterRoot);
109
109
110
- print ( '$ clock Unexpected binaries...' );
110
+ printProgress ( ' Unexpected binaries...' );
111
111
await verifyNoBinaries (flutterRoot);
112
112
113
- print ( '$ clock Trailing spaces...' );
113
+ printProgress ( ' Trailing spaces...' );
114
114
await verifyNoTrailingSpaces (flutterRoot); // assumes no unexpected binaries, so should be after verifyNoBinaries
115
115
116
- print ( '$ clock Deprecations...' );
116
+ printProgress ( ' Deprecations...' );
117
117
await verifyDeprecations (flutterRoot);
118
118
119
- print ( '$ clock Goldens...' );
119
+ printProgress ( ' Goldens...' );
120
120
await verifyGoldenTags (flutterPackages);
121
121
122
- print ( '$ clock Skip test comments...' );
122
+ printProgress ( ' Skip test comments...' );
123
123
await verifySkipTestComments (flutterRoot);
124
124
125
- print ( '$ clock Licenses...' );
125
+ printProgress ( ' Licenses...' );
126
126
await verifyNoMissingLicense (flutterRoot);
127
127
128
- print ( '$ clock Test imports...' );
128
+ printProgress ( ' Test imports...' );
129
129
await verifyNoTestImports (flutterRoot);
130
130
131
- print ( '$ clock Bad imports (framework)...' );
131
+ printProgress ( ' Bad imports (framework)...' );
132
132
await verifyNoBadImportsInFlutter (flutterRoot);
133
133
134
- print ( '$ clock Bad imports (tools)...' );
134
+ printProgress ( ' Bad imports (tools)...' );
135
135
await verifyNoBadImportsInFlutterTools (flutterRoot);
136
136
137
- print ( '$ clock Internationalization...' );
137
+ printProgress ( ' Internationalization...' );
138
138
await verifyInternationalizations (flutterRoot, dart);
139
139
140
- print ( '$ clock Integration test timeouts...' );
140
+ printProgress ( ' Integration test timeouts...' );
141
141
await verifyIntegrationTestTimeouts (flutterRoot);
142
142
143
- print ( '$ clock null initialized debug fields...' );
143
+ printProgress ( ' null initialized debug fields...' );
144
144
await verifyNullInitializedDebugExpensiveFields (flutterRoot);
145
145
146
146
// Ensure that all package dependencies are in sync.
147
- print ( '$ clock Package dependencies...' );
147
+ printProgress ( ' Package dependencies...' );
148
148
await runCommand (flutter, < String > ['update-packages' , '--verify-only' ],
149
149
workingDirectory: flutterRoot,
150
150
);
151
151
152
152
/// Ensure that no new dependencies have been accidentally
153
153
/// added to core packages.
154
- print ( '$ clock Package Allowlist...' );
154
+ printProgress ( ' Package Allowlist...' );
155
155
await _checkConsumerDependencies ();
156
156
157
157
// Analyze all the Dart code in the repo.
158
- print ( '$ clock Dart analysis...' );
158
+ printProgress ( ' Dart analysis...' );
159
159
await _runFlutterAnalyze (flutterRoot, options: < String > [
160
160
'--flutter-repo' ,
161
161
...arguments,
162
162
]);
163
163
164
- print ( '$ clock Executable allowlist...' );
164
+ printProgress ( ' Executable allowlist...' );
165
165
await _checkForNewExecutables ();
166
166
167
167
// Try with the --watch analyzer, to make sure it returns success also.
168
168
// The --benchmark argument exits after one run.
169
- print ( '$ clock Dart analysis (with --watch)...' );
169
+ printProgress ( ' Dart analysis (with --watch)...' );
170
170
await _runFlutterAnalyze (flutterRoot, options: < String > [
171
171
'--flutter-repo' ,
172
172
'--watch' ,
@@ -175,14 +175,14 @@ Future<void> run(List<String> arguments) async {
175
175
]);
176
176
177
177
// Analyze the code in `{@tool snippet}` sections in the repo.
178
- print ( '$ clock Snippet code...' );
178
+ printProgress ( ' Snippet code...' );
179
179
await runCommand (dart,
180
180
< String > ['--enable-asserts' , path.join (flutterRoot, 'dev' , 'bots' , 'analyze_snippet_code.dart' ), '--verbose' ],
181
181
workingDirectory: flutterRoot,
182
182
);
183
183
184
184
// Try analysis against a big version of the gallery; generate into a temporary directory.
185
- print ( '$ clock Dart analysis (mega gallery)...' );
185
+ printProgress ( ' Dart analysis (mega gallery)...' );
186
186
final Directory outDir = Directory .systemTemp.createTempSync ('flutter_mega_gallery.' );
187
187
try {
188
188
await runCommand (dart,
@@ -548,27 +548,23 @@ String _generateLicense(String prefix) {
548
548
549
549
Future <void > verifyNoMissingLicense (String workingDirectory, { bool checkMinimums = true }) async {
550
550
final int ? overrideMinimumMatches = checkMinimums ? null : 0 ;
551
- int failed = 0 ;
552
- failed += await _verifyNoMissingLicenseForExtension (workingDirectory, 'dart' , overrideMinimumMatches ?? 2000 , _generateLicense ('// ' ));
553
- failed += await _verifyNoMissingLicenseForExtension (workingDirectory, 'java' , overrideMinimumMatches ?? 39 , _generateLicense ('// ' ));
554
- failed += await _verifyNoMissingLicenseForExtension (workingDirectory, 'h' , overrideMinimumMatches ?? 30 , _generateLicense ('// ' ));
555
- failed += await _verifyNoMissingLicenseForExtension (workingDirectory, 'm' , overrideMinimumMatches ?? 30 , _generateLicense ('// ' ));
556
- failed += await _verifyNoMissingLicenseForExtension (workingDirectory, 'cpp' , overrideMinimumMatches ?? 0 , _generateLicense ('// ' ));
557
- failed += await _verifyNoMissingLicenseForExtension (workingDirectory, 'swift' , overrideMinimumMatches ?? 10 , _generateLicense ('// ' ));
558
- failed += await _verifyNoMissingLicenseForExtension (workingDirectory, 'gradle' , overrideMinimumMatches ?? 80 , _generateLicense ('// ' ));
559
- failed += await _verifyNoMissingLicenseForExtension (workingDirectory, 'gn' , overrideMinimumMatches ?? 0 , _generateLicense ('# ' ));
560
- failed += await _verifyNoMissingLicenseForExtension (workingDirectory, 'sh' , overrideMinimumMatches ?? 1 , _generateLicense ('# ' ), header: r'#!/usr/bin/env bash\n' ,);
561
- failed += await _verifyNoMissingLicenseForExtension (workingDirectory, 'bat' , overrideMinimumMatches ?? 1 , _generateLicense ('REM ' ), header: r'@ECHO off\n' );
562
- failed += await _verifyNoMissingLicenseForExtension (workingDirectory, 'ps1' , overrideMinimumMatches ?? 1 , _generateLicense ('# ' ));
563
- failed += await _verifyNoMissingLicenseForExtension (workingDirectory, 'html' , overrideMinimumMatches ?? 1 , '<!-- ${_generateLicense ('' )} -->' , trailingBlank: false , header: r'<!DOCTYPE HTML>\n' );
564
- failed += await _verifyNoMissingLicenseForExtension (workingDirectory, 'xml' , overrideMinimumMatches ?? 1 , '<!-- ${_generateLicense ('' )} -->' , header: r'(<\?xml version="1.0" encoding="utf-8"\?>\n)?' );
565
- failed += await _verifyNoMissingLicenseForExtension (workingDirectory, 'frag' , overrideMinimumMatches ?? 1 , _generateLicense ('// ' ), header: r'#version 320 es(\n)+' );
566
- if (failed > 0 ) {
567
- foundError (< String > ['License check failed.' ]);
568
- }
551
+ await _verifyNoMissingLicenseForExtension (workingDirectory, 'dart' , overrideMinimumMatches ?? 2000 , _generateLicense ('// ' ));
552
+ await _verifyNoMissingLicenseForExtension (workingDirectory, 'java' , overrideMinimumMatches ?? 39 , _generateLicense ('// ' ));
553
+ await _verifyNoMissingLicenseForExtension (workingDirectory, 'h' , overrideMinimumMatches ?? 30 , _generateLicense ('// ' ));
554
+ await _verifyNoMissingLicenseForExtension (workingDirectory, 'm' , overrideMinimumMatches ?? 30 , _generateLicense ('// ' ));
555
+ await _verifyNoMissingLicenseForExtension (workingDirectory, 'cpp' , overrideMinimumMatches ?? 0 , _generateLicense ('// ' ));
556
+ await _verifyNoMissingLicenseForExtension (workingDirectory, 'swift' , overrideMinimumMatches ?? 10 , _generateLicense ('// ' ));
557
+ await _verifyNoMissingLicenseForExtension (workingDirectory, 'gradle' , overrideMinimumMatches ?? 80 , _generateLicense ('// ' ));
558
+ await _verifyNoMissingLicenseForExtension (workingDirectory, 'gn' , overrideMinimumMatches ?? 0 , _generateLicense ('# ' ));
559
+ await _verifyNoMissingLicenseForExtension (workingDirectory, 'sh' , overrideMinimumMatches ?? 1 , _generateLicense ('# ' ), header: r'#!/usr/bin/env bash\n' ,);
560
+ await _verifyNoMissingLicenseForExtension (workingDirectory, 'bat' , overrideMinimumMatches ?? 1 , _generateLicense ('REM ' ), header: r'@ECHO off\n' );
561
+ await _verifyNoMissingLicenseForExtension (workingDirectory, 'ps1' , overrideMinimumMatches ?? 1 , _generateLicense ('# ' ));
562
+ await _verifyNoMissingLicenseForExtension (workingDirectory, 'html' , overrideMinimumMatches ?? 1 , '<!-- ${_generateLicense ('' )} -->' , trailingBlank: false , header: r'<!DOCTYPE HTML>\n' );
563
+ await _verifyNoMissingLicenseForExtension (workingDirectory, 'xml' , overrideMinimumMatches ?? 1 , '<!-- ${_generateLicense ('' )} -->' , header: r'(<\?xml version="1.0" encoding="utf-8"\?>\n)?' );
564
+ await _verifyNoMissingLicenseForExtension (workingDirectory, 'frag' , overrideMinimumMatches ?? 1 , _generateLicense ('// ' ), header: r'#version 320 es(\n)+' );
569
565
}
570
566
571
- Future <int > _verifyNoMissingLicenseForExtension (
567
+ Future <void > _verifyNoMissingLicenseForExtension (
572
568
String workingDirectory,
573
569
String extension ,
574
570
int minimumMatches,
@@ -592,22 +588,17 @@ Future<int> _verifyNoMissingLicenseForExtension(
592
588
}
593
589
// Fail if any errors
594
590
if (errors.isNotEmpty) {
595
- final String redLine = '$red ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━$reset ' ;
596
591
final String fileDoes = errors.length == 1 ? 'file does' : '${errors .length } files do' ;
597
- print (< String > [
598
- redLine,
592
+ foundError (< String > [
599
593
'${bold }The following $fileDoes not have the right license header for $extension files:$reset ' ,
600
594
...errors.map <String >((String error) => ' $error ' ),
601
595
'The expected license header is:' ,
602
596
if (header.isNotEmpty) 'A header matching the regular expression "$header ",' ,
603
597
if (header.isNotEmpty) 'followed by the following license text:' ,
604
598
license,
605
599
if (trailingBlank) '...followed by a blank line.' ,
606
- redLine,
607
- ].join ('\n ' ));
608
- return 1 ;
600
+ ]);
609
601
}
610
- return 0 ;
611
602
}
612
603
613
604
class _Line {
@@ -1650,7 +1641,7 @@ Future<EvalResult> _evalCommand(String executable, List<String> arguments, {
1650
1641
final String relativeWorkingDir = path.relative (workingDirectory);
1651
1642
1652
1643
if (! runSilently) {
1653
- printProgress ('RUNNING' , relativeWorkingDir, commandDescription);
1644
+ print ('RUNNING: cd $ cyan $ relativeWorkingDir $ reset ; $ green $ commandDescription $ reset ' );
1654
1645
}
1655
1646
1656
1647
final Stopwatch time = Stopwatch ()..start ();
@@ -1669,12 +1660,12 @@ Future<EvalResult> _evalCommand(String executable, List<String> arguments, {
1669
1660
);
1670
1661
1671
1662
if (! runSilently) {
1672
- print ('$ clock ELAPSED TIME: $bold ${prettyPrintDuration (time .elapsed )}$reset for $commandDescription in $relativeWorkingDir ' );
1663
+ print ('ELAPSED TIME: $bold ${prettyPrintDuration (time .elapsed )}$reset for $commandDescription in $relativeWorkingDir ' );
1673
1664
}
1674
1665
1675
1666
if (exitCode != 0 && ! allowNonZeroExit) {
1676
- stderr.write (result.stderr);
1677
1667
foundError (< String > [
1668
+ result.stderr,
1678
1669
'${bold }ERROR:$red Last command exited with $exitCode .$reset ' ,
1679
1670
'${bold }Command:$red $commandDescription $reset ' ,
1680
1671
'${bold }Relative working directory:$red $relativeWorkingDir $reset ' ,
@@ -1838,9 +1829,8 @@ const Set<String> kExecutableAllowlist = <String>{
1838
1829
Future <void > _checkForNewExecutables () async {
1839
1830
// 0b001001001
1840
1831
const int executableBitMask = 0x49 ;
1841
-
1842
1832
final List <File > files = await _gitFiles (flutterRoot);
1843
- int unexpectedExecutableCount = 0 ;
1833
+ final List < String > errors = < String > [] ;
1844
1834
for (final File file in files) {
1845
1835
final String relativePath = path.relative (
1846
1836
file.path,
@@ -1849,14 +1839,14 @@ Future<void> _checkForNewExecutables() async {
1849
1839
final FileStat stat = file.statSync ();
1850
1840
final bool isExecutable = stat.mode & executableBitMask != 0x0 ;
1851
1841
if (isExecutable && ! kExecutableAllowlist.contains (relativePath)) {
1852
- unexpectedExecutableCount += 1 ;
1853
- print ('$relativePath is executable: ${(stat .mode & 0x1FF ).toRadixString (2 )}' );
1842
+ errors.add ('$relativePath is executable: ${(stat .mode & 0x1FF ).toRadixString (2 )}' );
1854
1843
}
1855
1844
}
1856
- if (unexpectedExecutableCount > 0 ) {
1845
+ if (errors.isNotEmpty ) {
1857
1846
throw Exception (
1858
- 'found $unexpectedExecutableCount unexpected executable file'
1859
- '${unexpectedExecutableCount == 1 ? '' : 's' }! If this was intended, you '
1847
+ '${errors .join ('\n ' )}\n '
1848
+ 'found ${errors .length } unexpected executable file'
1849
+ '${errors .length == 1 ? '' : 's' }! If this was intended, you '
1860
1850
'must add this file to kExecutableAllowlist in dev/bots/analyze.dart' ,
1861
1851
);
1862
1852
}
0 commit comments