Skip to content

Commit

Permalink
Only create SourceFile for leak when detected
Browse files Browse the repository at this point in the history
  • Loading branch information
sigurdm committed Sep 15, 2023
1 parent 5da02a2 commit 1bc4462
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions lib/src/validator/leak_detection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ final class LeakPattern {
/// * Captured group have a entropy higher than [_entropyThresholds] requires
/// for the given _group identifier_, and,
Iterable<LeakMatch> findPossibleLeaks(String file, String content) sync* {
final source = SourceFile.fromString(content, url: file);
for (final m in _pattern.allMatches(content)) {
if (_allowed.any((s) => m.group(0)!.contains(s))) {
continue;
Expand All @@ -180,7 +179,7 @@ final class LeakPattern {
.any((entry) => _entropy(m.group(entry.key)!) < entry.value)) {
continue;
}

final source = SourceFile.fromString(content, url: file);
yield LeakMatch(
this,
source.span(m.start, m.start + m.group(0)!.length),
Expand Down

0 comments on commit 1bc4462

Please sign in to comment.