Skip to content

Commit

Permalink
Ignore g.dart files
Browse files Browse the repository at this point in the history
  • Loading branch information
mosuem committed Dec 16, 2024
1 parent 9d9a86b commit 0a76419
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions pkgs/firehose/lib/src/health/license.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Future<List<String>> getFilesWithoutLicenses(
if (ignoredFiles.none((glob) =>
glob.matches(path.relative(file.path, from: repositoryDir.path)))) {
var fileContents = File(file.path).readAsStringSync();
if (!fileIsGenerated(fileContents) &&
if (!fileIsGenerated(fileContents, file.path) &&
!fileContainsCopyright(fileContents)) {
print(relativePath);
return relativePath;
Expand All @@ -41,10 +41,12 @@ Done, found ${filesWithoutLicenses.length} files without license headers''');
return filesWithoutLicenses;
}

bool fileIsGenerated(String fileContents) => fileContents
.split('\n')
.takeWhile((line) => line.startsWith('//') || line.isEmpty)
.any((line) => line.toLowerCase().contains('generate'));
bool fileIsGenerated(String fileContents, String path) =>
path.endsWith('g.dart') ||
fileContents
.split('\n')
.takeWhile((line) => line.startsWith('//') || line.isEmpty)
.any((line) => line.toLowerCase().contains('generate'));

bool fileContainsCopyright(String fileContents) =>
fileContents.contains('// Copyright (c)');

0 comments on commit 0a76419

Please sign in to comment.