-
Notifications
You must be signed in to change notification settings - Fork 50
Added uncovered files detection - Issue #529 #2029
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR needs tests.
@@ -1,6 +1,8 @@ | |||
include: package:dart_flutter_team_lints/analysis_options.yaml | |||
|
|||
analyzer: | |||
errors: | |||
unnecessary_this: ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can fix this lint, you don't need to add an exception.
@@ -42,8 +42,10 @@ const _debugTokenPositions = bool.fromEnvironment('DEBUG_COVERAGE'); | |||
/// If [scopedOutput] is non-empty, coverage will be restricted so that only | |||
/// scripts that start with any of the provided paths are considered. | |||
/// | |||
/// If [isolateIds] is set, the coverage gathering will be restricted to only | |||
/// those VM isolates. | |||
/// If [isolateIds] is set, coverage gathering **will not be restricted** to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated change (from #2032 ?)
@@ -2,6 +2,8 @@ | |||
// for details. All rights reserved. Use of this source code is governed by a | |||
// BSD-style license that can be found in the LICENSE file. | |||
|
|||
// ignore_for_file: unnecessary_this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this
@@ -103,6 +106,13 @@ Future<Map<String, dynamic>> collect(Uri serviceUri, bool resume, | |||
isolateIds, | |||
coverableLineCache, | |||
waitPaused); | |||
|
|||
// Apply filtering if a filter function is provided | |||
if (filter != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are these changes for? They seem unrelated to the PR. There's already a bunch of ways of filtering the coverage, so I'm not sure what this is for.
If you check what the _getAllCoverage
function actually returns, this filter definitely won't work as you intend. Did you test your code?
}) { | ||
final pathFilter = _getPathFilter( | ||
reportOn: reportOn, | ||
ignoreGlobs: ignoreGlobs, | ||
); | ||
final buf = StringBuffer(); | ||
|
||
// Get all Dart files in the project | ||
final allDartFiles = resolver.listAllDartFiles().toSet(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lots of duplicated code between formatLcov
and prettyPrint
. Can you factorize them?
@@ -129,6 +132,21 @@ extension FileHitMapsFormatter on Map<String, HitMap> { | |||
buf.write('end_of_record\n'); | |||
} | |||
|
|||
// Add uncovered files if allowed | |||
for (final file in uncoveredFiles) { | |||
if (includeUncovered != null && !includeUncovered(file)) continue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If includeUncovered
is null, then no uncovered files should be included. That's to ensure we don't change behavior for existing users.
@Deprecated('Use Resolver.create') | ||
Resolver({this.packagesPath, this.sdkRoot}) | ||
|
||
Resolver |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you revert all these unrelated formatting changes?
{this.packagesPath, | ||
this.packagePath, | ||
this.sdkRoot, | ||
Map<String, Uri>? packages}) | ||
: _packages = packages; | ||
/// Returns a list of all Dart files in the project. | ||
List<String> listAllDartFiles({String directoryPath = '.'}) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This util doesn't need to be on Resolver
. It doesn't use any of the fields.
Contribution guidelines:
dart format
.Note that many Dart repos have a weekly cadence for reviewing PRs - please allow for some latency before initial review feedback.
Summary
This PR enhances
package:coverage
by adding support for detecting uncovered files.Changes
Testing
dart test
and all tests passed successfully.Issue Reference