Skip to content

Commit 73a945e

Browse files
committed
fix: matching only comment with they are at the start of the line and match comment blocs
1 parent 6807503 commit 73a945e

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

bin/audit/key_parser.dart

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,12 @@ class KeyParser {
9191
final content = file.readAsStringSync();
9292

9393
// remove all comments to avoid false positives
94-
final commentPattern = RegExp(r'\/\/.*?$|\/\*.*?\*/', multiLine: true, dotAll: true);
94+
// remove single-line comments that start the line (optionally preceded by whitespace)
95+
// and multi-line /* ... */ blocks
96+
final commentPattern = RegExp(
97+
r'^[ \t]*//.*?$|/\*[\s\S]*?\*/',
98+
multiLine: true,
99+
);
95100
final commentRemovedContent = content.replaceAll(commentPattern, '');
96101

97102
for (var patternType in KeyPatternType.values) {

0 commit comments

Comments
 (0)