-
Notifications
You must be signed in to change notification settings - Fork 354
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: rewrite the linter for spaces before semicolons in Lean #16532
base: master
Are you sure you want to change the base?
Conversation
grunweg
commented
Sep 6, 2024
•
edited by Command-Master
Loading
edited by Command-Master
- depends on: [Merged by Bors] - feat: rewrite the trailing whitespace linter in Lean #16334
There is an in-progress PR batteries to the same effect: when that PR lands, this linter can be removed. Both implement basically the same logic. This linter is consciously not rewritten as a syntax linter, as a fair number of mathlib contributors have their text editor configured to remove trailing whitespace when saving: with such configurations, in effect, the linter would only fire intermittently (such as, between keypresses), which is not helpful. Running this as a text-based linter in CI, which is auto-fixable, is far more helpful.
PR summary cf9e63e260Import changes for modified filesNo significant changes to the import graph Import changes for all files
|
930f60f
to
2f91482
Compare
Actually, this reveals a bug in the suggested auto-fix: while |
@@ -56,6 +56,10 @@ inductive StyleError where | |||
| adaptationNote | |||
/-- A line ends with windows line endings (\r\n) instead of unix ones (\n). -/ | |||
| windowsLineEnding | |||
/-- A line contains trailing whitespace. -/ | |||
| trailingWhitespace | |||
/-- A line contains the string " ;" -/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[lint-style (comment with "bot fix style" to have the bot commit all style suggestions)] reported by reviewdog 🐶
/-- A line contains the string " ;" -/ | |
/-- A line contains the string ";" -/ |
return (errors, if errors.size > 0 then some fixedLines else none) | ||
|
||
|
||
/-- Lint a collection of input strings for the substring " ;". -/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[lint-style (comment with "bot fix style" to have the bot commit all style suggestions)] reported by reviewdog 🐶
/-- Lint a collection of input strings for the substring " ;". -/ | |
/-- Lint a collection of input strings for the substring ";". -/ |
-- Future: also lint for a semicolon *not* followed by a space or ⟩. | ||
if pos != line.endPos && line.get (line.prev pos) == ' ' then | ||
errors := errors.push (StyleError.semicolon, idx + 1) | ||
fixedLines := fixedLines.set! idx (line.replace " ;" ";") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[lint-style (comment with "bot fix style" to have the bot commit all style suggestions)] reported by reviewdog 🐶
fixedLines := fixedLines.set! idx (line.replace " ;" ";") | |
fixedLines := fixedLines.set! idx (line.replace ";" ";") |
bors d+ |
✌️ grunweg can now approve this pull request. To approve and merge a pull request, simply reply with |
This PR/issue depends on: |