getIgnoreReason static method

String? getIgnoreReason(
  1. String filePath,
  2. String? content,
  3. List<String> patterns,
  4. List<String> exactFiles, {
  5. CommentStyle style = CommentStyle.cStyle,
})

Get the reason a file should be ignored

Implementation

static String? getIgnoreReason(
  String filePath,
  String? content,
  List<String> patterns,
  List<String> exactFiles, {
  CommentStyle style = CommentStyle.cStyle,
}) {
  final normalizedPath = filePath.replaceAll('\\', '/');

  // Check exact file matches
  for (final file in exactFiles) {
    if (normalizedPath == file || normalizedPath.endsWith('/$file')) {
      return 'In ignore files list';
    }
  }

  // Check patterns
  for (final pattern in patterns) {
    if (_matchGlobPattern(normalizedPath, pattern)) {
      return 'Matches pattern: $pattern';
    }
  }

  // Check generated markers in content
  if (content != null && hasGeneratedMarker(content, style)) {
    return 'Contains generated file marker';
  }

  return null;
}