Reduce the amount of spam from analyze watch. (#7582)
See https://github.com/dart-lang/sdk/issues/28463, which I think is a regression. This also fixes the regression introduced by https://codereview.chromium.org/2559773002 whereby we were no longer checking any of the lints.
This commit is contained in:
parent
1e1463216a
commit
cbda208b4b
@ -26,8 +26,10 @@ analyzer:
|
|||||||
todo: ignore
|
todo: ignore
|
||||||
exclude:
|
exclude:
|
||||||
- 'bin/cache/**'
|
- 'bin/cache/**'
|
||||||
- 'dev/missing_dependency_tests/**'
|
# the following two are relative to the stocks example and the flutter package respectively
|
||||||
- 'packages/flutter_tools/test/data/dart_dependencies_test/**'
|
# see https://github.com/dart-lang/sdk/issues/28463
|
||||||
|
- 'lib/i18n/stock_messages_*.dart'
|
||||||
|
- 'lib/src/http/**'
|
||||||
|
|
||||||
linter:
|
linter:
|
||||||
rules:
|
rules:
|
||||||
|
@ -25,10 +25,9 @@ analyzer:
|
|||||||
strong_mode_down_cast_composite: ignore
|
strong_mode_down_cast_composite: ignore
|
||||||
# allow having TODOs in the code
|
# allow having TODOs in the code
|
||||||
todo: ignore
|
todo: ignore
|
||||||
exclude:
|
# `flutter analyze` (without `--watch`) just ignores directories
|
||||||
- 'bin/cache/**'
|
# that contain a .dartignore file, and this file does not have any
|
||||||
- 'dev/missing_dependency_tests/**'
|
# effect on what files are actually analyzed.
|
||||||
- 'packages/flutter_tools/test/data/dart_dependencies_test/**'
|
|
||||||
|
|
||||||
linter:
|
linter:
|
||||||
rules:
|
rules:
|
||||||
|
4
dev/missing_dependency_tests/.analysis_options
Normal file
4
dev/missing_dependency_tests/.analysis_options
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
analyzer:
|
||||||
|
exclude:
|
||||||
|
- '**'
|
||||||
|
|
0
dev/missing_dependency_tests/.dartignore
Normal file
0
dev/missing_dependency_tests/.dartignore
Normal file
@ -1,3 +0,0 @@
|
|||||||
analyzer:
|
|
||||||
exclude:
|
|
||||||
- 'lib/i18n/stock_messages_*.dart'
|
|
0
examples/stocks/lib/i18n/.dartignore
Normal file
0
examples/stocks/lib/i18n/.dartignore
Normal file
@ -132,6 +132,7 @@ class FlutterError extends AssertionError {
|
|||||||
///
|
///
|
||||||
/// All sentences in the error should be correctly punctuated (i.e.,
|
/// All sentences in the error should be correctly punctuated (i.e.,
|
||||||
/// do end the error message with a period).
|
/// do end the error message with a period).
|
||||||
|
@override
|
||||||
final String message;
|
final String message;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
0
packages/flutter/lib/src/http/.dartignore
Normal file
0
packages/flutter/lib/src/http/.dartignore
Normal file
@ -73,14 +73,9 @@ class AnalyzeOnce extends AnalyzeBase {
|
|||||||
pubSpecDirectories.add(currentDirectory);
|
pubSpecDirectories.add(currentDirectory);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(ianh): Fix the intl package resource generator
|
|
||||||
// TODO(pq): extract this regexp from the exclude in options
|
|
||||||
RegExp stockExampleFiles = new RegExp('examples/stocks/lib/i18n/.*\.dart\$');
|
|
||||||
|
|
||||||
if (flutterRepo) {
|
if (flutterRepo) {
|
||||||
for (Directory dir in repoPackages) {
|
for (Directory dir in repoPackages) {
|
||||||
_collectDartFiles(dir, dartFiles,
|
_collectDartFiles(dir, dartFiles);
|
||||||
exclude: (FileSystemEntity entity) => stockExampleFiles.hasMatch(entity.path));
|
|
||||||
pubSpecDirectories.add(dir);
|
pubSpecDirectories.add(dir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -164,7 +159,6 @@ class AnalyzeOnce extends AnalyzeBase {
|
|||||||
for (AnalysisErrorDescription error in errors) {
|
for (AnalysisErrorDescription error in errors) {
|
||||||
bool shouldIgnore = false;
|
bool shouldIgnore = false;
|
||||||
if (error.errorCode.name == 'public_member_api_docs') {
|
if (error.errorCode.name == 'public_member_api_docs') {
|
||||||
// https://github.com/dart-lang/linter/issues/207
|
|
||||||
// https://github.com/dart-lang/linter/issues/208
|
// https://github.com/dart-lang/linter/issues/208
|
||||||
if (isFlutterLibrary(error.source.fullName)) {
|
if (isFlutterLibrary(error.source.fullName)) {
|
||||||
if (!argResults['dartdocs']) {
|
if (!argResults['dartdocs']) {
|
||||||
@ -175,9 +169,6 @@ class AnalyzeOnce extends AnalyzeBase {
|
|||||||
shouldIgnore = true;
|
shouldIgnore = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO(ianh): Fix the Dart mojom compiler
|
|
||||||
if (error.source.fullName.endsWith('.mojom.dart'))
|
|
||||||
shouldIgnore = true;
|
|
||||||
if (shouldIgnore)
|
if (shouldIgnore)
|
||||||
continue;
|
continue;
|
||||||
printError(error.asString());
|
printError(error.asString());
|
||||||
@ -226,18 +217,18 @@ class AnalyzeOnce extends AnalyzeBase {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<File> _collectDartFiles(Directory dir, List<File> collected, {FileFilter exclude}) {
|
List<File> _collectDartFiles(Directory dir, List<File> collected) {
|
||||||
// Bail out in case of a .dartignore.
|
// Bail out in case of a .dartignore.
|
||||||
if (fs.isFileSync(path.join(path.dirname(dir.path), '.dartignore')))
|
if (fs.isFileSync(path.join(dir.path, '.dartignore')))
|
||||||
return collected;
|
return collected;
|
||||||
|
|
||||||
for (FileSystemEntity entity in dir.listSync(recursive: false, followLinks: false)) {
|
for (FileSystemEntity entity in dir.listSync(recursive: false, followLinks: false)) {
|
||||||
if (isDartFile(entity) && (exclude == null || !exclude(entity)))
|
if (isDartFile(entity))
|
||||||
collected.add(entity);
|
collected.add(entity);
|
||||||
if (entity is Directory) {
|
if (entity is Directory) {
|
||||||
String name = path.basename(entity.path);
|
String name = path.basename(entity.path);
|
||||||
if (!name.startsWith('.') && name != 'packages')
|
if (!name.startsWith('.') && name != 'packages')
|
||||||
_collectDartFiles(entity, collected, exclude: exclude);
|
_collectDartFiles(entity, collected);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,6 +84,7 @@ class DriveCommand extends RunCommandBase {
|
|||||||
Device get device => _device;
|
Device get device => _device;
|
||||||
|
|
||||||
/// Subscription to log messages printed on the device or simulator.
|
/// Subscription to log messages printed on the device or simulator.
|
||||||
|
// ignore: cancel_subscriptions
|
||||||
StreamSubscription<String> _deviceLogSubscription;
|
StreamSubscription<String> _deviceLogSubscription;
|
||||||
|
|
||||||
int get debugPort => int.parse(argResults['debug-port']);
|
int get debugPort => int.parse(argResults['debug-port']);
|
||||||
|
@ -17,6 +17,7 @@ import 'package:analyzer/src/generated/java_io.dart'; // ignore: implementation_
|
|||||||
import 'package:analyzer/src/generated/source.dart'; // ignore: implementation_imports
|
import 'package:analyzer/src/generated/source.dart'; // ignore: implementation_imports
|
||||||
import 'package:analyzer/src/generated/source_io.dart'; // ignore: implementation_imports
|
import 'package:analyzer/src/generated/source_io.dart'; // ignore: implementation_imports
|
||||||
import 'package:analyzer/src/task/options.dart'; // ignore: implementation_imports
|
import 'package:analyzer/src/task/options.dart'; // ignore: implementation_imports
|
||||||
|
import 'package:linter/src/rules.dart' as linter; // ignore: implementation_imports
|
||||||
import 'package:cli_util/cli_util.dart' as cli_util;
|
import 'package:cli_util/cli_util.dart' as cli_util;
|
||||||
import 'package:package_config/packages.dart' show Packages;
|
import 'package:package_config/packages.dart' show Packages;
|
||||||
import 'package:package_config/src/packages_impl.dart' show MapPackages; // ignore: implementation_imports
|
import 'package:package_config/src/packages_impl.dart' show MapPackages; // ignore: implementation_imports
|
||||||
@ -28,6 +29,12 @@ import '../base/file_system.dart' hide IOSink;
|
|||||||
import '../base/io.dart';
|
import '../base/io.dart';
|
||||||
|
|
||||||
class AnalysisDriver {
|
class AnalysisDriver {
|
||||||
|
AnalysisDriver(this.options) {
|
||||||
|
AnalysisEngine.instance.logger =
|
||||||
|
new _StdLogger(outSink: options.outSink, errorSink: options.errorSink);
|
||||||
|
_processPlugins();
|
||||||
|
}
|
||||||
|
|
||||||
Set<Source> _analyzedSources = new HashSet<Source>();
|
Set<Source> _analyzedSources = new HashSet<Source>();
|
||||||
|
|
||||||
AnalysisOptionsProvider analysisOptionsProvider =
|
AnalysisOptionsProvider analysisOptionsProvider =
|
||||||
@ -38,11 +45,6 @@ class AnalysisDriver {
|
|||||||
AnalysisContext context;
|
AnalysisContext context;
|
||||||
|
|
||||||
DriverOptions options;
|
DriverOptions options;
|
||||||
AnalysisDriver(this.options) {
|
|
||||||
AnalysisEngine.instance.logger =
|
|
||||||
new _StdLogger(outSink: options.outSink, errorSink: options.errorSink);
|
|
||||||
_processPlugins();
|
|
||||||
}
|
|
||||||
|
|
||||||
String get sdkDir => options.dartSdkPath ?? cli_util.getSdkDir().path;
|
String get sdkDir => options.dartSdkPath ?? cli_util.getSdkDir().path;
|
||||||
|
|
||||||
@ -51,17 +53,17 @@ class AnalysisDriver {
|
|||||||
List<AnalysisErrorDescription> errors = <AnalysisErrorDescription>[];
|
List<AnalysisErrorDescription> errors = <AnalysisErrorDescription>[];
|
||||||
for (AnalysisErrorInfo info in infos) {
|
for (AnalysisErrorInfo info in infos) {
|
||||||
for (AnalysisError error in info.errors) {
|
for (AnalysisError error in info.errors) {
|
||||||
if (!_isFiltered(error)) {
|
if (!_isFiltered(error))
|
||||||
errors.add(new AnalysisErrorDescription(error, info.lineInfo));
|
errors.add(new AnalysisErrorDescription(error, info.lineInfo));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return errors;
|
return errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<AnalysisErrorInfo> _analyze(Iterable<File> files) {
|
List<AnalysisErrorInfo> _analyze(Iterable<File> files) {
|
||||||
context = AnalysisEngine.instance.createAnalysisContext();
|
context = AnalysisEngine.instance.createAnalysisContext();
|
||||||
_processAnalysisOptions(context, options);
|
_processAnalysisOptions();
|
||||||
|
context.analysisOptions = options;
|
||||||
PackageInfo packageInfo = new PackageInfo(options.packageMap);
|
PackageInfo packageInfo = new PackageInfo(options.packageMap);
|
||||||
List<UriResolver> resolvers = _getResolvers(context, packageInfo.asMap());
|
List<UriResolver> resolvers = _getResolvers(context, packageInfo.asMap());
|
||||||
context.sourceFactory =
|
context.sourceFactory =
|
||||||
@ -94,7 +96,6 @@ class AnalysisDriver {
|
|||||||
List<UriResolver> _getResolvers(InternalAnalysisContext context,
|
List<UriResolver> _getResolvers(InternalAnalysisContext context,
|
||||||
Map<String, List<file_system.Folder>> packageMap) {
|
Map<String, List<file_system.Folder>> packageMap) {
|
||||||
|
|
||||||
|
|
||||||
// Create our list of resolvers.
|
// Create our list of resolvers.
|
||||||
List<UriResolver> resolvers = <UriResolver>[];
|
List<UriResolver> resolvers = <UriResolver>[];
|
||||||
|
|
||||||
@ -106,9 +107,6 @@ class AnalysisDriver {
|
|||||||
// Fail fast if no URI mappings are found.
|
// Fail fast if no URI mappings are found.
|
||||||
assert(sdk.libraryMap.size() > 0);
|
assert(sdk.libraryMap.size() > 0);
|
||||||
sdk.analysisOptions = context.analysisOptions;
|
sdk.analysisOptions = context.analysisOptions;
|
||||||
// TODO(pq): re-enable once we have a proper story for SDK summaries
|
|
||||||
// in the presence of embedders (https://github.com/dart-lang/sdk/issues/26467).
|
|
||||||
sdk.useSummary = false;
|
|
||||||
|
|
||||||
resolvers.add(new DartUriResolver(sdk));
|
resolvers.add(new DartUriResolver(sdk));
|
||||||
} else {
|
} else {
|
||||||
@ -141,17 +139,15 @@ class AnalysisDriver {
|
|||||||
return processor != null && processor.severity == null;
|
return processor != null && processor.severity == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _processAnalysisOptions(
|
void _processAnalysisOptions() {
|
||||||
AnalysisContext context, AnalysisOptions analysisOptions) {
|
|
||||||
String optionsPath = options.analysisOptionsFile;
|
String optionsPath = options.analysisOptionsFile;
|
||||||
if (optionsPath != null) {
|
if (optionsPath != null) {
|
||||||
file_system.File file =
|
file_system.File file =
|
||||||
PhysicalResourceProvider.INSTANCE.getFile(optionsPath);
|
PhysicalResourceProvider.INSTANCE.getFile(optionsPath);
|
||||||
Map<Object, Object> optionMap =
|
Map<Object, Object> optionMap =
|
||||||
analysisOptionsProvider.getOptionsFromFile(file);
|
analysisOptionsProvider.getOptionsFromFile(file);
|
||||||
if (optionMap != null) {
|
if (optionMap != null)
|
||||||
applyToAnalysisOptions(context.analysisOptions, optionMap);
|
applyToAnalysisOptions(options, optionMap);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,23 +156,26 @@ class AnalysisDriver {
|
|||||||
plugins.addAll(AnalysisEngine.instance.requiredPlugins);
|
plugins.addAll(AnalysisEngine.instance.requiredPlugins);
|
||||||
ExtensionManager manager = new ExtensionManager();
|
ExtensionManager manager = new ExtensionManager();
|
||||||
manager.processPlugins(plugins);
|
manager.processPlugins(plugins);
|
||||||
|
linter.registerLintRules();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class AnalysisDriverException implements Exception {
|
class AnalysisDriverException implements Exception {
|
||||||
final String message;
|
|
||||||
AnalysisDriverException([this.message]);
|
AnalysisDriverException([this.message]);
|
||||||
|
|
||||||
|
final String message;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() => message == null ? 'Exception' : 'Exception: $message';
|
String toString() => message == null ? 'Exception' : 'Exception: $message';
|
||||||
}
|
}
|
||||||
|
|
||||||
class AnalysisErrorDescription {
|
class AnalysisErrorDescription {
|
||||||
|
AnalysisErrorDescription(this.error, this.line);
|
||||||
|
|
||||||
static Directory cwd = fs.currentDirectory.absolute;
|
static Directory cwd = fs.currentDirectory.absolute;
|
||||||
|
|
||||||
final AnalysisError error;
|
final AnalysisError error;
|
||||||
final LineInfo line;
|
final LineInfo line;
|
||||||
AnalysisErrorDescription(this.error, this.line);
|
|
||||||
|
|
||||||
ErrorCode get errorCode => error.errorCode;
|
ErrorCode get errorCode => error.errorCode;
|
||||||
|
|
||||||
@ -203,7 +202,6 @@ class AnalysisErrorDescription {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class DriverOptions extends AnalysisOptionsImpl {
|
class DriverOptions extends AnalysisOptionsImpl {
|
||||||
|
|
||||||
DriverOptions() {
|
DriverOptions() {
|
||||||
// Set defaults.
|
// Set defaults.
|
||||||
lint = true;
|
lint = true;
|
||||||
@ -223,9 +221,6 @@ class DriverOptions extends AnalysisOptionsImpl {
|
|||||||
/// The path to analysis options.
|
/// The path to analysis options.
|
||||||
String analysisOptionsFile;
|
String analysisOptionsFile;
|
||||||
|
|
||||||
/// Analysis options map.
|
|
||||||
Map<Object, Object> analysisOptions;
|
|
||||||
|
|
||||||
/// Out sink for logging.
|
/// Out sink for logging.
|
||||||
IOSink outSink = stdout;
|
IOSink outSink = stdout;
|
||||||
|
|
||||||
@ -247,18 +242,19 @@ class PackageInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Packages _packages;
|
Packages _packages;
|
||||||
HashMap<String, List<file_system.Folder>> _map =
|
|
||||||
new HashMap<String, List<file_system.Folder>>();
|
|
||||||
|
|
||||||
Map<String, List<file_system.Folder>> asMap() => _map;
|
Map<String, List<file_system.Folder>> asMap() => _map;
|
||||||
|
HashMap<String, List<file_system.Folder>> _map =
|
||||||
|
new HashMap<String, List<file_system.Folder>>();
|
||||||
|
|
||||||
Packages asPackages() => _packages;
|
Packages asPackages() => _packages;
|
||||||
}
|
}
|
||||||
|
|
||||||
class _StdLogger extends Logger {
|
class _StdLogger extends Logger {
|
||||||
|
_StdLogger({this.outSink, this.errorSink});
|
||||||
|
|
||||||
final IOSink outSink;
|
final IOSink outSink;
|
||||||
final IOSink errorSink;
|
final IOSink errorSink;
|
||||||
_StdLogger({this.outSink, this.errorSink});
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void logError(String message, [Exception exception]) =>
|
void logError(String message, [Exception exception]) =>
|
||||||
@ -267,6 +263,7 @@ class _StdLogger extends Logger {
|
|||||||
@override
|
@override
|
||||||
void logInformation(String message, [Exception exception]) {
|
void logInformation(String message, [Exception exception]) {
|
||||||
// TODO(pq): remove once addressed in analyzer (http://dartbug.com/28285)
|
// TODO(pq): remove once addressed in analyzer (http://dartbug.com/28285)
|
||||||
if (message != 'No definition of type FutureOr') outSink.writeln(message);
|
if (message != 'No definition of type FutureOr')
|
||||||
|
outSink.writeln(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user