-
Notifications
You must be signed in to change notification settings - Fork 613
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
Add enforcement of wpilib's java style when using vscode. #6669
Add enforcement of wpilib's java style when using vscode. #6669
Conversation
This will automatically format modified lines (according to wpilib's java style) when a java file is saved in vscode. This requires including .vscode/settings.json in the repo which appears to be a fairly widely accepted practice in large projects (including vscode itself and mozilla). For details, see: https://stackoverflow.com/questions/32964920/should-i-commit-the-vscode-folder-to-source-control
Theres actually a long standing VS Code issue about workspace local settings Until that happens, I wouldn't want something like this, as I run a very different settings.json. |
Can your user-specific settings be put in your user settings instead of the folder settings? If not, would adding them to a shared setttings.json actually break things for others? |
I'll have to double check. But probably would be opposed to format on save either way. I've seen too many times where it doesn't always get things right, and then you have to remember how to save without formatting. |
I could live without the format-on-save being in the folder settings. I could move that to my user settings. I am primarily interested in getting the wpilib specific style in the folder settings. Would that work for you? |
One of the biggest things I worry about is when you're working on the C++ side, a lot of random file associations get added, in the It's really easy to add this locally, I'm not fully convinced adding it to the repo is worth it. We could document how to get settings like this working. |
One other concern is that I don't think this will fully cover all the formatting that CI enforces. I find I trigger spotless a lot more often then wpiformat. |
Does my most recent commit address that worry?
I'm not yet convinced that it can't be made to "just work". 😄 |
Fwiw, I started looking into this because of a formatting issue that wpiformat didn't catch. At least for that particular issue, my testing indicates that this would have fixed it. And even if it doesn't catch all issues, it would still be a step in the right direction. |
No, because that doesn't work on Windows. |
That's because wpiformat is mainly for formatting C++ files, and spotless is for formatting Java files. The only formatting wpiformat does to Java files is remove trailing whitespace and blank lines after open curly braces. The issue you had in that PR would have been fixed by spotless's javadoc comment reflowing via |
Works for me on Windows. Did you try it? Note that the glob will match the headers installed by the wpilib installer at |
It needs to match the MSVC headers too, which are all over the place. |
Good to know but not at all clear to new contributors.
...or, if this PR was accepted, it wouldn't be an issue to begin with. 😄 I do appreciate the tip though. Thanks! |
Does my latest commit match them? |
I don't like this change, if people want to configure auto formatting for their editor they can it's not the responsibility of the project. I'll also repeat C++ file association concerns other people have brought up, this could be annoying to see popping up occasionally in prs. |
Have vscode recommend an extension that will, by default, automatically merge settings from settings.default.json into settings.json. Move the relevant settings into settings.default.json. The files.associations setting has been removed because it is no longer relevant to this PR. Have git ignore settings.json but not ignore settings.default.json.
Ok. My latest commit takes a (hopefully) less controversial/intrusive approach. It makes the settings optional but recommended. It does so by putting the relevant settings in Does that address everyone's concerns? |
I also don't like this change, even with the "recommended settings" plugin. Adding this to the codebase implies that it is actually recommended, and I don't recommend formatting on save.
Instead, could we document formatting requirements/tools better? (Both on the user's device, and via the PR format command) |
This will automatically format modified lines (according to wpilib's java style) when a java file is saved in vscode.
This requires including .vscode/settings.json in the repo which appears to be a fairly widely accepted practice in large projects (including vscode itself and mozilla). For details, see: https://stackoverflow.com/questions/32964920/should-i-commit-the-vscode-folder-to-source-control