So I’ve forked allwpilib and managed to contribute back to WPILIB this year. It has been a struggle on my end and I do want to thank everyone that has supported me on chief and on the conversations in the PR’s themselves.
I do have a question about editing code. I use simple tools like VS code. I’ve noticed that when I load allwpilib that there are tons of errors, which I’m assuming is because of imports not being loaded and the general way in which the project is constructed. No worries there.
Is there a way to remove these errors by effectively having the import load and not mess anything up. I know I can turn them off, but having autocomplete and autochecking really helps me as I’m sure it does many other people.
No, because it’s just building the generated code, which is not checked into the repository. You’re going to need to build to test locally anyway.
I personally use vscode for WPILib development. For Java, I just use the standard Java development pack of vscode extensions. For C++ work, I generally use cmake (rather than gradle) to build and clangd (and vscode clangd extension) for intellisense.
Also with formatting and linting. Other than silly errors on my part is there a way to automatically handle these and I’m really having difficulties reading the github logs and determining what the formating issues are?
Unfortunately running .\gradlew build didn’t remove the errors. There is like over 4000 of them.
I have the Java extensions and c++ extensions installed.
C++ errors can mostly be solved by running ./gradlew generateVsCode. You’ll also need the wpilib extension installed. That generates the same config that robot projects do, and I’ve found work really well.
It’s very difficult to get all the errors out of Java code. But switching to another ide doesn’t help here either. It’s caused by the gradle integration not knowing about the code generation, so it will do a configuration but not be able to find any of the generated code. Which is where most of the errors come from in my experience.
For C++, we have our own tool called wpiformat (pip install wpiformat to install it); most of the heavy lifting is done by clang-format, so when I’m just formatting when editing I can use the clang-format extension in vscode to reformat and it does most of what’s needed (the other parts wpiformat does are things like reordering header files).
For Java, we use spotless; the gradlew spotlessApply command can be used to auto-format the Java code. Spotless doesn’t catch/clean up PMD errors though; those have to be fixed manually.
In GitHub, we have a comment trigger /format to run both of these to clean up PRs–you can look at the GitHub actions file to see what it does.
You’ll need Python installed for that command to work. If you have it installed, you can probably run it from any terminal? That’s just the command to install it, to run it after it’s installed it’s just wpiformat (assuming it’s on the PATH).