From 0a76419b43d1a45c5c91dfb8ed90b29857fc6e3c Mon Sep 17 00:00:00 2001 From: Moritz Date: Mon, 16 Dec 2024 14:36:10 +0100 Subject: [PATCH] Ignore g.dart files --- pkgs/firehose/lib/src/health/license.dart | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/pkgs/firehose/lib/src/health/license.dart b/pkgs/firehose/lib/src/health/license.dart index 8492ee46..ae39d2e5 100644 --- a/pkgs/firehose/lib/src/health/license.dart +++ b/pkgs/firehose/lib/src/health/license.dart @@ -26,7 +26,7 @@ Future> 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; @@ -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)');