Skip to content

Conversation

@maflcko
Copy link
Member

@maflcko maflcko commented Oct 16, 2015

Formatting recently added files likely does not create many conflicts.

Reviewers may use

  • contrib/devtools/clang-format.py ~/clang-format-3.6.2 src/bench src/http* src/qt/bantablemodel.* src/test/addrman_tests.cpp src/test/dbwrapper_tests.cpp src/test/streams_tests.cpp src/zmq/zmq*
  • or just any version of clang-format 3.6. to verify the diff.

This will clean up the new files from #6733, #6103, #5677, #6650 and #6315.


UPDATE:
I have appended a commit to set AlignAfterOpenBracket to false.

@maflcko
Copy link
Member Author

maflcko commented Oct 24, 2015

Rebased because #6790 is merged. Also, resolve trivial merge conflict.

@maflcko maflcko force-pushed the MarcoFalke-2015-clangFormatRecent branch from 27100d4 to f5f57bf Compare October 24, 2015 15:16
@maflcko maflcko force-pushed the MarcoFalke-2015-clangFormatRecent branch from f5f57bf to d2da939 Compare October 24, 2015 15:28
@dcousens
Copy link
Contributor

ACK

@dcousens
Copy link
Contributor

Why did this not pick up on the lack of indentation here?

@maflcko
Copy link
Member Author

maflcko commented Oct 27, 2015

@dcousens I did only clang-format recently added files to prevent creating merge conflicts and see if any updates are necessary with regard to the clang-format workflow.

You can find the set of files in the OP (hidden in the command line)

@jgarzik
Copy link
Contributor

jgarzik commented Oct 27, 2015

Please discuss and schedule this at the next IRC meeting.

Similar to the libconsensus reformats, there is no point creating a pull request for cosmetic, mechanical changes unless they are ready to be merged soon after creation.

If cosmetic changes will not be merged immediately, this creates a constant-rebase hell for the pull request in question.

Given that it takes mere minutes to re-create this from scratch, it is better to

  • Schedule cosmetic changes in a time window
  • Create pull request when that time window opens
  • Harass maintainers to merge ASAP :)

@dcousens
Copy link
Contributor

@MarcoFalke is there perhaps a way we can put this under test? Making maintainers conform to a style that would otherwise be a breaking test is a great way to avoid discussion/bike shedding over this.

Perhaps something to bring up at the IRC meeting.

@jgarzik
Copy link
Contributor

jgarzik commented Oct 27, 2015

The general plan was to format files, then have an automated check for that set of files, e.g. either (a) auto-reformat those files for future changes or (b) reject a push unless those files comply with the format.

@dcousens
Copy link
Contributor

Option (b) is less prone to dangerous errors sneaking if a bug exists in the formatter, so I've typically opted for that personally.

@maflcko
Copy link
Member Author

maflcko commented Oct 28, 2015

@dcousens
Copy link
Contributor

@maflcko
Copy link
Member Author

maflcko commented Oct 28, 2015

Ok, then. 19 utc works for me.

@laanwj
Copy link
Member

laanwj commented Oct 29, 2015

Tend towards NACK. My big gripe with changes like this is that it makes it much harder to find when actual code changes happened. Every time you try to use e.g. git-blame you end up with tons of "code beautification" to wade through. It makes git less useful as a maintainer. That these are recently added files makes it less of an issue, that's true...

Copy link
Contributor

Choose a reason for hiding this comment

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

This alignment is wrong

Copy link
Member Author

Choose a reason for hiding this comment

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

Alignment is correct. Comment is in the wrong line. ;)

@dcousens
Copy link
Contributor

@laanwj I think the sooner we can just put this under test, the bike-shedding and nitting will just disappear because the tests will spell it out, and it just becomes a non-issue.
Yes, it will make a few commits that may appear trivial [initially], but, in the interest of the long term readability of the code base, I think it would be worth it. YMMV.

If there is any discussion of this at the IRC meeting, it should probably be directly in response to #6839 (comment), not necessarily the PR itself.

@laanwj
Copy link
Member

laanwj commented Oct 29, 2015

I'm just not a big fan of this. We can also make bikeshedding and nitting go away by discouraging it in other ways, which don't involve mangling the entire codebase.

@jgarzik
Copy link
Contributor

jgarzik commented Oct 29, 2015

To be clear, my position is

  • NAK, close pull request
  • Schedule time window
  • Re-create pull request from scratch when time window opens (concept ACK)

@dcousens
Copy link
Contributor

FTR, there is still a lack of consensus over how to structure these changes going forward [in terms of moving away from the current ad hoc nature].

@gmaxwell
Copy link
Contributor

A couple thoughts:

When changing existing code we must not just trust clang-format repeatability to verify that no bugs were introduced, we should test via checks for identical object files. This will take a little effort because some macros insert line numbers, and these will need to be bypassed.

To use clang format normativeily we must end up specifying a particular version that all contributors must use, as clang format changes its behavior. This is irritating, and disruptive to contributing. It could be made much better with good automation like cfield's depbuilder work, to help people get a particular version of clang-format; though due to the flowing API breakage in C++ code, I don't know how long an older version will be maintainable.

Another concern is which style to specify. The most common behavior in Bitcoin Core today has stylistic elements which have been objectively shown to increase software defect rate and confuse review-- e.g. unbraced multi-line IFs. We should not make any disruptive reformating changes unless we are quite confident that the style is what we want to live with.

We could avoid disrupting the workflow of existing patches by only reformatting (and then requiring it) on new files and substantial rewrites. I think that would be a better path.

To the extent that there is hope to address bikeshedding via this, I beg anyone thinking that to give up that thought. Bikeshedding is not a result of any particular coding style or consistency, bikeshedding arises from a lack of perspective which can only be addressed by experience, community norms, and having more important things to worry about.

Stylistic consistency has actual benefits; it aids newcomers in their contributions because it is easier for them to make sure their work is okay on styleistic grounds; though this may be offset by having to install some particular version of clang-format before they can get started. It eases review because the uniformity creates better expectations; but reformating makes looking at the history harder, which harms review. Good style choices (as opposed to merely consistent) have, at times, been shown to lower defect rates in software-- but there is not a universal opinion on what choices are good. So there are benefits to be had, but they must be carefully managed with other risks and costs. And the magnitude of the potential benefits, I think, are enough to say that this subject should have a very low priority in general.

@maflcko
Copy link
Member Author

maflcko commented Oct 29, 2015

@gmaxwell To use clang format normativeily we must end up specifying a particular version that all contributors must use

https://github.com/bitcoin/bitcoin/blob/master/contrib/devtools/clang-format.py#L15

@gmaxwell We could avoid disrupting the workflow of existing patches by only reformatting (and then requiring it) on new files and substantial rewrites. I think that would be a better path.

I agree, but I am not sure about the requirement. Imagine changes to critical code, refactor-only or just a new feature whose PR aims to produce a simple diff that is easy to read and to verify. Often clean diffs and proper formatting are orthogonal.

Entirely new files are the exception but they should ideally be formatted before submitting the PR (at least prior to merging).

@laanwj
Copy link
Member

laanwj commented Nov 2, 2015

I think, are enough to say that this subject should have a very low priority in general.

Yes, and with that, I'm going to close this.

@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants