Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
D
dorie
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 31
    • Issues 31
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 9
    • Merge Requests 9
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
  • dorie
  • dorie
  • Issues
  • #180

Closed
Open
Opened Feb 14, 2020 by Santiago Ospina De Los Ríos@sospinarMaintainer

Homogeneize formatting in the C++ code

Description

The c++ code has become a little bit disorderd due that each one of the developers is more fund to a particular coding style. For example, there are several parts of the code that use tabs instead of spaces. Another places the intentantion is 2 spaces instead of 4. The opening of the braces of if-else conditions and for-loops is sometimes done in the same line and sometimes in the next one, and etc. There is no big issue with each one of these inconsistencies, but in the end, they sum up and make our code look somehow disorganized.

Proposal

Use automatic tools to ensure that we follow a consistent format scheme through the code.

Automation

The tool clang-format is available in many systems and can automatically apply specific formatting options. Then, the idea is to agree in a specific format and to store it in the repository with the file .clang-format so that is clear that we follow it.

I personally use plain Mozilla settings with the Mozilla coding style because is the one most similar to the style used in dune. But I am open to any other proposal.

Old code

Once decided upon specific settings, we should use the tool once over the whole repository to make existing code follow the new format.

New code

New code may not follow the format we choose for dorie. Hence, I see two ways to enforce new code to follow these rules:

  • Allow any format in merge request and pass clang-format every now and then.
  • Do not accept merge requests without the appropiated format.

The first one is relatively easy to apply for every one but will clutter our git history. The second is more drastic but could be more easily enforced by providing the right tools for it. For example, by providing a git hook that checks and applies the format settings. In the second case, we would have to update our contributing guide.

EDIT: Correction on the link to the git hook: https://github.com/barisione/clang-format-hooks

Related issues

Edited Jun 19, 2020 by Santiago Ospina De Los Ríos
To upload designs, you'll need to enable LFS and have admin enable hashed storage. More information
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: dorie/dorie#180