Open royfalk opened 3 years ago
I'm all for finding a linter that can enforce our coding style and would love to see that as part of the PR gates too, along with a script that can run it locally so devs can easily check it prior to submitting PRs. Let's resolve #481 and #483 first, then we can find a tool for this that matches those decisions.
That said, I've always had trouble finding one that works well for C and C++.
That's why I keep promoting Google's style. They wrote a linter for it. In theory, we can hack it to check for another style, but life is too short.
@royfalk I agree with this proposal 100%.
"Life is too short" -- yes, indeed
If cpplint
tries to tell us that we should be using auto
in more places, then we can turn that warning off. I don't know that it will though
@stephengtuggy about the only place that auto
is good for is with iterators where you would otherwise have things like x<y>::iterator
or x<y>::const_iterator
- which can be both lengthy, and cause issues with maintenance so it's one place where it becomes very convenient; so there is a place for it, but it's rather limited.
I've known some folks in the past that wanted to use auto for every variable (and argued from a standards perspective that it should be), which is just wrong.
Before saying more I'll read through the Google C++ guides. Right now I'm working on the ISO one. I'm a slow reader so please bear with me.
@royfalk I'm assuming you mean https://google.github.io/styleguide/cppguide.html for the Google C++ Style, correct?
Raw comments: https://gist.github.com/BenjamenMeyer/aebe7fa6a06fa0ae02e22b7ed0bfed12 overview:
@BenjamenMeyer In response to your comments:
.editorconfig
file at the root of each project to enforce this in modern IDEs / text editors. I could do this if you guys want.{}
. I would like to see us both initialize every field at the point of declaration, and write our own constructors explicitly (if necessary). As far as I'm aware, these two approaches would not conflict with each other. What's more, they would allow us to visually confirm that each variable and field is initialized -- something that is extremely important, and rather lacking in the current codebase. Brace initializers ({}
) would give us a consistent syntax to visually verify that everything is initialized.using namespace
statements. They might still have too much potential to cause problems.I'm glad that we seem to be in agreement about just about everything else.
Thanks.
@stephengtuggy certainly we should create a repo where we can store some various editor configurations for folks to use.
@stephengtuggy certainly we should create a repo where we can store some various editor configurations for folks to use.
- I suggest another repo so it doesn't cloud all the other repos
I'm not sure I follow how this would "cloud" the repos. It seems to me like it would be more convenient to put the .editorconfig
file at the root of each repo. (That's what I meant by "at the root of each project." Sorry if that wasn't clear.)
- It can be organized with a folder for each editor
.editorconfig
covers multiple modern editors with one file. I'm pretty sure Sublime Text supports it. I know Visual Studio and Visual Studio Code do.
However, for additional per-IDE settings (such as Visual Studio Code debugging launch configurations), we could certainly put those in per-IDE folders.
- The settings can be provided for all the different languages we use across all the repos
The one .editorconfig
file would also cover most, if not all, the different languages we use.
I'll file a separate issue for the .editorconfig
/ editor settings suggestion. In the meantime, do we have enough consensus around the Google code style to begin using cpplint?
At present we are not aligned to a specific style. The style currently recommended (linux kernel) is C and not C++. I suggest we align with Google C++. I have no specific preference for it, except that it comes with a linter that supposedly identifies issues. Looking a few years into the future, it would be nice to enforce this at the PR level.
I suggest we discuss this here or in a dedicated room at gitter and then vote.