Menu ▾ ▴

#545 attach-return-type conflicts with max-code-length

closed-fixed
None
2023-01-29
2021-01-08
No

Take this C++ code:

nonstd::optional<QueueLoader::CategorizedDownloads>
    QueueLoader::categorize_downloads(
        const std::vector<Download>& downloads,
        bool also_remove_finished)
{
}

It's formatted weirdly just to make it clear what changes AStyle performs.

After running astyle --attach-return-type --max-code-length=80 reproducer.cpp:

nonstd::optional<QueueLoader::CategorizedDownloads> QueueLoader::categorize_downloads(
    const std::vector<Download>& downloads,
    bool also_remove_finished)
{
}

Note that the first line is now longer than 80 characters — longer than the limit we imposed.

After running the same command again:

nonstd::optional<QueueLoader::CategorizedDownloads>
QueueLoader::categorize_downloads(
    const std::vector<Download>& downloads,
    bool also_remove_finished)
{
}

AStyle corrected the line length, good! But if I run AStyle again, it applies attach-return-type once more and the code is back to its previous form. Running AStyle again and again makes the code switch back and forth between the two versions.

Discussion

  • André Simon

    André Simon - 2022-11-25
    • status: open --> open-accepted
    • assigned_to: André Simon
     
  • André Simon

    André Simon - 2023-01-24
    • status: open-accepted --> closed-fixed
     
  • André Simon

    André Simon - 2023-01-24

    This issue was resolved in the latest 3.2 beta release.

     
  • Alexander Batischev

    Thanks!

     

Log in to post a comment.