@@ -43,6 +43,11 @@ const Set<String> _ignoredFullBasenameList = <String>{
43
43
'resource.h' , // Generated by VS.
44
44
};
45
45
46
+ // Path parts to ignore. Used to ignore entire subdirectories.
47
+ const Set <String > _ignorePathPartList = < String > {
48
+ 'FlutterGeneratedPluginSwiftPackage' , // Generated by Flutter tool.
49
+ };
50
+
46
51
// Third-party packages where the code doesn't have file-level annotation, just
47
52
// the package-level LICENSE file. Each entry must be a directory relative to
48
53
// third_party/packages, as that is the only directory where this is allowed.
@@ -227,7 +232,7 @@ class LicenseCheckCommand extends PackageCommand {
227
232
final List <File > unrecognizedThirdPartyFiles = < File > [];
228
233
229
234
// Most code file types in the repository use '//' comments.
230
- final String defaultFirstParyLicenseBlock = _generateLicenseBlock ('// ' );
235
+ final String defaultFirstPartyLicenseBlock = _generateLicenseBlock ('// ' );
231
236
// A few file types have a different comment structure.
232
237
final Map <String , String > firstPartyLicenseBlockByExtension =
233
238
< String , String > {
@@ -258,19 +263,19 @@ class LicenseCheckCommand extends PackageCommand {
258
263
// still pass since they will be converted back on commit.
259
264
content = content.replaceAll ('\r\n ' , '\n ' );
260
265
261
- final String firstParyLicense =
266
+ final String firstPartyLicense =
262
267
firstPartyLicenseBlockByExtension[p.extension (file.path)] ??
263
- defaultFirstParyLicenseBlock ;
268
+ defaultFirstPartyLicenseBlock ;
264
269
if (_isThirdParty (file)) {
265
270
// Third-party directories allow either known third-party licenses, our
266
271
// the first-party license, as there may be local additions.
267
272
if (! _thirdPartyLicenseBlockRegexes
268
273
.any ((RegExp regex) => regex.hasMatch (content)) &&
269
- ! content.contains (firstParyLicense )) {
274
+ ! content.contains (firstPartyLicense )) {
270
275
unrecognizedThirdPartyFiles.add (file);
271
276
}
272
277
} else {
273
- if (! content.contains (firstParyLicense )) {
278
+ if (! content.contains (firstPartyLicense )) {
274
279
incorrectFirstPartyFiles.add (file);
275
280
}
276
281
}
@@ -305,11 +310,24 @@ class LicenseCheckCommand extends PackageCommand {
305
310
}
306
311
307
312
bool _shouldIgnoreFile (File file) {
308
- final String path = file.path;
309
- return _ignoreBasenameList.contains (p.basenameWithoutExtension (path)) ||
310
- _ignoreSuffixList.any ((String suffix) =>
311
- path.endsWith (suffix) ||
312
- _ignoredFullBasenameList.contains (p.basename (path)));
313
+ if (_ignoreBasenameList.contains (p.basenameWithoutExtension (file.path))) {
314
+ return true ;
315
+ }
316
+
317
+ if (_ignoreSuffixList.any (file.path.endsWith)) {
318
+ return true ;
319
+ }
320
+
321
+ if (_ignoredFullBasenameList.contains (p.basename (file.path))) {
322
+ return true ;
323
+ }
324
+
325
+ final List <String > parts = path.split (file.path);
326
+ if (parts.any (_ignorePathPartList.contains)) {
327
+ return true ;
328
+ }
329
+
330
+ return false ;
313
331
}
314
332
315
333
bool _isThirdParty (File file) {
0 commit comments