Skip to content

Commit

Permalink
Merge pull request #14 from emanuel-braz/develop
Browse files Browse the repository at this point in the history
Remove 'part of' files from list of imports
  • Loading branch information
emanuel-braz authored Mar 19, 2022
2 parents 87562b6 + d77fa8c commit d3ce34a
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 12 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# [3.0.1] 2022-03-19
#### Fix
- remove 'part of' files from list of imports

# [3.0.0] 2022-03-07
#### Break
- Spelling fixes: `--exclude-sufix` becomes `--exclude-suffix`
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## DLCOV - CLI to add code coverage threshold (CI/CD, git hooks, etc.)
## DLCOV - CLI to verify code coverage threshold (CI/CD, git hooks, etc.)

### Usage Example
#### Long
Expand Down
30 changes: 20 additions & 10 deletions lib/usecases/create_file_references.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ class CreateFileReferences {
final fileSytemEntities =
await _helper.getFileSystemEntities(Directory(_sourceDirectory));

final filteredFilePaths = _helper.getFilteredFilePaths(
fileSytemEntities, _removeFileWithSuffixes);
final candidateFiles =
await _helper.getOnlyCandidateFiles(fileSytemEntities);

final filteredFilePaths =
_helper.getFilteredFilePaths(candidateFiles, _removeFileWithSuffixes);

final fileImports = [
'/*\n'
Expand Down Expand Up @@ -68,18 +71,25 @@ class CreateFileReferencesHelper {
return completer.future;
}

List<String> getFilteredFilePaths(List<FileSystemEntity> fileSytemEntities,
List<String> removeFileWithSuffixes) {
return fileSytemEntities
.where((fileSystemEntity) {
return fileSystemEntity.path.endsWith('.dart') &&
!removeFileWithSuffixes
.any((suffix) => fileSystemEntity.path.endsWith(suffix));
})
List<String> getFilteredFilePaths(
List<File> files, List<String> removeFileWithSuffixes) {
return files
.where((file) =>
!removeFileWithSuffixes.any((suffix) => file.path.endsWith(suffix)))
.map((e) => e.path)
.toList();
}

Future<List<File>> getOnlyCandidateFiles(
List<FileSystemEntity> fileSytemEntities) async {
List<File> candidateFiles = fileSytemEntities.whereType<File>().toList();
return candidateFiles
.where((file) => file.path.endsWith('.dart'))
.where((file) =>
!file.readAsLinesSync().any((line) => line.startsWith('part of')))
.toList();
}

Future<File> writeContentToFile(String content, String path) =>
fileSystemUtil.writeToFile(content, path);
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: dlcov
description: A CLI to add code coverage threshold (CI/CD, git hooks, etc.)
version: 3.0.0
version: 3.0.1
homepage: https://github.com/emanuel-braz/dlcov

environment:
Expand Down

0 comments on commit d3ce34a

Please sign in to comment.