Skip to content

ENH: Update coding style guidelines#170

Merged
dzenanz merged 8 commits intoInsightSoftwareConsortium:masterfrom
jhlegarreta:UpdateCodingStyleGuidelines
Dec 14, 2021
Merged

ENH: Update coding style guidelines#170
dzenanz merged 8 commits intoInsightSoftwareConsortium:masterfrom
jhlegarreta:UpdateCodingStyleGuidelines

Conversation

@jhlegarreta
Copy link
Copy Markdown
Member

@jhlegarreta jhlegarreta commented Dec 10, 2021

  • DOC: Remove uses of itk::ImageTraits
  • DOC: Make test ending messages consistent
  • DOC: Override destructor and prefer = default for trivial bodies
  • DOC: Match the current function deletion practice in ITK
  • DOC: Prefer using pre-increment over post-increment
  • DOC: Update the ITK code style to current automatically enforced
  • DOC: Document brace and brace list initialization preference
  • DOC: Update itk::N4BiasFieldCorrectionImageFilter::Sharpen definition

Fixes #133.

Remove uses of `itk::ImageTraits`.

Cros-referencing related ITK commits:
InsightSoftwareConsortium/ITK@dc9630a
InsightSoftwareConsortium/ITK@d775b4d

Update the template parameters of `itk::Image` to the current
implementation:
https://github.com/InsightSoftwareConsortium/ITK/tree/217c0d408487d454cf9b0f945ab5575c2322ee7a
Make test ending messages consistent.
Mark class destructor with `override` and replace its default body with
= default; to match current practice in ITK.

Cross-referencing related ITK commits, e.g.:
InsightSoftwareConsortium/ITK@7ef2496
InsightSoftwareConsortium/ITK@9b74640
Match the current function deletion practice in ITK: add the
`ITK_DISALLOW_COPY_AND_ASSIGN` macro to the class' public section.

Cross-referencing the ITK commits:
InsightSoftwareConsortium/ITK@939cee4
InsightSoftwareConsortium/ITK@b0f183b
Prefer using pre-increment over post-increment `for` loop local
counters to match current ITK practice.
@github-actions github-actions bot added area:Appendices Issues affecting the Appendices part language:LaTeX Changes to LaTeX code type:BookStyle Changes to book style files type:Enhancement Improvement of existing methods or implementation labels Dec 10, 2021
@jhlegarreta
Copy link
Copy Markdown
Member Author

A few notes:

Pinging @N-Dekker on this.

But maybe I missed them. Anyone is welcome to add a commit to fix any.

  • If other oversights are found, anyone is welcome to rebase interactively, ammend and push force.

  • Maybe better tools to keep this in sync with the ITK code base changes should be found, and ways to enforce these in the ITK code base. e.g. @hjmjohnson would clang be able to reformat these files cleanly next time?

Cross-referencing:
InsightSoftwareConsortium/ITK#1195

@N-Dekker
Copy link
Copy Markdown
Contributor

Have not found examples liable to be changed to use trailing return types: https://github.com/InsightSoftwareConsortium/ITKSoftwareGuide/pull/162/files

But maybe I missed them. Anyone is welcome to add a commit to fix any.

The SharpenImage example code could be restyled, using trailing return types:

typename
N4BiasFieldCorrectionImageFilter< TInputImage, TMaskImage, TOutputImage >::RealImagePointer
N4BiasFieldCorrectionImageFilter< TInputImage, TMaskImage, TOutputImage >
::SharpenImage( const RealImageType *unsharpenedImage ) const

@jhlegarreta
Copy link
Copy Markdown
Member Author

jhlegarreta commented Dec 11, 2021

The SharpenImage example code could be restyled, using trailing return types:

Thanks. The definition was outdated. I updated it in ec15294. The new one does not have any return type.

Copy link
Copy Markdown
Member

@dzenanz dzenanz left a comment

Choose a reason for hiding this comment

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

Great effort Jon!

@jhlegarreta jhlegarreta force-pushed the UpdateCodingStyleGuidelines branch from ec15294 to b53226d Compare December 13, 2021 21:43
Update the ITK code style to the current, automatically enforced style:
- Introduce the use of the `clang-format` style enforcing tool.
- Modify the related passages.
- Update the verbatim code snippets to reflect the new style.

Cross-referencing the ITK change commits:
https://github.com/InsightSoftwareConsortium/ITK/pull/1191/commits
@jhlegarreta jhlegarreta force-pushed the UpdateCodingStyleGuidelines branch from b53226d to 5f6ae91 Compare December 13, 2021 22:21
Copy link
Copy Markdown
Member

@dzenanz dzenanz left a comment

Choose a reason for hiding this comment

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

Sorry to nitpick again :(

Document brace and brace list initialization preference in member
declaration.

Change the examples that were using any other initialization type
accordingly, using mock class and method names if necessary.
@jhlegarreta jhlegarreta force-pushed the UpdateCodingStyleGuidelines branch from 5f6ae91 to 55ea845 Compare December 13, 2021 23:20
Copy link
Copy Markdown
Member

@dzenanz dzenanz left a comment

Choose a reason for hiding this comment

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

Awesome!

Copy link
Copy Markdown
Contributor

@N-Dekker N-Dekker left a comment

Choose a reason for hiding this comment

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

👍

@dzenanz dzenanz merged commit 781010a into InsightSoftwareConsortium:master Dec 14, 2021
@jhlegarreta jhlegarreta deleted the UpdateCodingStyleGuidelines branch December 14, 2021 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:Appendices Issues affecting the Appendices part language:LaTeX Changes to LaTeX code type:BookStyle Changes to book style files type:Enhancement Improvement of existing methods or implementation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update the Code Style Guide section to match the .clang-format tool decisions

3 participants