8000 RFC: Coding style check/enforcement · Issue #4223 · micropython/micropython · GitHub
[go: up one dir, main page]

Skip to content
RFC: Coding style check/enforcement #4223
Closed
@stinos

Description

@stinos

It's nice to be consistent and using a tool like clang-format is by far the easiest way to achieve that. Below are clang-format settings which match the envisioned style for MicroPython pretty well (I left include file sorting out because almost no files have them sorted alphabetically now, though I think it would be good nonetheless).

Based on some brief previous discussion there is interest to somehow incorporate that in MicroPython. This could be as simple as including a .clang-format file in the repository. People can then choose to just format new/modified pieces of code or whole files. More involved solutions woule be things like pre-commit hooks or adding a check for PRs. Ideas/comments?

The major problem with introducing this: the codebase right now isn't formatted 100% consistently. This is to be expected of course, but with an automated tool it's annoying. It's not bad but I randomly went over a couple of files and there's only a small percentage which are completely ok. The differences are mainly with respect to line length/breaking arguments and indentation of PP directives. There are again different ways to deal with this: leave as-is (drawback is running the tool on a whole file nearly always creates a diff), format everything at once, format chunks or files incrementally as they are modified, ...

---
BasedOnStyle: LLVM
Language: Cpp
AlignAfterOpenBracket: DontAlign
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
ColumnLimit: 100
ContinuationIndentWidth: 4
IndentCaseLabels: true
IndentWidth: 4
PointerAlignment: Right
SortIncludes: false
TabWidth: 4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0