Unverified Commit 95d7d671 authored by Jenn Magder's avatar Jenn Magder Committed by GitHub

Remove analyze --dartdocs flag (#80484)

parent c09ace27
......@@ -1197,7 +1197,7 @@ Future<void> _runFlutterAnalyze(String workingDirectory, {
}) async {
return runCommand(
flutter,
<String>['analyze', '--dartdocs', ...options],
<String>['analyze', ...options],
workingDirectory: workingDirectory,
);
}
......
......@@ -2,70 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:convert';
import 'dart:io';
import 'package:flutter_devicelab/framework/framework.dart';
import 'package:flutter_devicelab/framework/task_result.dart';
import 'package:flutter_devicelab/framework/utils.dart';
import 'package:path/path.dart' as path;
Future<void> main() async {
final String dot = Platform.isWindows ? '-' : '•';
await flutter('update-packages');
await task(() async {
final Stopwatch clock = Stopwatch()..start();
final Process analysis = await startProcess(
path.join(flutterDirectory.path, 'bin', 'flutter'),
<String>['analyze', '--no-preamble', '--flutter-repo', '--dartdocs'],
workingDirectory: flutterDirectory.path,
);
int publicMembers = 0;
int otherErrors = 0;
int otherLines = 0;
bool sawFinalLine = false;
await for (String entry in analysis.stdout.transform<String>(utf8.decoder).transform<String>(const LineSplitter())) {
entry = entry.trim();
print('analyzer stdout: $entry');
if (entry == 'Building flutter tool...') {
// ignore this line
} else if (entry.startsWith('info $dot Document all public members $dot')) {
publicMembers += 1;
} else if (entry.startsWith('info $dot') || entry.startsWith('warning $dot') || entry.startsWith('error $dot')) {
otherErrors += 1;
} else if (entry.contains(' (ran in ') && !sawFinalLine) {
// ignore this line once
sawFinalLine = true;
} else if (entry.isNotEmpty) {
otherLines += 1;
print('^ not sure what to do with that line ^');
}
}
await for (final String entry in analysis.stderr.transform<String>(utf8.decoder).transform<String>(const LineSplitter())) {
print('analyzer stderr: $entry');
if (entry.contains(' (ran in ') && !sawFinalLine) {
// ignore this line once
sawFinalLine = true;
} else {
otherLines += 1;
print('^ not sure what to do with that line ^');
}
}
final int result = await analysis.exitCode;
clock.stop();
if (!sawFinalLine)
throw Exception('flutter analyze did not output final message');
if (publicMembers == 0 && otherErrors == 0 && result != 0)
throw Exception('flutter analyze exited with unexpected error code $result');
if (publicMembers != 0 && otherErrors != 0 && result == 0)
throw Exception('flutter analyze exited with successful status code despite reporting errors');
if (otherLines != 0)
throw Exception('flutter analyze had unexpected output (we saw $otherLines unexpected line${ otherLines == 1 ? "" : "s" })');
final Map<String, dynamic> data = <String, dynamic>{
'members_missing_dartdocs': publicMembers,
'analysis_errors': otherErrors,
'elapsed_time_ms': clock.elapsedMilliseconds,
};
return TaskResult.success(data, benchmarkScoreKeys: data.keys.toList());
// TODO(jmagman): Remove once dartdocs builder can be deleted
// when https://github.com/flutter/flutter/issues/79798 rolls to stable.
return TaskResult.success(null);
});
}
......@@ -114,12 +114,6 @@
"task_name": "linux_customer_testing",
"flaky": false
},
{
"name": "Linux dartdocs",
"repo": "flutter",
"task_name": "linux_dartdocs",
"flaky": false
},
{
"name": "Linux docs_test",
"repo": "flutter",
......
......@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// ignore_for_file: public_member_api_docs
// This is the test for the private implementation of animated icons.
// To make the private API accessible from the test we do not import the
// material material_animated_icons library, but instead, this test file is an
......
......@@ -41,8 +41,8 @@ class AnalyzeCommand extends FlutterCommand {
help: 'Analyze the current project, if applicable.', defaultsTo: true);
argParser.addFlag('dartdocs',
negatable: false,
help: 'List every public member that is lacking documentation. '
'(The "public_member_api_docs" lint must be enabled in "analysis_options.yaml".)',
help: '(deprecated) List every public member that is lacking documentation. '
'This command will be removed in a future version of Flutter.',
hide: !verboseHelp);
argParser.addFlag('watch',
help: 'Run analysis continuously, watching the filesystem for changes.',
......
......@@ -17,7 +17,6 @@ import '../base/platform.dart';
import '../base/terminal.dart';
import '../base/utils.dart';
import '../cache.dart';
import '../dart/analysis.dart';
import '../globals_null_migrated.dart' as globals;
/// Common behavior for `flutter analyze` and `flutter analyze --watch`
......@@ -71,12 +70,11 @@ abstract class AnalyzeBase {
}
}
void writeBenchmark(Stopwatch stopwatch, int errorCount, int membersMissingDocumentation) {
void writeBenchmark(Stopwatch stopwatch, int errorCount) {
const String benchmarkOut = 'analysis_benchmark.json';
final Map<String, dynamic> data = <String, dynamic>{
'time': stopwatch.elapsedMilliseconds / 1000.0,
'issues': errorCount,
'missingDartDocs': membersMissingDocumentation,
};
fileSystem.file(benchmarkOut).writeAsStringSync(toPrettyJson(data));
logger.printStatus('Analysis benchmark written to $benchmarkOut ($data).');
......@@ -85,41 +83,14 @@ abstract class AnalyzeBase {
bool get isFlutterRepo => argResults['flutter-repo'] as bool;
String get sdkPath => argResults['dart-sdk'] as String ?? artifacts.getArtifactPath(Artifact.engineDartSdkPath);
bool get isBenchmarking => argResults['benchmark'] as bool;
bool get isDartDocs => argResults['dartdocs'] as bool;
String get protocolTrafficLog => argResults['protocol-traffic-log'] as String;
static int countMissingDartDocs(List<AnalysisError> errors) {
return errors.where((AnalysisError error) {
return error.code == 'public_member_api_docs';
}).length;
}
static String generateDartDocMessage(int undocumentedMembers) {
String dartDocMessage;
assert(undocumentedMembers >= 0);
switch (undocumentedMembers) {
case 0:
dartDocMessage = 'all public member have documentation';
break;
case 1:
dartDocMessage = 'one public member lacks documentation';
break;
default:
dartDocMessage = '$undocumentedMembers public members lack documentation';
}
return dartDocMessage;
}
/// Generate an analysis summary for both [AnalyzeOnce], [AnalyzeContinuously].
static String generateErrorsMessage({
@required int issueCount,
int issueDiff,
int files,
@required String seconds,
int undocumentedMembers = 0,
String dartDocMessage = '',
}) {
final StringBuffer errorsMessage = StringBuffer(issueCount > 0
? '$issueCount ${pluralize('issue', issueCount)} found.'
......@@ -138,12 +109,7 @@ abstract class AnalyzeBase {
if (files != null) {
errorsMessage.write(' • analyzed $files ${pluralize('file', files)}');
}
if (undocumentedMembers > 0) {
errorsMessage.write(' (ran in ${seconds}s; $dartDocMessage)');
} else {
errorsMessage.write(' (ran in ${seconds}s)');
}
errorsMessage.write(' (ran in ${seconds}s)');
return errorsMessage.toString();
}
}
......
......@@ -122,15 +122,6 @@ class AnalyzeContinuously extends AnalyzeBase {
}
}
int issueCount = errors.length;
// count missing dartdocs
final int undocumentedMembers = AnalyzeBase.countMissingDartDocs(errors);
if (!isDartDocs) {
errors.removeWhere((AnalysisError error) => error.code == 'public_member_api_docs');
issueCount -= undocumentedMembers;
}
errors.sort();
for (final AnalysisError error in errors) {
......@@ -142,23 +133,21 @@ class AnalyzeContinuously extends AnalyzeBase {
dumpErrors(errors.map<String>((AnalysisError error) => error.toLegacyString()));
final int issueCount = errors.length;
final int issueDiff = issueCount - lastErrorCount;
lastErrorCount = issueCount;
final String seconds = (analysisTimer.elapsedMilliseconds / 1000.0).toStringAsFixed(2);
final String dartDocMessage = AnalyzeBase.generateDartDocMessage(undocumentedMembers);
final String errorsMessage = AnalyzeBase.generateErrorsMessage(
issueCount: issueCount,
issueDiff: issueDiff,
files: analyzedPaths.length,
seconds: seconds,
undocumentedMembers: undocumentedMembers,
dartDocMessage: dartDocMessage,
);
logger.printStatus(errorsMessage);
if (firstAnalysis && isBenchmarking) {
writeBenchmark(analysisTimer, issueCount, undocumentedMembers);
writeBenchmark(analysisTimer, issueCount);
server.dispose().whenComplete(() { exit(issueCount > 0 ? 1 : 0); });
}
......
......@@ -147,14 +147,9 @@ class AnalyzeOnce extends AnalyzeBase {
timer?.stop();
}
final int undocumentedMembers = AnalyzeBase.countMissingDartDocs(errors);
if (!isDartDocs) {
errors.removeWhere((AnalysisError error) => error.code == 'public_member_api_docs');
}
// emit benchmarks
if (isBenchmarking) {
writeBenchmark(timer, errors.length, undocumentedMembers);
writeBenchmark(timer, errors.length);
}
// --write
......@@ -171,12 +166,9 @@ class AnalyzeOnce extends AnalyzeBase {
final int errorCount = errors.length;
final String seconds = (timer.elapsedMilliseconds / 1000.0).toStringAsFixed(1);
final String dartDocMessage = AnalyzeBase.generateDartDocMessage(undocumentedMembers);
final String errorsMessage = AnalyzeBase.generateErrorsMessage(
issueCount: errorCount,
seconds: seconds,
undocumentedMembers: undocumentedMembers,
dartDocMessage: dartDocMessage,
);
if (errorCount > 0) {
......
......@@ -15,21 +15,13 @@ import '../../src/common.dart';
const String _kFlutterRoot = '/data/flutter';
void main() {
testWithoutContext('analyze generate correct DartDoc message', () async {
expect(AnalyzeBase.generateDartDocMessage(0), 'all public member have documentation');
expect(AnalyzeBase.generateDartDocMessage(1), 'one public member lacks documentation');
expect(AnalyzeBase.generateDartDocMessage(2), '2 public members lack documentation');
});
testWithoutContext('analyze generate correct errors message', () async {
expect(
AnalyzeBase.generateErrorsMessage(
issueCount: 0,
seconds: '0.1',
undocumentedMembers: 1,
dartDocMessage: 'one public member lacks documentation',
),
'No issues found! (ran in 0.1s; one public member lacks documentation)',
'No issues found! (ran in 0.1s)',
);
expect(
......@@ -38,10 +30,8 @@ void main() {
issueDiff: 2,
files: 1,
seconds: '0.1',
undocumentedMembers: 1,
dartDocMessage: 'one public member lacks documentation',
),
'3 issues found. (2 new) • analyzed 1 file (ran in 0.1s; one public member lacks documentation)',
'3 issues found. (2 new) • analyzed 1 file (ran in 0.1s)',
);
});
......
......@@ -13,28 +13,15 @@ void main() {
final String message = AnalyzeBase.generateErrorsMessage(
issueCount: 0,
seconds: '10',
undocumentedMembers: 0,
);
expect(message, 'No issues found! (ran in 10s)');
});
testWithoutContext('AnalyzeBase message formatting with undocumented issues', () async {
final String message = AnalyzeBase.generateErrorsMessage(
issueCount: 0,
seconds: '10',
undocumentedMembers: 1,
dartDocMessage: 'test'
);
expect(message, 'No issues found! (ran in 10s; test)');
});
testWithoutContext('AnalyzeBase message formatting with one issue', () async {
final String message = AnalyzeBase.generateErrorsMessage(
issueCount: 1,
seconds: '10',
undocumentedMembers: 0,
);
expect(message, '1 issue found. (ran in 10s)');
......@@ -44,7 +31,6 @@ void main() {
final String message = AnalyzeBase.generateErrorsMessage(
issueCount: 10,
seconds: '10',
undocumentedMembers: 0,
);
expect(message, '10 issues found. (ran in 10s)');
......@@ -54,7 +40,6 @@ void main() {
final String message = AnalyzeBase.generateErrorsMessage(
issueCount: 0,
seconds: '10',
undocumentedMembers: 0,
files: 10,
);
......@@ -65,7 +50,6 @@ void main() {
final String message = AnalyzeBase.generateErrorsMessage(
issueCount: 1,
seconds: '10',
undocumentedMembers: 0,
issueDiff: 1,
);
......@@ -76,7 +60,6 @@ void main() {
final String message = AnalyzeBase.generateErrorsMessage(
issueCount: 0,
seconds: '10',
undocumentedMembers: 0,
issueDiff: -1,
);
......
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