libvncserver icon indicating copy to clipboard operation
libvncserver copied to clipboard

make use of clang-format or uncrustify

Open bk138 opened this issue 5 years ago • 4 comments

  • [ ] add style spec

  • [ ] format all code

  • [ ] enforce in CI

bk138 avatar Apr 11 '20 10:04 bk138

editorconfig is not really up to the task as

  • most plugins only understand encoding, tabs vs spaces and indent width, nothing about brace style for instance
  • editorconfig linting support for C is abysmal, seems eclint and ec are targeted at JS and the likes

bk138 avatar Feb 05 '21 21:02 bk138

clang-format could step in

  • PRO: can specify a lot of format properties
  • PRO: can check code against spec
  • CON: I could not find a ready-made .clang-format for K&R C (would have to get created). https://zed0.co.uk/clang-format-configurator/ can help. a start:
BreakBeforeBraces: Linux
IndentWidth: '4'
  • there is https://github.com/SavchenkoValeriy/emacs-clang-format-plus for emacs and support in vscode, but what about others?

bk138 avatar Feb 05 '21 21:02 bk138

May I suggest to use uncrustify instead?

The big advantage is that the configuration is much simple, and it has an example following the K&R style by default https://github.com/uncrustify/uncrustify/blob/master/etc/kr-indent.cfg, that file can be easily modified for the bracket and space customization.

Uncrustify works quite well, it's actively maintained and can be easily integrated in many editors, IDE and build systems.

If you give me the GO I can try to submit a PR.

antenore avatar Apr 27 '22 15:04 antenore

Sounds promising, but all kinds of formatting changes are probably held up by open PRs and #394 - after those, this can be tackled, me thinks

bk138 avatar Apr 27 '22 17:04 bk138