-
Notifications
You must be signed in to change notification settings - Fork 7
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
Style & whitespace #83
Style & whitespace #83
Conversation
This is a good idea IMHO! However to get closer to project norms for C code you might want to pull in the latest attempt at a clang-format by @trws from flux-framework/flux-core#4694. |
Oh yeah... we should finish fixing that up. It was pretty close IIRC. |
Should I hold off on this PR while we iron out clang-format or should I move ahead with it? |
TBH, I'd probably say go for it, we can always rerun later. Might be good to configure these commits to be ignored by blame commits in git though so they don't hide everything. Example here if you haven't done the .git-blame-ignore-revs thing before: https://akrabat.com/ignoring-revisions-with-git-blame/ |
66c25b7
to
cec3e37
Compare
OK done, although I noticed clang-format left some unreasonably long lines unchanged... |
Lines over 88 chars should only persist unbroken if there's nothing to break. Is there somewhere it's doing something strange? |
cec3e37
to
edbc43f
Compare
No actually, upon further investigation there was one line that it left over 88 characters for some reason, and there were a few that I thought were 89 characters but were actually 88. All the changes are reasonable enough I think. |
We normally break lines in C at 80 characters. |
We had that discussion before, probably in slack since it doesn't seem to be in the issue/PR history, when we were setting up black as the python formatter and I was working on clang-format the last time. The number of spurious linebreaks drops significantly if there's a little bit of slop space above 80, for black they chose 88, and at the time IIRC we had general agreement to adjust that, so that's what I had put in the clang-format as well. |
edbc43f
to
d536037
Compare
Ah OK sorry! That's fine then I guess. |
Whoops I had just adjusted it down to 80, will fix... |
|| !(hlist = hostlist_from_array (nodelist))) { | ||
|| !(hlist = | ||
hostlist_from_array (nodelist))) { |
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.
Compound conditional line breaks are usually done like the original in our code base. Is that fixable?
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.
Ok that's odd... I would have expected it to keep it the original way here because it's not an argument. There are other spots in this file where they got indented because there's nesting, but I'm not sure why this is happening. Will check it out.
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.
This particular example probably no longer applies now that I brought the limit back to 88
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.
@jameshcorbett, what version of clang-format are you using? With these settings, and clang-format
16, I get this:
if (flux_kvs_lookup_get_unpack (fut,
"{s:{s:o}}",
"execution",
"nodelist",
&nodelist)
< 0
|| !(hlist = hostlist_from_array (nodelist))) {
flux_log_error (h,
PLUGIN_NAME
": "
"Error fetching R from shell-counting future");
prolog_status = 1;
goto cleanup;
}
(note that this is without the wrapper I'm working on in the other PR to fix the dangling < 0
in the middle)
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.
12.0.1
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.
I'm updating it now...
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.
Good idea, technically 11/12 support everything in the config, but I think it was 13 that fixed a bunch of alignment issues when some of the options we use are combined.
Do whichever you prefer for now @jameshcorbett, we'll hopefully hash out the last few bits in the PR over on core and probably have an update, but I don't see that as a reason not to use the tooling in here in the meantime. I want to avoid stalling you on that since we've been working on it, on and off, since 2015... hmm... what's the emoji for simultaneous laughing and crying? 😭 🤣 ? |
2ed8736
to
7ef7056
Compare
Ok, sorry for changes, I brought the line length back to 88 since that's my preference. |
7ef7056
to
65e6b11
Compare
One more push to update the clang-format used to version 16. |
Oddly, this seems to still have the alignment issue, I would have thought that would take care of it. it looks like the issue is from treating the _pack and _unpack functions as whitespace-sensitive. It's adjusting the indent of following |
65e6b11
to
d9584ae
Compare
Problem: coral2_dws.py has some lines that are too long. Run the 'black' formatter over it.
Problem: C style should be standardized. Some developers rely on an automatic tool to do their formatting. Add a .clang-format file for clang.
Problem: the style in all of this repo's C files is messy and irregular. Run clang-format over every file.
Problem: commits that make style changes will confuse git blame. Add a file for telling git to ignore those commits when assigning blame. git can be configured to always use this file with 'git config blame.ignoreRevsFile .git-blame-ignore-revs'
d9584ae
to
e1ddced
Compare
That got the indents, it looks like it didn't show up in core because it's really, really rare to have pack/unpack in single if chains for whatever reason there. I'm good here pending others's approval. |
For Python that is fine, but I do find myself lengthening shortening variable names to play the "how to get black to format this more reasonably" with 88 character limit. I wonder if we'll want to shorten it for flux-core at least. We have codified 80 character limit in RFC 7. |
Sure, not planning to argue that here so much as point out that's what's in the file James was pointed to. Could always do what the black, and spack actually, folks did and do our own test to determine where the dog-leg is between reducing extra lines and keeping things tight. |
@garlick if you'll stamp this with your approval I'll go ahead and set MWP |
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.
OK I don't think these rules are ready for flux-core where there's a lot of established code purposefully formatted a certain way, but it does fix quite a lot here so LGTM.
Thanks! |
No description provided.