style: make clang-format break long lines #21223

pull vasild wants to merge 1 commits into bitcoin:master from vasild:clang-format-ColumnLimit changing 1 files +1 −1
  1. vasild commented at 1:36 pm on February 18, 2021: member
    Without limit clang-format would join manually broken lines into a single very long line, hindering readability.
  2. style: make clang-format break long lines
    Without limit clang-format would join manually broken lines into a
    single very long line, hindering readability.
    1322dae9da
  3. laanwj added the label Scripts and tools on Feb 18, 2021
  4. jnewbery commented at 3:52 pm on February 18, 2021: member
    @vasild do you have an example of this? The only instances I’ve seen are argument/parameter lists, which should be fixed by #21221.
  5. vasild commented at 5:36 pm on February 18, 2021: member

    Yes (those are not affected by BinPackParameters and BinPackArguments from #21221):

    before (without limit, master):

     0    txNew.vin[0].scriptSig = CScript() << 486604799 << CScriptNum(4) << std::vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));
     1
     2//
     3
     4                    for (std::set<uint256>::iterator it = pto->m_tx_relay->setInventoryTxToSend.begin(); it != pto->m_tx_relay->setInventoryTxToSend.end(); it++) {
     5
     6//
     7
     8        if (m_shift < n || m_shift >= std::numeric_limits<uint64_t>::max() || m_shift < std::numeric_limits<I>::min() || m_shift > std::numeric_limits<I>::max()) throw std::ios_base::failure("differential value overflow");
     9
    10//
    11
    12    std::vector<CBlockIndex*>::const_iterator lower = std::lower_bound(vChain.begin(), vChain.end(), blockparams,
    13        [](CBlockIndex* pBlock, const std::pair<int64_t, int>& blockparams) -> bool { return pBlock->GetBlockTimeMax() < blockparams.first || pBlock->nHeight < blockparams.second; });
    

    after (with limit, this PR):

     0    txNew.vin[0].scriptSig = CScript()
     1                             << 486604799 << CScriptNum(4)
     2                             << std::vector<unsigned char>(
     3                                    (const unsigned char*)pszTimestamp,
     4                                    (const unsigned char*)pszTimestamp + strlen(pszTimestamp));
     5
     6//
     7
     8                    for (std::set<uint256>::iterator it =
     9                             pto->m_tx_relay->setInventoryTxToSend.begin();
    10                         it != pto->m_tx_relay->setInventoryTxToSend.end(); it++) {
    11
    12//
    13
    14        if (m_shift < n || m_shift >= std::numeric_limits<uint64_t>::max() ||
    15            m_shift < std::numeric_limits<I>::min() || m_shift > std::numeric_limits<I>::max())
    16            throw std::ios_base::failure("differential value overflow");
    17
    18//
    19
    20    std::vector<CBlockIndex*>::const_iterator lower = std::lower_bound(
    21        vChain.begin(), vChain.end(), blockparams,
    22        [](CBlockIndex* pBlock, const std::pair<int64_t, int>& blockparams) -> bool {
    23            return pBlock->GetBlockTimeMax() < blockparams.first ||
    24                   pBlock->nHeight < blockparams.second;
    25        });
    

    Maybe I did not pick the best examples, see the output of git grep '.{100,}' '*.cpp' '*.h' (or 150 for the extreme cases).

  6. vasild commented at 9:21 am on February 19, 2021: member

    @jnewbery, I just realized that you asked for an example where clang-format would join a manually broken line and I gave examples where it would break a long line (the opposite).

    Indeed I cannot find such examples, other than functions’ arguments/parameters, which is addressed in #21221.

    Closing this in favor of #21221. Will reopen if I find examples where manually broken lines get joined (with #21221 merged).

  7. vasild closed this on Feb 19, 2021

  8. jnewbery commented at 9:23 am on February 19, 2021: member
    Thanks @vasild!
  9. DrahtBot locked this on Aug 16, 2022

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-11-17 06:12 UTC

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