Skip to content

[Merged by Bors] - feat: the longFile linter#15610

Closed
adomani wants to merge 55 commits intomasterfrom
adomani/long_file_linter
Closed

[Merged by Bors] - feat: the longFile linter#15610
adomani wants to merge 55 commits intomasterfrom
adomani/long_file_linter

Conversation

@adomani
Copy link
Copy Markdown
Contributor

@adomani adomani commented Aug 8, 2024

The "longFile" linter is a syntax linter. It emits a warning on files which are longer than a certain number of lines
(1500 by default). A value of 0 silences the linter entirely.

This PR also modifies the TextBased fileTooLong linter: now it only lints files that do not contain set_option linter.style.longFile , and removes the exceptions that are now covered by the "longFile" linter.

The TextBased longFile linter stays (for now), though it is going to be removed soon.


Once #15845 lands, the text-based linter can be removed.

I tried setting the default option for the linter to 0 and then modifying it in the lakefile to be 1500 for Mathlib, but I could not get it to work.

Open in Gitpod

@github-actions
Copy link
Copy Markdown

github-actions bot commented Aug 8, 2024

PR summary c01109e5bb

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

Declarations diff

+ longFileLinter

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.

@adomani adomani added the t-linter Linter label Aug 8, 2024
@adomani
Copy link
Copy Markdown
Contributor Author

adomani commented Aug 8, 2024

What I feel is really missing for this linter is a test. However, I do not know how to test it, since eoi is not a "normal" syntax node and #guard_msgs in does not latch onto it.

@grunweg
Copy link
Copy Markdown
Contributor

grunweg commented Aug 10, 2024

Two quick thoughts (I can review properly next week):

  • can you add a comment to the text-based linter about this, including that many style exceptions are not necessary as these are managed by the syntax based linter, and why both linter will co-exist?
  • can you update the technical debt counter as well? Currently, it counts the number of "long file" style exceptions; can you ensure to also count the number of "set_option linter.longFile" (and add these... if a shell script allows this)?
  • as I said already: a syntax linter has much nicer user experience; thanks for upgrading the text-based linter even further!

@grunweg grunweg added the awaiting-author A reviewer has asked the author a question or requested changes. label Aug 10, 2024
@adomani
Copy link
Copy Markdown
Contributor Author

adomani commented Aug 11, 2024

Michael, thank you for the review!

I expanded the docs and comment to the text-based linters, mentioning the syntax one.

I also added the set_option linter.longFile count to the technical debts metrics. This is what I see locally:

$ printf '%s|%s\n' "$(
  { grep 'ERR_NUM_LIN' scripts/style-exceptions.txt
    grep '^set_option linter.longFile [0-9]*' $(git ls-files '*.lean') ; } | wc -l
)" "large files"
66|large files

and it matches the number that the Zulip post has.

@adomani adomani removed the awaiting-author A reviewer has asked the author a question or requested changes. label Aug 11, 2024
@ghost ghost added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Aug 12, 2024
Copy link
Copy Markdown
Contributor

@grunweg grunweg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for rewriting this linter! I took the liberty to propose some wording changes directly - feel free to revert any you dislike. I have one minor comment - apart from that, this looks good to go.

@grunweg
Copy link
Copy Markdown
Contributor

grunweg commented Aug 15, 2024

(Long-term, it would be nicest to have this PR remove the text-based linter instead, and import this linter in Mathlib.Init instead. We'll see in which order things land.)

@grunweg grunweg added the awaiting-author A reviewer has asked the author a question or requested changes. label Aug 15, 2024
grunweg added a commit that referenced this pull request Aug 30, 2024
Not recognising one is more confusing than any other behaviour.
In practice, after #15610 none of these should be needed in practice.
@mattrobball
Copy link
Copy Markdown
Contributor

bors merge

@github-actions github-actions bot added the ready-to-merge This PR has been sent to bors. label Aug 30, 2024
mathlib-bors bot pushed a commit that referenced this pull request Aug 30, 2024
The "longFile" linter is a syntax linter. It emits a warning on files which are longer than a certain number of lines
(1500 by default). A value of `0` silences the linter entirely.

This PR also modifies the `TextBased` `fileTooLong` linter: now it only lints files that do not contain `set_option linter.style.longFile `, and removes the exceptions that are now covered by the "longFile" linter.

The `TextBased` longFile linter stays (for now), though it is going to be removed soon.



Co-authored-by: Michael Rothgang <rothgami@math.hu-berlin.de>
@mathlib-bors
Copy link
Copy Markdown
Contributor

mathlib-bors bot commented Aug 30, 2024

Build failed (retrying...):

mathlib-bors bot pushed a commit that referenced this pull request Aug 30, 2024
The "longFile" linter is a syntax linter. It emits a warning on files which are longer than a certain number of lines
(1500 by default). A value of `0` silences the linter entirely.

This PR also modifies the `TextBased` `fileTooLong` linter: now it only lints files that do not contain `set_option linter.style.longFile `, and removes the exceptions that are now covered by the "longFile" linter.

The `TextBased` longFile linter stays (for now), though it is going to be removed soon.



Co-authored-by: Michael Rothgang <rothgami@math.hu-berlin.de>
@mathlib-bors
Copy link
Copy Markdown
Contributor

mathlib-bors bot commented Aug 30, 2024

Pull request successfully merged into master.

Build succeeded:

@mathlib-bors mathlib-bors bot changed the title feat: the longFile linter [Merged by Bors] - feat: the longFile linter Aug 30, 2024
@mathlib-bors mathlib-bors bot closed this Aug 30, 2024
@mathlib-bors mathlib-bors bot deleted the adomani/long_file_linter branch August 30, 2024 11:38
grunweg added a commit that referenced this pull request Aug 30, 2024
Not recognising one is more confusing than any other behaviour.
In practice, after #15610 none of these should be needed in practice.
mathlib-bors bot pushed a commit that referenced this pull request Sep 4, 2024
This file has been recording exceptions to the text-based style linters in `lint-style.py` and `Linter/TextBased`. The length of this file is meant to reach zero - and now, it indeed has. 🎉

Some of the linter errors were easy to fix (and just required sustained effort), such as some misformatted author lines or missing module documentation. The main remaining entries were exceptions for the "long file linter", which has been rewritten as a syntax linter (in #15610 and #16299). Exceptions are now tracked as `set_option linter.style.longFile <number>` instead, obviating the need for this file.

This implies the need for a file with transient style exceptions is gone. All of the remaining text-based linters should not be introduced in new code. For *permanent* exceptions, the file `nolints-style.txt` continues to exist; that file must (intentionally) be updated by hand.

[zulip discussion](https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/RFC.3A.20remove.20.60scripts.2Fstyle-exceptions.2Etxt.60)
mathlib-bors bot pushed a commit that referenced this pull request Sep 5, 2024
This file has been recording exceptions to the text-based style linters in `lint-style.py` and `Linter/TextBased`. The length of this file is meant to reach zero - and now, it indeed has. 🎉

Some of the linter errors were easy to fix (and just required sustained effort), such as some misformatted author lines or missing module documentation. The main remaining entries were exceptions for the "long file linter", which has been rewritten as a syntax linter (in #15610 and #16299). Exceptions are now tracked as `set_option linter.style.longFile <number>` instead, obviating the need for this file.

This implies the need for a file with transient style exceptions is gone. All of the remaining text-based linters should not be introduced in new code. For *permanent* exceptions, the file `nolints-style.txt` continues to exist; that file must (intentionally) be updated by hand.

[zulip discussion](https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/RFC.3A.20remove.20.60scripts.2Fstyle-exceptions.2Etxt.60)
bjoernkjoshanssen pushed a commit that referenced this pull request Sep 9, 2024
The "longFile" linter is a syntax linter. It emits a warning on files which are longer than a certain number of lines
(1500 by default). A value of `0` silences the linter entirely.

This PR also modifies the `TextBased` `fileTooLong` linter: now it only lints files that do not contain `set_option linter.style.longFile `, and removes the exceptions that are now covered by the "longFile" linter.

The `TextBased` longFile linter stays (for now), though it is going to be removed soon.



Co-authored-by: Michael Rothgang <rothgami@math.hu-berlin.de>
bjoernkjoshanssen pushed a commit that referenced this pull request Sep 9, 2024
This file has been recording exceptions to the text-based style linters in `lint-style.py` and `Linter/TextBased`. The length of this file is meant to reach zero - and now, it indeed has. 🎉

Some of the linter errors were easy to fix (and just required sustained effort), such as some misformatted author lines or missing module documentation. The main remaining entries were exceptions for the "long file linter", which has been rewritten as a syntax linter (in #15610 and #16299). Exceptions are now tracked as `set_option linter.style.longFile <number>` instead, obviating the need for this file.

This implies the need for a file with transient style exceptions is gone. All of the remaining text-based linters should not be introduced in new code. For *permanent* exceptions, the file `nolints-style.txt` continues to exist; that file must (intentionally) be updated by hand.

[zulip discussion](https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/RFC.3A.20remove.20.60scripts.2Fstyle-exceptions.2Etxt.60)
bjoernkjoshanssen pushed a commit that referenced this pull request Sep 9, 2024
The "longFile" linter is a syntax linter. It emits a warning on files which are longer than a certain number of lines
(1500 by default). A value of `0` silences the linter entirely.

This PR also modifies the `TextBased` `fileTooLong` linter: now it only lints files that do not contain `set_option linter.style.longFile `, and removes the exceptions that are now covered by the "longFile" linter.

The `TextBased` longFile linter stays (for now), though it is going to be removed soon.



Co-authored-by: Michael Rothgang <rothgami@math.hu-berlin.de>
bjoernkjoshanssen pushed a commit that referenced this pull request Sep 9, 2024
This file has been recording exceptions to the text-based style linters in `lint-style.py` and `Linter/TextBased`. The length of this file is meant to reach zero - and now, it indeed has. 🎉

Some of the linter errors were easy to fix (and just required sustained effort), such as some misformatted author lines or missing module documentation. The main remaining entries were exceptions for the "long file linter", which has been rewritten as a syntax linter (in #15610 and #16299). Exceptions are now tracked as `set_option linter.style.longFile <number>` instead, obviating the need for this file.

This implies the need for a file with transient style exceptions is gone. All of the remaining text-based linters should not be introduced in new code. For *permanent* exceptions, the file `nolints-style.txt` continues to exist; that file must (intentionally) be updated by hand.

[zulip discussion](https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/RFC.3A.20remove.20.60scripts.2Fstyle-exceptions.2Etxt.60)
bjoernkjoshanssen pushed a commit that referenced this pull request Sep 12, 2024
The "longFile" linter is a syntax linter. It emits a warning on files which are longer than a certain number of lines
(1500 by default). A value of `0` silences the linter entirely.

This PR also modifies the `TextBased` `fileTooLong` linter: now it only lints files that do not contain `set_option linter.style.longFile `, and removes the exceptions that are now covered by the "longFile" linter.

The `TextBased` longFile linter stays (for now), though it is going to be removed soon.



Co-authored-by: Michael Rothgang <rothgami@math.hu-berlin.de>
bjoernkjoshanssen pushed a commit that referenced this pull request Sep 12, 2024
This file has been recording exceptions to the text-based style linters in `lint-style.py` and `Linter/TextBased`. The length of this file is meant to reach zero - and now, it indeed has. 🎉

Some of the linter errors were easy to fix (and just required sustained effort), such as some misformatted author lines or missing module documentation. The main remaining entries were exceptions for the "long file linter", which has been rewritten as a syntax linter (in #15610 and #16299). Exceptions are now tracked as `set_option linter.style.longFile <number>` instead, obviating the need for this file.

This implies the need for a file with transient style exceptions is gone. All of the remaining text-based linters should not be introduced in new code. For *permanent* exceptions, the file `nolints-style.txt` continues to exist; that file must (intentionally) be updated by hand.

[zulip discussion](https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/RFC.3A.20remove.20.60scripts.2Fstyle-exceptions.2Etxt.60)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer-merge A reviewer has approved the changed; awaiting maintainer approval. ready-to-merge This PR has been sent to bors. t-linter Linter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants