a69289a9 | 04-Jun-2024 |
Patrick Williams <patrick@stwcx.xyz> |
style: cpp: update for clang-format-18
clang-format-18 changed the behavior for lambda formatting, and by adjusting the penalties we think we can get a more consistent formatting with a more natural
style: cpp: update for clang-format-18
clang-format-18 changed the behavior for lambda formatting, and by adjusting the penalties we think we can get a more consistent formatting with a more natural indentation of lambdas. Making these adjustments and will be reformatting all repositories accordingly with clang-18.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: I5e08687e696dd240402a2780158664b7113def0e
show more ...
|
5ae48158 | 28-Sep-2023 |
Alexander Hansen <alexander.hansen@9elements.com> |
clang-tidy: propose a base .clang-tidy
When there is a specific recommendation, it is taken from Cpp Core guidelines [1] or clang-tidy defaults.
- readability-function-size.LineThreshold was chos
clang-tidy: propose a base .clang-tidy
When there is a specific recommendation, it is taken from Cpp Core guidelines [1] or clang-tidy defaults.
- readability-function-size.LineThreshold was chosen to support [ F.3 Keep functions short and simple ]
They recommend 60 lines to flag functions which would not fit on a screen.
- readability-function-size.ParameterThreshold was chosen to support [ F.2: A function should perform a single logical operation ]
They recommend to be suspicious of functions with 7 or more parameters.
- readability-function-cognitive-complexity.Threshold was chosen to support [ F.3: Keep functions short and simple ]
They recommend a cyclomatic complexity of 10 or less. However, cyclomatic complexity is not implemented in clang-tidy, therefore going with the clang-tidy default.
What is the goal of this change?
- making it easier for people to read the code.
- making it easier to perform refactorings without breaking stuff
- making it easier to review changes
Who will be responsible for making the required changes?
- Everyone who is interested. The plan is to atleast get some of the most important pieces into a more readable state. Examples are dbus-sensors, entity-manager, x86-power-control.
- The plan is to enable some of these checks as errors once a repo comes into compliance. After that, contributors will be responsible to ensure their changes meet these checks.
Tradeoffs:
- There might be more code overall, as functions will be smaller. - People might be required to do another (refactoring) iteration on their changes if some of these checks become hard errors. - Refactoring code to meet these checks might introduce bugs.
[1] https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines
Change-Id: Icbdd55d2f672037a57d8ed08d52b20427e9e1e4f Signed-off-by: Alexander Hansen <alexander.hansen@9elements.com>
show more ...
|
e1a27147 | 19-Oct-2023 |
Patrick Williams <patrick@stwcx.xyz> |
clang-format: refresh settings from clang-17 docs
With later versions of clang, a number of settings we had previously are either deprecated or replaced from a simple boolean to an enumeration value
clang-format: refresh settings from clang-17 docs
With later versions of clang, a number of settings we had previously are either deprecated or replaced from a simple boolean to an enumeration value. Update them to reflect the intent.
Update a few settings based on new options available in clang-17 to minimize formatting churn.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: Ia0d5d3f9a48c60ab0f233166cfa481758d10491f
show more ...
|
dc24b2ec | 10-May-2023 |
Patrick Williams <patrick@stwcx.xyz> |
clang-format: add IndentExternBlock setting
Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: I7cb11f19333775f3912f98a3a8bfd6559601fabc |
d1d05ee6 | 12-May-2023 |
Andrew Jeffery <andrew@aj.id.au> |
style: Add clang-format file for C code
This is based on libmctp and obmc-console's .clang-format with updates for clang-16.
Change-Id: I56535f1289fec55c3ce2b8c98ccc7e4904a62b75 Signed-off-by: Andr
style: Add clang-format file for C code
This is based on libmctp and obmc-console's .clang-format with updates for clang-16.
Change-Id: I56535f1289fec55c3ce2b8c98ccc7e4904a62b75 Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
show more ...
|
231ad0cd | 13-Apr-2023 |
Patrick Williams <patrick@stwcx.xyz> |
clang-format: add clang-format-16 options
Some options are added and/or changed in clang-format-16. Attempt to define ones that cause the most churn in the codebase if left unset.
Signed-off-by: P
clang-format: add clang-format-16 options
Some options are added and/or changed in clang-format-16. Attempt to define ones that cause the most churn in the codebase if left unset.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: I80217b5f8efeb4d5eeae3071149e6cfbe72f8046
show more ...
|
22319395 | 07-Feb-2023 |
Andrew Jeffery <andrew@aj.id.au> |
clang-format: Specify lambda formatting
Do so in accordance with existing community practice:
1. https://github.com/openbmc/bmcweb/blob/5b5574ace856c7f787528ab8f5e5352a90f2a6cb/.clang-format#L84 2.
clang-format: Specify lambda formatting
Do so in accordance with existing community practice:
1. https://github.com/openbmc/bmcweb/blob/5b5574ace856c7f787528ab8f5e5352a90f2a6cb/.clang-format#L84 2. https://github.com/openbmc/dbus-sensors/blob/6747eba5e06ce8f7b407193410aa7d04eb5b833c/.clang-format#L53
Change-Id: Ic89424f510578622c1ac5627e28b0293e4da7e07 Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
show more ...
|
06136285 | 29-Sep-2022 |
Patrick Williams <patrick@stwcx.xyz> |
clang-format: use options for C++20 requires
clang-15 adds options to format C++20 Concepts `requires` statements. Set them now so we have consistency in any code which starts to use C++20 Concepts
clang-format: use options for C++20 requires
clang-15 adds options to format C++20 Concepts `requires` statements. Set them now so we have consistency in any code which starts to use C++20 Concepts.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: If75f8ebdf46855423a4ffb1dba598e9c61d9a462
show more ...
|
c742fe86 | 29-Sep-2022 |
Patrick Williams <patrick@stwcx.xyz> |
clang-format: tweak alignment settings
We already use 'PointerAlignment: Left'. clang-13 and clang-14 added 'QualifierAlignment' and 'ReferenceAlignment' options. Set those to left similarly.
Qua
clang-format: tweak alignment settings
We already use 'PointerAlignment: Left'. clang-13 and clang-14 added 'QualifierAlignment' and 'ReferenceAlignment' options. Set those to left similarly.
QualifierAlignment sets: * `const int` - right * `int const` - wrong
ReferenceAlignment sets: * `int& foo` - right * `int &foo` - wrong
Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: I17f2457b10682513ed5d824ce8c506dee833a744
show more ...
|
ba68be6a | 29-Sep-2022 |
Patrick Williams <patrick@stwcx.xyz> |
clang-format: tweak penalty values
clang-format-15 seems to end up with a slightly different whitespace break than clang-format-14 did. Tweak the PenaltyBreakAssignment to favor not breaking as oft
clang-format: tweak penalty values
clang-format-15 seems to end up with a slightly different whitespace break than clang-format-14 did. Tweak the PenaltyBreakAssignment to favor not breaking as often, which allows the two to be more consistent.
This is already applied to sdbusplus as I49826e2011bce317b6b82dc985ddd35fa6eef2cb.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: I455cc4bf29097e3d0462a7c1b667d21e382af104
show more ...
|
3547af1f | 26-Aug-2022 |
Patrick Williams <patrick@stwcx.xyz> |
clang-format: allow some empty blocks on single line
Enable AllowShortBLocksOnASingleLine and AllowShortFunctionsOnASingleLine as 'Empty' instead of 'false'. This allows the code to be slightly mor
clang-format: allow some empty blocks on single line
Enable AllowShortBLocksOnASingleLine and AllowShortFunctionsOnASingleLine as 'Empty' instead of 'false'. This allows the code to be slightly more compact in the already readable case of an empty block. In sdbusplus this yields some minor simplifications such as:
``` - compose(bus_t&, const char*) - {} + compose(bus_t&, const char*) {} ```
Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: I39423dc80c057674e16d23389f4e4d88aae80e6f
show more ...
|
ac5d5445 | 16-May-2022 |
Brad Bishop <bradleyb@fuzziesquirrel.com> |
clang-format: cpp: remove empty lines
This seems to be how most people code anyway (no metrics gathered just my anecdotal observation), and with the setting in the other state, whether or not extra
clang-format: cpp: remove empty lines
This seems to be how most people code anyway (no metrics gathered just my anecdotal observation), and with the setting in the other state, whether or not extra lines are allowed appears ambiguous and can result in comments and questions in review. Take the hard-line to make it explicit to avoid comments during review.
Change-Id: Icb75b3e11b5209a19c3ef6e92cf42d84a060af98 Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
show more ...
|
2f52b0a3 | 10-Nov-2021 |
Patrick Williams <patrick@stwcx.xyz> |
clang-format: force unix newlines
In order to help avoid dos-style newlines from being introduced to the codebase, force the clang-format style to use unix-style newlines.
`DeriveLineEnding: fals
clang-format: force unix newlines
In order to help avoid dos-style newlines from being introduced to the codebase, force the clang-format style to use unix-style newlines.
`DeriveLineEnding: false`: - This disables automatic newline style detection by clang-format.
`UseCRLF: false`: - Since detection is disabled, this enforces unix-style (LF).
Also, add a remark in the cpp-style document to codify the expectation that unix-style newlines are used.
Tested: Apply changes to sdbusplus, run 'unix2dos' on a source file, and confirm file is reverted to unix-style with 'clang-format'.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: Ie8f0cd956a3c52cd14891c06a0b61507f5829aaf
show more ...
|
a021c6c0 | 16-Sep-2021 |
Manojkiran Eda <manojkiran.eda@gmail.com> |
eslint config/style file for json validation
Check-in the global eslint json validator configuration file. This configuration enables eslint plugins that supports comments in json files during valid
eslint config/style file for json validation
Check-in the global eslint json validator configuration file. This configuration enables eslint plugins that supports comments in json files during validation in CI.
This can be improved in future, for javascript files & json formatting.
Signed-off-by: Manojkiran Eda <manojkiran.eda@gmail.com> Change-Id: I22c265695a28cba150cb10691c0914152356d401
show more ...
|
9e5bbd0c | 05-Aug-2021 |
Andrew Jeffery <andrew@aj.id.au> |
style/cpp: Don't break long string literals
Exploiting string literal concatonation makes it harder to grep for log messages in the source.
Change-Id: If5777adc5824560c4f6694399a1c11067c7b3999 Sign
style/cpp: Don't break long string literals
Exploiting string literal concatonation makes it harder to grep for log messages in the source.
Change-Id: If5777adc5824560c4f6694399a1c11067c7b3999 Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
show more ...
|
36d6f56f | 28-May-2020 |
Patrick Williams <patrick@stwcx.xyz> |
clang-format: set standard to 'Latest'
Per the LLVM code, the string 'Cpp11' is actually an alias to 'Latest', while 'C++11' is C++11. We want to tend towards using the latest C++ standard anyhow,
clang-format: set standard to 'Latest'
Per the LLVM code, the string 'Cpp11' is actually an alias to 'Latest', while 'C++11' is C++11. We want to tend towards using the latest C++ standard anyhow, so set clang-format to 'Latest'. This is both what we are already asking clang-format to do and clearer for people looking at the file.
https://github.com/llvm/llvm-project/commit/e5032567903de19962333c4bf7d2edceaf4f9824#diff-b49a097415dff2837d9626d422c58ba8R82
Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: I430c58633b0d285cc617d013f8a1d6b3832aeba5
show more ...
|
b6de1960 | 21-May-2020 |
Patrick Williams <patrick@stwcx.xyz> |
clang-format: add AfterCaseLabel option from clang-10
Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: Id230561133d147c223cee3fb033978373b72f6c6 |
9a71ea19 | 29-Oct-2019 |
Zane Shelley <zshelle@us.ibm.com> |
Updated cpp/.clang-format to v8 spec
Included missing fields and updated values based on the version 8 specification.
Signed-off-by: Zane Shelley <zshelle@us.ibm.com> Change-Id: I0ca66d83467e39a93b
Updated cpp/.clang-format to v8 spec
Included missing fields and updated values based on the version 8 specification.
Signed-off-by: Zane Shelley <zshelle@us.ibm.com> Change-Id: I0ca66d83467e39a93bbde45af6fa724313e85809
show more ...
|
0dcc430a | 24-Sep-2018 |
Patrick Venture <venture@google.com> |
add .clang-format exemplars
Adds .clang-format for cpp and javascript
Change-Id: I8a7ed63be54a3f44ef448cf603ee2a8643436afd Signed-off-by: Patrick Venture <venture@google.com> |