clang-format: Recently added files #6839

pull MarcoFalke wants to merge 2 commits into bitcoin:master from MarcoFalke:MarcoFalke-2015-clangFormatRecent changing 19 files +218 −244
  1. MarcoFalke commented at 10:28 am on October 16, 2015: member

    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.

  2. MarcoFalke force-pushed on Oct 23, 2015
  3. MarcoFalke commented at 3:09 pm on October 24, 2015: member
    Rebased because #6790 is merged. Also, resolve trivial merge conflict.
  4. MarcoFalke force-pushed on Oct 24, 2015
  5. clang-format: Recently added files 44605105e5
  6. clang-format: Update and run on recent new files
    Set AlignAfterOpenBracket: false
    d2da9395c9
  7. MarcoFalke force-pushed on Oct 24, 2015
  8. dcousens commented at 12:03 pm on October 26, 2015: contributor
    ACK
  9. dcousens commented at 3:27 am on October 27, 2015: contributor
    Why did this not pick up on the lack of indentation here?
  10. MarcoFalke commented at 6:48 am on October 27, 2015: member

    @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)

  11. jgarzik commented at 7:36 pm on October 27, 2015: contributor

    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 :)
  12. dcousens commented at 10:17 pm on October 27, 2015: 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.

  13. jgarzik commented at 10:28 pm on October 27, 2015: contributor
    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.
  14. dcousens commented at 10:29 pm on October 27, 2015: 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.
  15. MarcoFalke commented at 10:08 am on October 28, 2015: member

    next IRC meeting

    In case this means http://www.wolframalpha.com/input/?i=15+utc+thursday #bitcoin-core-dev , I am already scheduled.

  16. dcousens commented at 11:11 am on October 28, 2015: contributor
    @MarcoFalke, @sipa mentioned it was at http://www.wolframalpha.com/input/?i=19+utc+thursday, is it tracked anywhere?
  17. MarcoFalke commented at 11:14 am on October 28, 2015: member
    Ok, then. 19 utc works for me.
  18. laanwj commented at 11:43 am on October 29, 2015: member
    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…
  19. in src/httprpc.cpp: in d2da9395c9
    127@@ -127,7 +128,7 @@ static bool HTTPReq_JSONRPC(HTTPRequest* req, const std::string &)
    128             // Send reply
    129             strReply = JSONRPCReply(result, NullUniValue, jreq.id);
    130 
    131-        // array of requests
    132+            // array of requests
    


    dcousens commented at 12:06 pm on October 29, 2015:
    This alignment is wrong

    MarcoFalke commented at 9:14 pm on October 29, 2015:
    Alignment is correct. Comment is in the wrong line. ;)
  20. dcousens commented at 12:08 pm on October 29, 2015: 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.

  21. laanwj commented at 12:33 pm on October 29, 2015: member
    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.
  22. jgarzik commented at 1:46 pm on October 29, 2015: contributor

    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)
  23. dcousens commented at 8:00 pm on October 29, 2015: 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].
  24. gmaxwell commented at 8:20 pm on October 29, 2015: 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.

  25. MarcoFalke commented at 8:37 pm on October 29, 2015: member

    @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).

  26. laanwj commented at 3:33 am on November 2, 2015: member

    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.

  27. laanwj closed this on Nov 2, 2015

  28. MarcoFalke deleted the branch on Nov 2, 2015
  29. DrahtBot locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-12-22 06:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me