Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
otb
otb
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 273
    • Issues 273
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 8
    • Merge Requests 8
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • CI / CD
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Main Repositories
  • otbotb
  • Merge Requests
  • !273

Merged
Opened Oct 25, 2018 by Victor Poughon@poughovContributor

Update .clang-format

  • Overview 24
  • Commits 4
  • Changes 4

Summary

Consistent code formatting is important! clang-format is the best tool for automatic C++ formatting. We already have a .clang-format configuration file at the root of the project. But it was copy-pasted from ITK and is poorly suited to current OTB code. I think our .clang-format configuration should be such that it produces the minimum diff to current source files and still looks good and familiar to new developers. In this MR I do two things:

  • Simplify and update .clang-format. The most significant changes are:
BreakBeforeBraces: Allman
ColumnLimit:     160

I like Allman style because it's close to the current GNU/Whitesmiths style used in ITK, but is more self-consistent (all brace pairs follow the same indentation logic) and I believe it is much more familiar with new developers and other C++ projects (I have never seen GNU style elsewhere than OTB or ITK...). The 160 column limit seems like a good compromise after a few trial and errors on the whole code base.

The other elements should be trivial (but feel free to bikeshed of course!).

  • Run it on three files as an example:
M       Examples/Registration/ImageRegistration1.cxx
M       Modules/Applications/AppEdge/app/otbEdgeExtraction.cxx
M       Modules/Core/ImageBase/include/otbVectorImage.hxx

If you don't have clang-format installed, you can use this to see if you agree with the proposed configuration.

Should we run clang-format everywhere?

That's up for debate but personally I would not. I would run it on new files and some files where the indentation is very wrong (otbEdgeExtraction.cxx is one example). We can do it gradually.

Copyright

The copyright owner is CNES and has signed the ORFEO ToolBox Contributor License Agreement.


Check before merging:

  • All discussions are resolved
  • At least 2 👍 votes from core developers, no 👎 vote.
  • The feature branch is (reasonably) up-to-date with the base branch
  • Dashboard is green
  • Copyright owner has signed the ORFEO ToolBox Contributor License Agreement
Assignee
Assign to
Reviewer
Request review from
7.0.0
Milestone
7.0.0
Assign milestone
Time tracking
Reference: orfeotoolbox/otb!273
Source branch: update_clang_format

Revert this merge request

This will create a new commit in order to revert the existing changes.

Switch branch
Cancel
A new branch will be created in your fork and a new merge request will be started.

Cherry-pick this merge request

Switch branch
Cancel
A new branch will be created in your fork and a new merge request will be started.