@@ -323,28 +323,31 @@ 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
- for i in [ 0 ::lines.size - 1 ] do
327
- let line := lines[i]
326
+ let mut i := 0
327
+ for line in lines do
328
328
if line.back == ' ' then
329
329
errors := errors.push (StyleError.trailingWhitespace, i + 1 )
330
- fixedLines := fixedLines.set! 0 (line.dropRightWhile (· == ' ' ))
330
+ fixedLines := fixedLines.set! i (line.dropRightWhile (· == ' ' ))
331
+ i := i + 1
331
332
return (errors, fixedLines)
332
333
-- xxx: can I avoid set!, as I know the index is inbounds? is there a better way?
333
334
-- ask on zulip for the most idiomatic construct
334
335
335
336
-- TODO: apply the same change to all other linters, once this has been tested...
336
337
337
- def semicolonLinter : TextbaseLinter := fun lines ↦ Id.run do
338
+ def semicolonLinter : TextbasedLinter := fun lines ↦ Id.run do
338
339
let mut errors := Array.mkEmpty 0
339
340
let mut fixedLines := lines
340
- for i in [0 ::lines.size - 1 ] do
341
- let line := lines[i]
341
+ let mut idx := 0
342
+ for line in lines do --for i in [0::lines.size - 1] do
343
+ --let line := lines[ i ]
342
344
if line.contains ';' then
343
345
let replaced := (line.replace " ;" "; " ).replace " " " "
344
346
if replaced != line then
345
- errors := errors.push (StyleError.semicolon, i + 1 ) -- TODO: add error variant etc!
347
+ -- errors := errors.push (StyleError.semicolon, idx + 1) -- TODO: add error variant etc!
346
348
-- "Line contains a space before a semicolon"
347
- fixedLines := fixedLines.set! 0 replaced
349
+ fixedLines := fixedLines.set! idx replaced
350
+ idx := idx+ 1
348
351
return (errors, fixedLines)
349
352
350
353
/-- Whether a collection of lines consists *only* of imports, blank lines and single-line comments.
0 commit comments