Check for changes to formatter output resulting from clangd bump #680
Labels
conclusion: resolved
Issue was resolved
topic: infrastructure
Related to project infrastructure
topic: language server
Related to the Arduino Language Server
type: enhancement
Proposed improvement
Describe the current behavior
The Arduino IDE's Tools > Auto Format functionality is provided by ClangFormat.
Arduino IDE contains an embedded ClangFormat configuration that defines the standard Arduino code formatting style, which is used by default when the user formats their code via Tools > Auto Format.:
https://github.com/arduino/arduino-ide/blob/main/arduino-ide-extension/src/node/clang-formatter.ts
This configuration was developed using ClangFormat 11.0.1, but will be used with whatever version of clangd is installed with the Arduino IDE:
https://github.com/arduino/arduino-ide/blob/main/arduino-ide-extension/package.json#L165
We received valued advice from someone with experience using ClangFormat on Arduino code:
arduino/Arduino#11543 (comment)
ClangFormat has a strict approach to formatting. While the formatting style is very configurable, often it is not possible to configure it to leave the code as-is. This means that newly introduced configurations are likely to have a default setting that imposes formatting of some form, with no guarantees that it will align with the official Arduino code style.
To reproduce
.clang-format
file, on a machine that does not have a custom global.clang-format
file.The sketch file currently open in the editor will be formatted according to the ClangFormat configuration embedded in Arduino IDE.
Describe the request
Set up a formal system to check for formatter output changes at every update to the Arduino IDE 2.x clangd dependency:
arduino-ide/arduino-ide-extension/package.json
Lines 164 to 166 in 5499c25
My proposal is that we produce a file containing test data code that will exercise the significant C++ formatting capabilities of ClangFormat then check for a diff after formatting that code with the new version. If there is no diff, then we have a reasonable certainty that the bump will not necessitate any adjustments to the ClangFormat configuration.
Ideally this would be set up to run automatically as part of the CI/CD system of the appropriate repository. Since the clangd version in use is currently defined in this repository, it seems to be the best place.
Additional context
Related:
The text was updated successfully, but these errors were encountered: