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

Remove trailing whitespace from all files in lib #5268

Merged

Conversation

james-d-mitchell
Copy link
Contributor

This PR removes all tabs and trailing whitespace in all files in the lib directory, as mentioned in #5260. I could also add a CI job that would fail if tabs or trailing whitespace are introduced again in the future, but since I expect this will be controversial enough without that too, I haven't done it.

Text for release notes

None

@james-d-mitchell james-d-mitchell marked this pull request as draft December 14, 2022 10:18
@james-d-mitchell james-d-mitchell marked this pull request as ready for review December 14, 2022 10:55
Copy link
Member

@wilfwilson wilfwilson left a comment

Choose a reason for hiding this comment

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

I'm happy with this kind of change.

@fingolfin suggested in #5260 (review) that:

we could set up a .git-blame-ignore-revs file to ignore the changes in that commit for purposes of git blame and similar

I don't know how this would work, but I presume @fingolfin does, and I presume it can only be done after these commits are merged. I'm just noting it here so the idea doesn't get lost.

@james-d-mitchell
Copy link
Contributor Author

Thanks @wilfwilson I think I've added the appropriate file also.

@james-d-mitchell
Copy link
Contributor Author

Ooops included an extra commit, I didn't mean to, will remove now

@wilfwilson
Copy link
Member

@james-d-mitchell I don't think that .git-blame-ignore-revs will work as-is. Firstly, it references an old commit, but most importantly, I think it needs to be done after the PR is merged: the hashes of the commits in this PR will definitely change when it is rebase-and-merged onto master.

In addition, there are two relevant commits to ignore (the tab one and the trailing whitespace one), not just one, so ultimately two commits will need to be listed.

@james-d-mitchell
Copy link
Contributor Author

Aha, thanks @wilfwilson, that makes sense, I'll drop that commit.

@fingolfin fingolfin added topic: library release notes: not needed PRs introducing changes that are wholly irrelevant to the release notes labels Dec 14, 2022
Copy link
Member

@fingolfin fingolfin left a comment

Choose a reason for hiding this comment

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

Thank you!

In principle I am all for this. The main objection I am aware of are:

  • this could cause conflicts for in-flight PRs: OK, we have ~65 open PRs; but the majority of those are dormant and old and either are trivial to rebase or need major rebasing work anyway, and I don't intend to be held hostage by old unfinished work (which includes many of my own PRs -- I will gladly rebase them through whitespace changes, and also am happy to assist others with theirs)
  • there may also be unsubmitted big changes -- well, if you don't show your work via a PR, we can't take it into account
  • it "break git blame etc." -- but that's what we have .git-blame-ignore-revs for (to be added in a future PR)

So all in all I don't mind. In fact I have ulterior motives, I want to make some code formatting tweaks to the kernel code ;-).

But the tab changes are delicate. I would recommend to separate the "remove trailing whitespaces" changes and the tab changes into separate PRs. Then we can merge the "remove trailing tabs" PR rather quickly, but the tabs require careful vetting (and perhaps need to be done in multiple steps, i.e., convert just a couple files carefully and submit that, and deal with others later). Also, trailing spaces could also be removed in src and in doc/*/*.xml and possibly in grp.

Oh, and actually: please make sure to at least also apply all these changes to hpcgap/lib, to avoid divergence between those files and their counterparts in lib

lib/algfld.gi Outdated
q:= Quotient( R, g, factor );
Add( factors, factor );
g:= q;
q:= Quotient( R, g, factor );
Copy link
Member

Choose a reason for hiding this comment

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

Indentation is broken here. I would advise against trying to remove tabs with a fully automated script: in many places our tabs are 8 wide, but I think there are exceptions with 4 wide tabs (and who knows what else)

@ChrisJefferson
Copy link
Contributor

I like this, but I wonder if we should try to do it in a series of smaller pieces? (I wouldn't mind a little more churn)

I think a "strip whitespace off the end of lines" commit can be merged with basically no questions, whereas as @fingolfin says I've noticed in the past tabs require some manual work, as some are 4 space indents and some are 8 space indents.

@james-d-mitchell
Copy link
Contributor Author

I've dropped the remove tabs from this PR, I can see the rationale for replacing tabs more carefully (although the idea that anything could make the formatting of the library worse is amusing).

@james-d-mitchell
Copy link
Contributor Author

About HPC gap, I just did the same transformation on hpcgap/lib and there were only changes to 24 files, whereas in this PR there were changes to 421, so I think the idea that lib and hpcgap/lib are somehow in sync might need to be reexamined.

@james-d-mitchell james-d-mitchell changed the title Remove tabs trailing whitespace from all files in lib Remove trailing whitespace from all files in lib Dec 14, 2022
@mtorpey
Copy link
Contributor

mtorpey commented Dec 14, 2022

I'd appreciate the trailing whitespace being removed! As @fingolfin says, it hits git blame, but that can be got around with the ignore file.

I also agree that tabs are more delicate – a fully automated removal might make things worse.

@fingolfin
Copy link
Member

@james-d-mitchell hpcgap/lib mirrors a small subset of files from lib with patches applied. Those files need to be "in sync". The hundreds of additional files in lib simply are identical between GAP and HPC-GAP. So nothing to reexamine there :-)

@james-d-mitchell
Copy link
Contributor Author

@fingolfin aha, I see, ok, I'll add that to the PR now.

@fingolfin fingolfin merged commit ce30db3 into gap-system:master Dec 14, 2022
@james-d-mitchell james-d-mitchell deleted the remove-tabs-trailing-ws branch December 14, 2022 17:09
@fingolfin
Copy link
Member

I will remove a couple more trailing whitespace with a direct push momentarily, and add .git-blame-ignore-revs

@james-d-mitchell
Copy link
Contributor Author

Thanks @fingolfin !

@fingolfin
Copy link
Member

Done. And of course I idiotically broken the tests based on manual examples, so I'll fix that ASAP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release notes: not needed PRs introducing changes that are wholly irrelevant to the release notes topic: library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants