Skip to content
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

Open
wants to merge 21 commits into
base: master
Choose a base branch
from

Conversation

grunweg
Copy link
Collaborator

@grunweg grunweg commented Sep 6, 2024

grunweg added 15 commits August 30, 2024 23:26
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.
@grunweg grunweg added the t-linter Linter label Sep 6, 2024
Copy link

github-actions bot commented Sep 6, 2024

PR summary cf9e63e260

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

Declarations diff

+ semicolonLinter
+ trailingWhitespaceLinter
- line_endings_check(lines,

You can run this locally as follows
## summary with just the declaration names:
./scripts/declarations_diff.sh <optional_commit>

## more verbose report:
./scripts/declarations_diff.sh long <optional_commit>

The doc-module for script/declarations_diff.sh contains some details about this script.


No changes to technical debt.

You can run this locally as

./scripts/technical-debt-metrics.sh pr_summary
  • The relative value is the weighted sum of the differences with weight given by the inverse of the current value of the statistic.
  • The absolute value is the relative value divided by the total sum of the inverses of the current values (i.e. the weighted average of the differences).

@mathlib4-dependent-issues-bot mathlib4-dependent-issues-bot added the blocked-by-other-PR This PR depends on another PR to Mathlib (this label is automatically managed by a bot) label Sep 6, 2024
@leanprover-community-bot-assistant leanprover-community-bot-assistant added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Sep 12, 2024
@grunweg grunweg force-pushed the MR-rewrite-semicolonlinter branch from 930f60f to 2f91482 Compare November 21, 2024 15:54
@grunweg
Copy link
Collaborator Author

grunweg commented Nov 21, 2024

Actually, this reveals a bug in the suggested auto-fix: while lake exe lint-style respects the linter exclusions, the auto-fix doesn't. Marking as awaiting-author.

@grunweg grunweg added awaiting-author A reviewer has asked the author a question or requested changes and removed merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) labels Nov 21, 2024
@@ -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 " ;" -/

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 🐶

Suggested change
/-- 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 " ;". -/

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 🐶

Suggested change
/-- 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 " ;" ";")

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 🐶

Suggested change
fixedLines := fixedLines.set! idx (line.replace " ;" ";")
fixedLines := fixedLines.set! idx (line.replace ";" ";")

@kim-em
Copy link
Contributor

kim-em commented Nov 22, 2024

bors d+

@mathlib-bors
Copy link
Contributor

mathlib-bors bot commented Nov 22, 2024

✌️ grunweg can now approve this pull request. To approve and merge a pull request, simply reply with bors r+. More detailed instructions are available here.

@leanprover-community-mathlib4-bot leanprover-community-mathlib4-bot added delegated and removed awaiting-author A reviewer has asked the author a question or requested changes labels Nov 22, 2024
@mathlib4-dependent-issues-bot mathlib4-dependent-issues-bot removed the blocked-by-other-PR This PR depends on another PR to Mathlib (this label is automatically managed by a bot) label Nov 22, 2024
@mathlib4-dependent-issues-bot
Copy link
Collaborator

This PR/issue depends on:

@leanprover-community-bot-assistant leanprover-community-bot-assistant added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
delegated merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) t-linter Linter
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants