re-write flutter analyze to use the analysis server (#16979)

re-write flutter analyze (the single-shot and --flutter-repo) to use the analysis server
This commit is contained in:
Devon Carew
2018-05-10 09:48:40 -07:00
committed by GitHub
parent ca94bfdfc6
commit 09dec7f508
17 changed files with 460 additions and 831 deletions

View File

@@ -189,6 +189,8 @@ Future<Null> main() async {
}
}
buffer.add('');
buffer.add('// ignore_for_file: unused_element');
buffer.add('');
final List<Line> lines = new List<Line>.filled(buffer.length, null, growable: true);
for (Section section in sections) {
buffer.addAll(section.strings);
@@ -207,7 +209,7 @@ dependencies:
print('Found $sampleCodeSections sample code sections.');
final Process process = await Process.start(
_flutter,
<String>['analyze', '--no-preamble', mainDart.path],
<String>['analyze', '--no-preamble', '--no-congratulate', mainDart.parent.path],
workingDirectory: temp.path,
);
stderr.addStream(process.stderr);
@@ -216,10 +218,6 @@ dependencies:
errors.removeAt(0);
if (errors.first.startsWith('Running "flutter packages get" in '))
errors.removeAt(0);
if (errors.first.startsWith('Analyzing '))
errors.removeAt(0);
if (errors.last.endsWith(' issues found.') || errors.last.endsWith(' issue found.'))
errors.removeLast();
int errorCount = 0;
for (String error in errors) {
final String kBullet = Platform.isWindows ? ' - ' : ' • ';

View File

@@ -21,21 +21,24 @@ Future<Null> main() async {
int publicMembers = 0;
int otherErrors = 0;
int otherLines = 0;
await for (String entry in analysis.stderr.transform(utf8.decoder).transform(const LineSplitter())) {
print('analyzer stderr: $entry');
if (entry.startsWith('[lint] Document all public members')) {
publicMembers += 1;
} else if (entry.startsWith('[')) {
otherErrors += 1;
} else if (entry.startsWith('(Ran in ')) {
await for (String entry in analysis.stdout.transform(utf8.decoder).transform(const LineSplitter())) {
entry = entry.trim();
print('analyzer stdout: $entry');
if (entry == 'Building flutter tool...') {
// ignore this line
} else {
} else if (entry.startsWith('info • Document all public members •')) {
publicMembers += 1;
} else if (entry.startsWith('info •') || entry.startsWith('warning •') || entry.startsWith('error •')) {
otherErrors += 1;
} else if (entry.contains(' (ran in ')) {
// ignore this line
} else if (entry.isNotEmpty) {
otherLines += 1;
}
}
await for (String entry in analysis.stdout.transform(utf8.decoder).transform(const LineSplitter())) {
print('analyzer stdout: $entry');
if (entry == 'Building flutter tool...') {
await for (String entry in analysis.stderr.transform(utf8.decoder).transform(const LineSplitter())) {
print('analyzer stderr: $entry');
if (entry.startsWith('[lint] ')) {
// ignore this line
} else {
otherLines += 1;