# Update Coding Style for ITK

**URL:** <https://discourse.itk.org/t/update-coding-style-for-itk/2055>\
**Category:** Engineering\
**Tags:** style\
**Created:** [July 17, 2019, 2:45pm UTC](https://discourse.itk.org/t/update-coding-style-for-itk/2055 "2019-07-17T14:45:37Z")\
**Posts on this page:** 4\
**Page:** 2

<div class="post-metadata">

**Author:** ![jhlegarreta](https://discourse.itk.org/user_avatar/discourse.itk.org/jhlegarreta/32/476_2.png) [@jhlegarreta](https://discourse.itk.org/u/jhlegarreta)\
**Post date:** [November 4, 2020, 3:40pm UTC](https://discourse.itk.org/t/update-coding-style-for-itk/2055/22 "2020-11-04T15:40:32Z")

</div>

Maybe the immediately preceding comment lines:

```auto
// The following methods are used for updating the data processing pipeline.
//

//-------------------------------------------------------------

```

bear an impact on how the code is formatted/aligned in subsequent blocks?

---

<div class="post-metadata">

**Author:** ![Niels\_Dekker](https://discourse.itk.org/letter_avatar_proxy/v4/letter/n/9d8465/32.png) [@Niels\_Dekker](https://discourse.itk.org/u/Niels_Dekker)\
**Post date:** [November 4, 2020, 3:50pm UTC](https://discourse.itk.org/t/update-coding-style-for-itk/2055/23 "2020-11-04T15:50:49Z")

</div>

> [@dzenanz](#):
>
> That is possible, but this is way more distracting than an extra space.

In this specific case (the extra space before the `::MemberName`), I agree that it isn’t worth using “clang-format off”, but thanks for the suggestion, Hans.

It seems to me that the space was introduced when the original source code had a line break instead. Like it was here ( `DataObject ::Update` in ITK 5.0.1):

> <https://github.com/InsightSoftwareConsortium/ITK/blob/v5.0.1/Modules/Core/Common/src/itkDataObject.cxx#L329>

Interestingly, it appears to me that if you would manually remove those spaces, Clang-Format would not restore them!!! So it does look like a Clang-Format bug to me, indeed.

---

<div class="post-metadata">

**Author:** ![Niels\_Dekker](https://discourse.itk.org/letter_avatar_proxy/v4/letter/n/9d8465/32.png) [@Niels\_Dekker](https://discourse.itk.org/u/Niels_Dekker)\
**Post date:** [November 4, 2020, 5:42pm UTC](https://discourse.itk.org/t/update-coding-style-for-itk/2055/24 "2020-11-04T17:42:59Z")

</div>

And if it is a bug in the Clang-Format version currently used by ITK (version 8.0.1), well… I just tried Clang-Format 11.0, and it still leaves those spaces there, between the class name and the `::MemberName`!

Fortunately, Clang-Format does not appear to restore those spaces, when manually removed:

> <https://github.com/InsightSoftwareConsortium/ITK/pull/2096>

---

<div class="post-metadata">

**Author:** ![Niels\_Dekker](https://discourse.itk.org/letter_avatar_proxy/v4/letter/n/9d8465/32.png) [@Niels\_Dekker](https://discourse.itk.org/u/Niels_Dekker)\
**Post date:** [December 21, 2024, 9:46am UTC](https://discourse.itk.org/t/update-coding-style-for-itk/2055/25 "2024-12-21T09:46:16Z")

</div>

For the record, a related pull request of mine, proposing to disable the alignment of consecutive declarations:

> <https://github.com/InsightSoftwareConsortium/ITK/pull/5096>
>
> No longer enabled the style option of aligning consecutive declarations.
> 
> The …convention of aligning declarations has always bothered some of us, as appeared already during the discussion at https://discourse.itk.org/t/update-coding-style-for-itk/2055 (back in 2019).
> 
> While this style option may be just a matter of taste, it appears to hinder the collaborative development process, as it pollutes \[git\] blame, it makes changes to lines that aren't really changing, complicating code review, etc., as Sean McBride (@seanm) remarked at https://github.com/InsightSoftwareConsortium/ITK/pull/5015#discussion\_r1884709842. Moreover, it also triggers unnecessary git merge conflicts.
> 
> Now that clang-format is recently upgraded for ITK (pull request https://github.com/InsightSoftwareConsortium/ITK/pull/5015 commit 0b1fabd319697a61e10602804f4eb02e455ac6a1), it appears the right moment to reconsider this option.

[Previous page](https://discourse.itk.org/t/update-coding-style-for-itk/2055.md?page=1)
