Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[style] Enforce clang-format style. #74

Merged
merged 5 commits into from
Mar 19, 2020

Conversation

turon
Copy link
Contributor

@turon turon commented Mar 18, 2020

  • Adds github hook to confirm style conformance on each push and pull request
  • Locks clang-format tool to version 9
  • Updates code tree to enforce style guide

src/ble/BLEEndPoint.cpp Outdated Show resolved Hide resolved
@rwalker-apple
Copy link
Contributor

I'm personally a fan of the updates, but these are arbitrary choices that we should agree on and stop changing.

Can we agree to stop moving this around soon?

@turon
Copy link
Contributor Author

turon commented Mar 18, 2020

I'm personally a fan of the updates, but these are arbitrary choices that we should agree on and stop changing.

Can we agree to stop moving this around soon?

I agree. We can certainly use this PR to get final agreement.

Note that even running make pretty with the existing style guide currently results in many changes to the sources which we need to apply before enabling the pretty-check github hook.

The style guide in this PR takes the one OpenThread uses with two minor modifications carried over from the old one:

PointerAlignment: Middle  (OT uses Right)
SpaceAfterCStyleCast: true (OT uses false)

@rwalker-apple
Copy link
Contributor

rwalker-apple commented Mar 18, 2020

I'm personally a fan of the updates, but these are arbitrary choices that we should agree on and stop changing.
Can we agree to stop moving this around soon?

I agree. We can certainly use this PR to get final agreement.

Note that even running make pretty with the existing style guide currently results in many changes to the sources which we need to apply before enabling the pretty-check github hook.

The style guide in this PR takes the one OpenThread uses with two minor modifications carried over from the old one:

PointerAlignment: Middle  (OT uses Right)
SpaceAfterCStyleCast: true (OT uses false)

That shouldn't have been the case, unless a lot of code has been introduced since I landed .clang-format and a pretty-fied tree last week. invoking the build in the tree should have automatically updated the code to the standard... I suppose if one made a PR without building the code (or including the reformattting in the commit, or building without clang-format being installed), one could sneak in unformatted code :-(

@turon
Copy link
Contributor Author

turon commented Mar 18, 2020

I'm personally a fan of the updates, but these are arbitrary choices that we should agree on and stop changing.
Can we agree to stop moving this around soon?

I agree. We can certainly use this PR to get final agreement.
Note that even running make pretty with the existing style guide currently results in many changes to the sources which we need to apply before enabling the pretty-check github hook.
The style guide in this PR takes the one OpenThread uses with two minor modifications carried over from the old one:

PointerAlignment: Middle  (OT uses Right)
SpaceAfterCStyleCast: true (OT uses false)

That shouldn't have been the case, unless a lot of code has been introduced since I landed .clang-format and a pretty-fied tree last week.

Perhaps it's related to the version of clang-format being used. OpenThread and the current build system enforce that clang-format-6.0 is always used to guarantee the results are always the same.

Regardless of that, it does appear that sources in master are not all following the .clang-format that is there. Just PointerAlignment for example, some files have Right (AsyncDNSResolver.h), some Middle, and some Left (InitEndPointBasis in EndPointBasis.h).

@rwalker-apple
Copy link
Contributor

I think it's actually that a lot of code has come in on machines without clang-format, then we changed the build system over to nlbuild-autotools, which removed support for auto-reformatting altogether.

I don't see this being an issue going forward if we can get hooks running on this repo soon.

@rwalker-apple
Copy link
Contributor

rwalker-apple commented Mar 18, 2020

OpenThread and the current build system enforce that clang-format-6.0 is always used to guarantee the results are always the same.

Where does clang-format 6.0 come from for MacOS? I'd really like to keep my editor<->format integration intact.

Could we use the latest (since it's arbitrary and easily update-able)?

@jwhui
Copy link
Contributor

jwhui commented Mar 18, 2020

Perhaps it's related to the version of clang-format being used. OpenThread and the current build system enforce that clang-format-6.0 is always used to guarantee the results are always the same.

Where does clang-format 6.0 come from for MacOS? I'd really like to keep my editor<->format integration intact.

OpenThread uses: brew install llvm@6

Could we use the latest (since it's arbitrary and easily update-able)?

I think it's important to pick a version and stick to it - different versions can have different output. I agree, the particular version chosen is arbitrary.

@woody-apple
Copy link
Contributor

woody-apple commented Mar 18, 2020

I think it's important to pick a version and stick to it - different versions can have different output. I agree, the particular version chosen is arbitrary.

Can I propose we use the current latest version, since we're here now? :)

Oh, and please document how to install it :)

@turon
Copy link
Contributor Author

turon commented Mar 18, 2020

I think it's important to pick a version and stick to it - different versions can have different output. I agree, the particular version chosen is arbitrary.

Can I propose we use the current latest version, since we're here now? :)

By "current latest" are you proposing hot-off-the-presses (v11) or "latest available to package managers in common, stable OS distributions"?

My gMac laptop ships with v7. Ubuntu 18.04 I believe defaults to v6.0 after apt install clang-format.

So the benefits of choosing v6.0 would be:

  1. standard availability as packages via apt-get and brew.
  2. toolchain alignment for developers creating CHIP-over-OpenThread accessories.

@turon turon force-pushed the pr/clang-format branch 2 times, most recently from d3956f9 to e2ea981 Compare March 19, 2020 03:29
@turon
Copy link
Contributor Author

turon commented Mar 19, 2020

Ok. To address comments, this PR has been updated in two ways:

  1. .clang-format is unchanged (no actual style changes are introduced)
  2. Version of clang-format required was moved to 9.0.
    This version appears to be the newest readily available via apt-get on common debian / ubuntu distributions.

It appears from the diffs that the only files that needed style updates applied were new QR code, tests, and many of the headers.

@turon turon changed the title [style] Update clang-format style. [style] Enforce clang-format style. Mar 19, 2020
@turon turon requested a review from tpmanley March 19, 2020 04:02
Copy link
Contributor

@woody-apple woody-apple left a comment

Choose a reason for hiding this comment

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

Thanks @turon for dealing with the style change discussion :)

src/system/SystemMutex.h Outdated Show resolved Hide resolved
Copy link
Contributor

@tpmanley tpmanley left a comment

Choose a reason for hiding this comment

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

Just one minor nit

BUILDING.md Outdated Show resolved Hide resolved
BUILDING.md Outdated Show resolved Hide resolved
Copy link
Contributor

@gerickson gerickson left a comment

Choose a reason for hiding this comment

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

Some minor documentation issues to adjust.

@rwalker-apple
Copy link
Contributor

I think it's important to pick a version and stick to it - different versions can have different output. I agree, the particular version chosen is arbitrary.

As tools advance, it'd be nice to avail ourselves of the features and capabilities.

I advocate:

  1. building out continuous integration with containers that carry the required tools set to versions that the tree was developed against (implies building the containers and naming them in version control)
  2. developing with the latest compilers, formatters, etc. available to the team, updating them as we go on dev boxes, and building new containers as we advance

Is this is a weird place for this discussion?

@woody-apple woody-apple merged commit a4e26a0 into project-chip:master Mar 19, 2020
@turon turon mentioned this pull request Mar 19, 2020
mkardous-silabs referenced this pull request in SiliconLabs/watt-sandbox Oct 6, 2022
…ges - MATTER-705

Merge in WMN_TOOLS/matter from feature/pre-commit-hook to silabs

Squashed commit of the following:

commit fdff3509f1e85d78ebb923f89d7f63d644848556
Author: Curtis Rahman <curtis.rahman@silabs.com>
Date:   Thu Sep 8 08:51:39 2022 -0400

    Reverted pre-commit script, renamed run-all script

commit 01c1ed82b6a5dfa11c7c2f186344be5f09b8bfd3
Author: Curtis Rahman <curtis.rahman@silabs.com>
Date:   Wed Sep 7 10:01:27 2022 -0400

    Cleaned up; added comments/descriptions

commit 6febf6cbe5a01bfae11eb7881286ea487ef6450a
Author: Curtis Rahman <curtis.rahman@silabs.com>
Date:   Tue Sep 6 14:22:50 2022 -0400

    Added pre-commit SMG checker, modified existing pre-commit
jmartinez-silabs referenced this pull request in SiliconLabs/matter Oct 13, 2022
…ges - MATTER-705

Merge in WMN_TOOLS/matter from feature/pre-commit-hook to silabs

Squashed commit of the following:

commit fdff3509f1e85d78ebb923f89d7f63d644848556
Author: Curtis Rahman <curtis.rahman@silabs.com>
Date:   Thu Sep 8 08:51:39 2022 -0400

    Reverted pre-commit script, renamed run-all script

commit 01c1ed82b6a5dfa11c7c2f186344be5f09b8bfd3
Author: Curtis Rahman <curtis.rahman@silabs.com>
Date:   Wed Sep 7 10:01:27 2022 -0400

    Cleaned up; added comments/descriptions

commit 6febf6cbe5a01bfae11eb7881286ea487ef6450a
Author: Curtis Rahman <curtis.rahman@silabs.com>
Date:   Tue Sep 6 14:22:50 2022 -0400

    Added pre-commit SMG checker, modified existing pre-commit
nipatel-silabs pushed a commit to nipatel-silabs/connectedhomeip that referenced this pull request Oct 19, 2022
…ded CSA changes - MATTER-705

Merge in WMN_TOOLS/matter from feature/pre-commit-hook to silabs

Squashed commit of the following:

commit fdff3509f1e85d78ebb923f89d7f63d644848556
Author: Curtis Rahman <curtis.rahman@silabs.com>
Date:   Thu Sep 8 08:51:39 2022 -0400

    Reverted pre-commit script, renamed run-all script

commit 01c1ed82b6a5dfa11c7c2f186344be5f09b8bfd3
Author: Curtis Rahman <curtis.rahman@silabs.com>
Date:   Wed Sep 7 10:01:27 2022 -0400

    Cleaned up; added comments/descriptions

commit 6febf6cbe5a01bfae11eb7881286ea487ef6450a
Author: Curtis Rahman <curtis.rahman@silabs.com>
Date:   Tue Sep 6 14:22:50 2022 -0400

    Added pre-commit SMG checker, modified existing pre-commit
mkardous-silabs referenced this pull request in mkardous-silabs/connectedhomeip Oct 24, 2022
…ges - MATTER-705

Merge in WMN_TOOLS/matter from feature/pre-commit-hook to silabs

Squashed commit of the following:

commit fdff3509f1e85d78ebb923f89d7f63d644848556
Author: Curtis Rahman <curtis.rahman@silabs.com>
Date:   Thu Sep 8 08:51:39 2022 -0400

    Reverted pre-commit script, renamed run-all script

commit 01c1ed82b6a5dfa11c7c2f186344be5f09b8bfd3
Author: Curtis Rahman <curtis.rahman@silabs.com>
Date:   Wed Sep 7 10:01:27 2022 -0400

    Cleaned up; added comments/descriptions

commit 6febf6cbe5a01bfae11eb7881286ea487ef6450a
Author: Curtis Rahman <curtis.rahman@silabs.com>
Date:   Tue Sep 6 14:22:50 2022 -0400

    Added pre-commit SMG checker, modified existing pre-commit
mkardous-silabs referenced this pull request in mkardous-silabs/connectedhomeip Nov 2, 2022
…ges - MATTER-705

Merge in WMN_TOOLS/matter from feature/pre-commit-hook to silabs

Squashed commit of the following:

commit fdff3509f1e85d78ebb923f89d7f63d644848556
Author: Curtis Rahman <curtis.rahman@silabs.com>
Date:   Thu Sep 8 08:51:39 2022 -0400

    Reverted pre-commit script, renamed run-all script

commit 01c1ed82b6a5dfa11c7c2f186344be5f09b8bfd3
Author: Curtis Rahman <curtis.rahman@silabs.com>
Date:   Wed Sep 7 10:01:27 2022 -0400

    Cleaned up; added comments/descriptions

commit 6febf6cbe5a01bfae11eb7881286ea487ef6450a
Author: Curtis Rahman <curtis.rahman@silabs.com>
Date:   Tue Sep 6 14:22:50 2022 -0400

    Added pre-commit SMG checker, modified existing pre-commit
rerasool referenced this pull request in SiliconLabs/matter Nov 2, 2022
…ges - MATTER-705

Merge in WMN_TOOLS/matter from feature/pre-commit-hook to silabs

Squashed commit of the following:

commit fdff3509f1e85d78ebb923f89d7f63d644848556
Author: Curtis Rahman <curtis.rahman@silabs.com>
Date:   Thu Sep 8 08:51:39 2022 -0400

    Reverted pre-commit script, renamed run-all script

commit 01c1ed82b6a5dfa11c7c2f186344be5f09b8bfd3
Author: Curtis Rahman <curtis.rahman@silabs.com>
Date:   Wed Sep 7 10:01:27 2022 -0400

    Cleaned up; added comments/descriptions

commit 6febf6cbe5a01bfae11eb7881286ea487ef6450a
Author: Curtis Rahman <curtis.rahman@silabs.com>
Date:   Tue Sep 6 14:22:50 2022 -0400

    Added pre-commit SMG checker, modified existing pre-commit
Thirsrin pushed a commit to Thirsrin/connectedhomeip that referenced this pull request Jul 12, 2023
…ded CSA changes - MATTER-705

Merge in WMN_TOOLS/matter from feature/pre-commit-hook to silabs

Squashed commit of the following:

commit fdff3509f1e85d78ebb923f89d7f63d644848556
Author: Curtis Rahman <curtis.rahman@silabs.com>
Date:   Thu Sep 8 08:51:39 2022 -0400

    Reverted pre-commit script, renamed run-all script

commit 01c1ed82b6a5dfa11c7c2f186344be5f09b8bfd3
Author: Curtis Rahman <curtis.rahman@silabs.com>
Date:   Wed Sep 7 10:01:27 2022 -0400

    Cleaned up; added comments/descriptions

commit 6febf6cbe5a01bfae11eb7881286ea487ef6450a
Author: Curtis Rahman <curtis.rahman@silabs.com>
Date:   Tue Sep 6 14:22:50 2022 -0400

    Added pre-commit SMG checker, modified existing pre-commit
shgutte pushed a commit to shgutte/connectedhomeip that referenced this pull request Oct 5, 2023
…ded CSA changes - MATTER-705

Merge in WMN_TOOLS/matter from feature/pre-commit-hook to silabs

Squashed commit of the following:

commit fdff3509f1e85d78ebb923f89d7f63d644848556
Author: Curtis Rahman <curtis.rahman@silabs.com>
Date:   Thu Sep 8 08:51:39 2022 -0400

    Reverted pre-commit script, renamed run-all script

commit 01c1ed82b6a5dfa11c7c2f186344be5f09b8bfd3
Author: Curtis Rahman <curtis.rahman@silabs.com>
Date:   Wed Sep 7 10:01:27 2022 -0400

    Cleaned up; added comments/descriptions

commit 6febf6cbe5a01bfae11eb7881286ea487ef6450a
Author: Curtis Rahman <curtis.rahman@silabs.com>
Date:   Tue Sep 6 14:22:50 2022 -0400

    Added pre-commit SMG checker, modified existing pre-commit
shgutte pushed a commit to shgutte/connectedhomeip that referenced this pull request Jan 11, 2024
…ded CSA changes - MATTER-705

Merge in WMN_TOOLS/matter from feature/pre-commit-hook to silabs

Squashed commit of the following:

commit fdff3509f1e85d78ebb923f89d7f63d644848556
Author: Curtis Rahman <curtis.rahman@silabs.com>
Date:   Thu Sep 8 08:51:39 2022 -0400

    Reverted pre-commit script, renamed run-all script

commit 01c1ed82b6a5dfa11c7c2f186344be5f09b8bfd3
Author: Curtis Rahman <curtis.rahman@silabs.com>
Date:   Wed Sep 7 10:01:27 2022 -0400

    Cleaned up; added comments/descriptions

commit 6febf6cbe5a01bfae11eb7881286ea487ef6450a
Author: Curtis Rahman <curtis.rahman@silabs.com>
Date:   Tue Sep 6 14:22:50 2022 -0400

    Added pre-commit SMG checker, modified existing pre-commit
suveshpratapa pushed a commit to suveshpratapa/connectedhomeip that referenced this pull request May 22, 2024
…ded CSA changes - MATTER-705

Merge in WMN_TOOLS/matter from feature/pre-commit-hook to silabs

Squashed commit of the following:

commit fdff3509f1e85d78ebb923f89d7f63d644848556
Author: Curtis Rahman <curtis.rahman@silabs.com>
Date:   Thu Sep 8 08:51:39 2022 -0400

    Reverted pre-commit script, renamed run-all script

commit 01c1ed82b6a5dfa11c7c2f186344be5f09b8bfd3
Author: Curtis Rahman <curtis.rahman@silabs.com>
Date:   Wed Sep 7 10:01:27 2022 -0400

    Cleaned up; added comments/descriptions

commit 6febf6cbe5a01bfae11eb7881286ea487ef6450a
Author: Curtis Rahman <curtis.rahman@silabs.com>
Date:   Tue Sep 6 14:22:50 2022 -0400

    Added pre-commit SMG checker, modified existing pre-commit
mykrupp pushed a commit to mykrupp/connectedhomeip that referenced this pull request Jul 18, 2024
…ded CSA changes - MATTER-705

Merge in WMN_TOOLS/matter from feature/pre-commit-hook to silabs

Squashed commit of the following:

commit fdff3509f1e85d78ebb923f89d7f63d644848556
Author: Curtis Rahman <curtis.rahman@silabs.com>
Date:   Thu Sep 8 08:51:39 2022 -0400

    Reverted pre-commit script, renamed run-all script

commit 01c1ed82b6a5dfa11c7c2f186344be5f09b8bfd3
Author: Curtis Rahman <curtis.rahman@silabs.com>
Date:   Wed Sep 7 10:01:27 2022 -0400

    Cleaned up; added comments/descriptions

commit 6febf6cbe5a01bfae11eb7881286ea487ef6450a
Author: Curtis Rahman <curtis.rahman@silabs.com>
Date:   Tue Sep 6 14:22:50 2022 -0400

    Added pre-commit SMG checker, modified existing pre-commit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants