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