Skip to content

Commit

Permalink
Fix empty_catches in analyzer.
Browse files Browse the repository at this point in the history
R=brianwilkerson@google.com

Change-Id: I6abc5acbd93aa12df8ff6226c49f9b72c0313c92
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/127426
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
  • Loading branch information
scheglov authored and commit-bot@chromium.org committed Dec 6, 2019
1 parent 54b7543 commit 54e1c16
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 40 deletions.
1 change: 0 additions & 1 deletion pkg/analyzer/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ analyzer:
# Ignoring "style" lint rules from pedantic for now. There are pre-existing
# violations that need to be cleaned up. Each one can be cleaned up and
# enabled according to the value provided.
empty_catches: ignore
prefer_iterable_wheretype: ignore
# TODO(srawlins): At the time of writing, 2600 violations in lib/. The fix
# is mechanical, via `dartfmt --fix-doc-comments`, but not worth the churn
Expand Down
2 changes: 1 addition & 1 deletion pkg/analyzer/lib/src/generated/source_io.dart
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ class PackageUriResolver extends UriResolver {
return Uri.parse(
"$PACKAGE_SCHEME:${pkgFolder.getName()}$relPath");
}
} catch (e) {}
} catch (_) {}
}
}
}
Expand Down
10 changes: 7 additions & 3 deletions pkg/analyzer/lib/src/services/available_declarations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,9 @@ class DeclarationsContext {
visitFolder(resource);
}
}
} on FileSystemException {}
} on FileSystemException {
// ignored
}
}

visitFolder(_analysisContext.contextRoot.root);
Expand Down Expand Up @@ -481,7 +483,7 @@ class DeclarationsContext {
devDependenciesNode.keys.whereType<String>().toList();
}
}
} catch (e) {}
} catch (_) {}
return _PubspecDependencies(dependencies, devDependencies);
}
}
Expand Down Expand Up @@ -2010,7 +2012,9 @@ class _Package {
return folder;
}
}
} on FileSystemException {}
} on FileSystemException {
// ignored
}
return null;
}
}
Expand Down
4 changes: 3 additions & 1 deletion pkg/analyzer/lib/src/summary2/library_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,9 @@ class LibraryBuilder {
if (uri != null) {
LazyDirective.setSelectedUri(directive, '$uri');
}
} on FormatException {}
} on FormatException {
// ignored
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/analyzer/lib/src/workspace/package_build.dart
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ class PackageBuildWorkspace extends Workspace {
final yaml = loadYaml(pubspec.readAsStringSync());
return PackageBuildWorkspace._(
provider, folder.path, yaml['name'], builder);
} on Exception {}
} catch (_) {}
}

// Go up the folder.
Expand Down
55 changes: 22 additions & 33 deletions pkg/analyzer/test/src/dart/analysis/driver_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -358,10 +358,9 @@ class AnalysisDriverTest extends BaseAnalysisDriverTest {
}

test_addFile_notAbsolutePath() async {
try {
expect(() {
driver.addFile('not_absolute.dart');
fail('ArgumentError expected.');
} on ArgumentError {}
}, throwsArgumentError);
}

test_addFile_shouldRefresh() async {
Expand Down Expand Up @@ -696,10 +695,9 @@ var A = B;
}

test_changeFile_notAbsolutePath() async {
try {
expect(() {
driver.changeFile('not_absolute.dart');
fail('ArgumentError expected.');
} on ArgumentError {}
}, throwsArgumentError);
}

test_changeFile_notUsed() async {
Expand Down Expand Up @@ -1167,10 +1165,9 @@ bbb() {}
}

test_getErrors_notAbsolutePath() async {
try {
expect(() async {
await driver.getErrors('not_absolute.dart');
fail('ArgumentError expected.');
} on ArgumentError {}
}, throwsArgumentError);
}

test_getFilesDefiningClassMemberName_class() async {
Expand Down Expand Up @@ -1286,10 +1283,9 @@ bbb() {}
}

test_getFileSync_notAbsolutePath() async {
try {
expect(() {
driver.getFileSync('not_absolute.dart');
fail('ArgumentError expected.');
} on ArgumentError {}
}, throwsArgumentError);
}

test_getFileSync_part() async {
Expand Down Expand Up @@ -1319,10 +1315,9 @@ main() {
}

test_getIndex_notAbsolutePath() async {
try {
expect(() async {
await driver.getIndex('not_absolute.dart');
fail('ArgumentError expected.');
} on ArgumentError {}
}, throwsArgumentError);
}

test_getLibraryByUri() async {
Expand Down Expand Up @@ -1685,10 +1680,9 @@ main() {
}

test_getResult_notAbsolutePath() async {
try {
expect(() async {
await driver.getResult('not_absolute.dart');
fail('ArgumentError expected.');
} on ArgumentError {}
}, throwsArgumentError);
}

test_getResult_notDartFile() async {
Expand Down Expand Up @@ -1823,10 +1817,9 @@ var A2 = B1;
}

test_getSourceKind_notAbsolutePath() async {
try {
expect(() async {
await driver.getSourceKind('not_absolute.dart');
fail('ArgumentError expected.');
} on ArgumentError {}
}, throwsArgumentError);
}

test_getSourceKind_notDartFile() async {
Expand Down Expand Up @@ -1871,10 +1864,9 @@ import 'package:test/b.dart';
}

test_getUnitElement_notAbsolutePath() async {
try {
expect(() async {
await driver.getUnitElement('not_absolute.dart');
fail('ArgumentError expected.');
} on ArgumentError {}
}, throwsArgumentError);
}

test_getUnitElement_notDart() async {
Expand Down Expand Up @@ -2140,10 +2132,9 @@ import 'b.dart';
}

test_parseFile_notAbsolutePath() async {
try {
expect(() async {
await driver.parseFile('not_absolute.dart');
fail('ArgumentError expected.');
} on ArgumentError {}
}, throwsArgumentError);
}

test_parseFile_notDart() async {
Expand Down Expand Up @@ -2173,10 +2164,9 @@ import 'b.dart';
}

test_parseFileSync_notAbsolutePath() async {
try {
expect(() {
driver.parseFileSync('not_absolute.dart');
fail('ArgumentError expected.');
} on ArgumentError {}
}, throwsArgumentError);
}

test_parseFileSync_notDart() {
Expand Down Expand Up @@ -2742,10 +2732,9 @@ var A = B;
}

test_removeFile_notAbsolutePath() async {
try {
expect(() {
driver.removeFile('not_absolute.dart');
fail('ArgumentError expected.');
} on ArgumentError {}
}, throwsArgumentError);
}

test_resetUriResolution() async {
Expand Down

0 comments on commit 54e1c16

Please sign in to comment.