Skip to content

Commit

Permalink
fix: negatives
Browse files Browse the repository at this point in the history
  • Loading branch information
kevincobain2000 committed Dec 5, 2024
1 parent 15e7bf6 commit 9998f8a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ func (w *Watcher) Scan() (*ScanResult, error) {
bytesRead += int64(len(line)) + 1 // Adding 1 for the newline character
currentLineNum++
linesRead = currentLineNum - w.lastLineNum
// convert to positive number
if linesRead < 0 {
linesRead = -linesRead
}
slog.Debug("Scanning line", "line", string(line), "lineNum", currentLineNum, "linesRead", linesRead)
if w.ignorePattern != "" && ri.Match(line) {
continue
Expand All @@ -133,6 +137,9 @@ func (w *Watcher) Scan() (*ScanResult, error) {
matchPercentage := 0.0
if linesRead > 0 {
matchPercentage = float64(errorCounts) * 100 / float64(linesRead)
if matchPercentage > 100 {
matchPercentage = 100
}
}

// Restrict to two decimal places
Expand Down

0 comments on commit 9998f8a

Please sign in to comment.