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
Use autoformatters to enforce style of all programming languages in cosmos. #3947
Comments
@arnavb I think this is a must needed enhancement. For C and C++ I can guarantee that clang-format works great. It has direct plugins available for text editors, which makes formatting on save/on the go easier. We can make use of a clang-format configuration file for applying sane defaults for users. The file can be directly referenced using Code StylesMy suggestion would be to go with the google style guide. Available for multiple languages, and most importantly has tools which could enforce the same while coding. Known PluginsVim : https://github.com/rhysd/vim-clang-format |
@yedhink Cool! Would you be willing to add configuration for this to Travis CI? Make sure to reference this issue when doing so. |
@yedhink Also, what style do you propose we use for pure C? |
@arnavb Yes. I would love to add the configurations. Is there someplace I can message you directly, so as to clear doubts on the same? Like i had mentioned, going with the google style guide can work well for c++. But for pure C, i would strongly recommend following the Gnome style guide for pure c. Pure c, does have many accepted style guides like the Linux Kernel Style, GNU Style etc. The gnome style guide tries to bring about a comparative form of style guide, where the user can choose from the given best choices. For example: To nurture out a proper c-style guide, we can choose the best choices from the gnome style guide and make clang format follow the same. |
@yedhink I don't think that's a great idea, because the GNU style also comes with an unusual brace pattern. In my opinion, 2 spaces is too less for a language like C as well. I think sticking with the kernel style guide, except with 4 spaces, is best. The reason they use 8 char tabs is to discourage people from indenting more than 3 levels. However, since this is a repository for algorithms, such a situation is unavoidable. You can always contact me by email (visible on my profile page). |
@arnavb Sure. We can manage that. I would love to make a PR for the same. But currently it seems that the Build is failing. Should i work on that first and then move to this? or is someone already working on the build? |
This is a(n):
Details:
Currently, our repository contains various style guides in guides/coding_style. Enforcing that contributors follow this style guide is very difficult for contributors and maintainers alike. As such, I propose that we add autoformatters for all programming languages being used in cosmos and enforce their usage through Travis CI. This way, fixing code style is a simple matter of running one command. In addition, I believe that formatters that don't allow configuration are better, so that there are no arguments over what style is better; you simply follow whatever the autoformatter does.
I will use this as a tracking issue for all the autoformatters available. I will probably add some of them, but others can also do so (while referencing this issue).
Autoformatters:
If anyone would like to discuss more code formatters or other options, please feel free to reply to this issue. If anyone wants to add one in particular to Travis CI, then reference this issue and go for it!
The text was updated successfully, but these errors were encountered: