Small Linting of the code base to have a tab of 2#266
Conversation
|
I think having an auto-formatted style would be nice. Details may take quite a bit of figuring out, though. Things that seem clearly right to me:
Some clear suggestions:
However, the following cases seem less clear to me:
And there are many more ideas in Lean here There's also implementation questions:
|
|
This is a very small attempted and I don't understand the script fully nor it is the point, it was more of a oneshoot attempted to get sth better because right now it is painful On the indenting rules
Yes
What is the point then, just do Require rather than Require Import
I believe so, except if it captures all the definitions in the module ?
Most definitely to know what variables are available when, if your section has no variable, then there should not be a section, it is not meant for documenting Indenting all sections is not perfect but it is good enough result to me |
|
Hmm, I'm not sure how appealing a oneshot is. Auto-formatting is obviously desirable because it gives a quick out to all arguments about formatting, but I don't think just converting to the proposed style once would have the same effect, and then what's the point? And just looking at some more changes, what the script did in Streams.v:19 and ZmodDef.v:8 looks questionable to me already in a way separate from the conceptual questions. I'd rather just decide that anything goes on formatting, no nitpicking, but I realize that it may be challenging to get other devs to meaningfully agree to that.
The point is namespacing. For example, there are a bunch of files with module Z, ZArith exports all of them, users write Z.blah without knowing what file it's from. I'm not sure it's ideal, but it's an important enough use case that a namespacing feature was proposed for it in Rocq (and implemented in Lean). (In Z it's with module functors sometimes, which makes the question moot, Zmod follows the same pattern without functors.)
It sure is used this way in btauto and Vector for example. Maybe it shouldn't be, but just changing existing indentation doesn't feel like a strong enough precedent to enforce that. |
Basically, if you have a uniform style, even in the absence of autoformatting, it is much easier to check that new PR respect it and in the meantine the repo is already much better
Possible, I have checked many files but not all, as mentioned it is an experiment hence while it is a draft PR. |
I was tired of non-uniform indentation of the stdlib, so I used Python 3 and Claude to write a very basic linter:
Since it is a bit simplistic, the result is not perfect but it looks much better to me and easier to navigate than it used to be.
Tell me if you are interested of merging. If you are interested I am also joining the script
linter_MSP.py
Note there are a lot of diff dues the extensive use
Sectionin the code base, even when not needed apparently for documentation purpose. For Rocq in general, I believe it would be great to have a linter, e.g. integrated with vsrocq but I don't know how 😅