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

Check for changes to formatter output resulting from clangd bump #680

Closed
per1234 opened this issue Dec 13, 2021 · 0 comments · Fixed by arduino/tooling-project-assets#250
Assignees
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

Comments

@per1234
Copy link
Contributor

per1234 commented Dec 13, 2021

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)

we use clang-format-8 and believe me we have learned they are not all the same so you really have to pick one and stick to it. that said, if y'all want to pick one clang format version i'm happy to change our CI to match

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

  1. Start the Arduino IDE.
  2. Open a sketch that does not contain a .clang-format file, on a machine that does not have a custom global .clang-format file.
  3. Select Tools > Auto Format from the Arduino IDE menus.

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:

"clangd": {
"version": "14.0.0"
},

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:

@per1234 per1234 added type: enhancement Proposed improvement topic: infrastructure Related to project infrastructure topic: language server Related to the Arduino Language Server labels Dec 13, 2021
@per1234 per1234 self-assigned this Dec 13, 2021
@per1234 per1234 added the conclusion: resolved Issue was resolved label Jul 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant