-
Notifications
You must be signed in to change notification settings - Fork 228
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
Automatic code linting for pull requests #901
Comments
I know that many editors and IDEs allow custom style guides (and auto-complete automation). I'd expect linters to support similar customisation. I've not looked though - but I'd be very surprised if they didn't. |
I am having a look at clang-format which I found has options for this https://clang.llvm.org/docs/ClangFormatStyleOptions.html
Still trying to find some configuration that fits best to the existing code ... I just noticed that right now some code is aligned to 80 characters and some is not. So either all code would need to get aligned to that or to a bigger limit - to be defined... |
Got quite far with the configuration for clang-format which I put on this fork now: clang-format --style=llvm -dump-config documentation for that is available here: https://releases.llvm.org/10.0.0/tools/clang/docs/ClangFormatStyleOptions.html I have also setup this github action: https://github.com/marketplace/actions/clang-format-lint if you want to try different settings, you can just put the configuration in your repo folder locally and run something like clang-format -i server.cpp ; git diff ; git checkout server.cpp |
Sounds great! So it also automatically does the changes? |
here's an updated configuration which now only contains the options that differ from the LLVM base style:
Yes, it just adds another commit: https://github.com/passing/jamulus/commits/master I am not sure if it is possible to use this on pull requests coming from a fork. |
@ann0see looks like it works on a PR: https://github.com/passing/jamulus/pull/2
It should usually never break the code as it basically just wraps things around. Of course there could be a bug in the linter itself, but that I assume to be very unlikely. |
... and I think this is very important to avoid edit wars, both manual and automatical. As said elsewhere, I'm really happy that there is a consistent coding style so I'm absolutely in favor of keeping one. On the other hand, it was really hard for me (in one of my PRs) to spot all places where I've gotten the spacing wrong. Seems like other people are having similar issues (#945 (comment)). I would welcome both changes to make local linting just work (some |
So now there's 2 things to be decided: 1st: is the code style produced by clang-format with the proposed configuration (#901 (comment)) ok in general? 2nd: how should the integration look like. I see lots options:
|
align on arrow operator doesn't seem to be possible
the
sorting of include blocks could be adjusted, e.g. there's
that kind of alignment also doesn't seem to be possible |
Thanks for your further analysis! The diff is rather big, but I would still say that someone should scan through all of it. I'm volunteering to do that and would highlight anything controversial so that anyone can chime in. Maybe there are still some optimizations possible. However, this will be some effort and it would also do that if there's consensus to move this forward. I really like what @passing has done so far and think it is important to tackle this issue rather sooner than later as it will hopefully make our work (and the work by contributors) easier. Regarding the questions above:
@jamulussoftware/maindevelopers What do you think? If there's consensus I'd ask @passing to open a PR where we could go through the initial diff. |
Personally, I think non-blocking is better: the simple reason is that sometimes it's more urgent to get a fix than it is to worry about someone having got spacing wrong. That can be fixed later, so long as the linter is still highlighting it. That does mean aggressively fixing lint issues when highlighted to keep the number very low and increase visibility. It also means issues where the linter cannot be trained to accept "correct style" can be commented as "// lint accepted" or something (ideally a directive to the linter to shut up about specific issues on specific lines via a config would be nice). |
Good point. I assume Github owners might still have the power to override, even in blocking mode. If this is the case, I'd still prefer this. If this isn't possible, then we should probably go for non-blocking. @passing Is this something you could test on your fork?
I agree. |
thanks for the feedback! Then I'll take the following tasks with me
I do not have much experience with make and how to deal with tool dependencies there, it would be good if somebody could help out with
|
I have created the PR for checking all changes implied by the clang-format style: #1127 regarding
that could be done with Disabling Formatting on a Piece of Code: int formatted_code;
// clang-format off
void unformatted_code ;
// clang-format on
void formatted_code_again; |
... though I'd pickilly prefer I'll take a look at the change tomorrow. |
Is this done now? Can we close? |
No, this is a huge undertaking and the PR (#1127) is still in flight. I've now linked it to this issue. We will also have to check if the issue is done or if there are still follow-ups to do (possibly new issues, but we'll need tracking for that). The PR handles the format definition and the initial linting. I think any automatisms are not in the scope of that PR yet and will have to be done afterwards. |
With this issue having been auto-closed despite several tasks still to be done, I think it's best to keep it closed and start with a fresh outline what to do. I've done that here: #1702 |
I talked to corrados via mail and thought of automating some more steps in GitHub.
Reviewing a PR can be automated to some extent via a linter which enforces code style.
Unfortunately, I couldn't find a style guide (+ linter) which would fit to the Jamulus style, especially considering the two spaces between arguments in e.g. function calls/if statements:
if ( a )
seems to be uncommon.Does anybody know a linter which supports custom styles and a GitHub action?
The text was updated successfully, but these errors were encountered: