Code formatting question

128 views
Skip to first unread message

achary

unread,
Feb 13, 2024, 8:44:39 AM2/13/24
to KiCad Developers
Hi,
Few days ago I've cloned KiCcad source code and wanted to experiment with small improvements to the PDF plotting in pcbnew.

After setting the development environment (Ubuntu 22.04, clang-format-14) I've discovered even a simple re-formating of an unmodified `pcbnew/dialogs/dialog_plot.cpp` with clang-format, using the project's `_clang-format` spec file leads to a massive diff. Line wraps, indenting, white spaces, alignments for comment etc. Pretty large, to be honest. Much above the small cosmetic preferences mentioned in the code style policy. Tu put it into perspective: git diff --stat for that single file alone reported 185 insertions, 197 deletions.

So my question goes: Is my setup somehow non-conforming (like maybe clang-format-14 is perhaps too old or so), or is it the KiCad code base that in places like that does not adhere to what the `_clang-format` spec actually does define at present? Is this a norm?

regards,
Adam


Jon Evans

unread,
Feb 13, 2024, 9:04:03 AM2/13/24
to dev...@kicad.org
Yes, this is a norm.  KiCad's code style is not 100% representable in clang-format, and we also have a policy of not doing bulk-reformatting of files.

Make sure to configure your editor to not reformat lines that you didn't edit, and you should be OK.
Personally I turn off auto-reformatting, and only use the "manually reformat selected block" function when I need it.

-Jon

--
You received this message because you are subscribed to the Google Groups "KiCad Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to devlist+u...@kicad.org.
To view this discussion on the web visit https://groups.google.com/a/kicad.org/d/msgid/devlist/66a89028-7e38-49c7-be66-52d15ebd16fdn%40kicad.org.

achary

unread,
Feb 13, 2024, 9:07:16 AM2/13/24
to KiCad Developers, j...@craftyjon.com
Got it. Thanks for quick response.
Reply all
Reply to author
Forward
0 new messages