File tree 1 file changed +5
-8
lines changed
1 file changed +5
-8
lines changed Original file line number Diff line number Diff line change @@ -323,15 +323,12 @@ def broadImportsLinter : TextbasedLinter := fun lines ↦ Id.run do
323
323
def trailingWhitespaceLinter : TextbasedLinter := fun lines ↦ Id.run do
324
324
let mut errors := Array.mkEmpty 0
325
325
let mut fixedLines := lines
326
- -- invariant: this equals the current index of 'line' in 'lines',
327
- -- hence starts at 0 and is incremented *at the end* of the loop
328
- let mut lineNumber := 0
329
- for line in lines do
326
+ for h : idx in [:lines.size] do
327
+ let line := lines[idx]
330
328
if line.back == ' ' then
331
- errors := errors.push (StyleError.trailingWhitespace, lineNumber)
332
- fixedLines := fixedLines.set! 0 (line.dropRightWhile (· == ' ' ))
333
- lineNumber := lineNumber + 1
334
- return (errors, fixedLines)
329
+ errors := errors.push (StyleError.trailingWhitespace, idx + 1 )
330
+ fixedLines := fixedLines.set! idx (line.dropRightWhile (· == ' ' ))
331
+ return (errors, if errors.size > 0 then some fixedLines else none)
335
332
336
333
337
334
/-- Whether a collection of lines consists *only* of imports, blank lines and single-line comments.
You can’t perform that action at this time.
0 commit comments