Skip to content

Commit

Permalink
lint: clean up lines-to-ignore
Browse files Browse the repository at this point in the history
  • Loading branch information
Bogdanp committed Dec 25, 2023
1 parent 2ee6b23 commit 28aaf12
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions lint.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,19 @@
(make-parameter null))

(define ignore-all-re #rx"#\\|review: ignore\\|#")
(define ignore-line-re #rx";; (noqa|lint: ignore|review: ignore)")
(define ignore-line-re #rx";; (noqa|lint: ignore|review: ignore)$")
(define (lines-to-ignore filename)
(define ignore-all?
(call-with-input-file filename
(lambda (in)
(regexp-match? ignore-all-re in))))
(cond
[ignore-all? 'all]
[else (call-with-input-file filename
(lambda (in)
(for/list ([(line idx) (in-indexed (in-lines in))]
#:when (regexp-match? ignore-line-re line))
(add1 idx))))]))
(call-with-input-file filename
(lambda (in)
(for/fold ([lines null])
([(line idx) (in-indexed (in-lines in))])
(define all? (regexp-match? ignore-all-re line))
#:final all?
(cond
[all? 'all]
[(regexp-match? ignore-line-re line)
(cons (add1 idx) lines)]
[else lines])))))

(define/contract (lint filename)
(-> path-string? (listof problem?))
Expand All @@ -69,9 +69,9 @@
(current-problem-list)))
(if (pair? the-lines-to-ignore)
(filter-not
(λ (problem)
(λ (p)
(define-values (_source line _col)
(problem-loc problem))
(problem-loc p))
(memv line the-lines-to-ignore))
the-problems)
the-problems))
Expand Down

0 comments on commit 28aaf12

Please sign in to comment.