vegastrike / Vega-Strike-Engine-Source

Vega Strike Engine
Other
260 stars 44 forks source link

Adoption of Google code style and lint tool #482

Open royfalk opened 3 years ago

royfalk commented 3 years ago

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.

BenjamenMeyer commented 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++.

royfalk commented 3 years ago

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.

stephengtuggy commented 3 years ago

@royfalk I agree with this proposal 100%.

stephengtuggy commented 3 years ago

"Life is too short" -- yes, indeed

stephengtuggy commented 3 years ago

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

BenjamenMeyer commented 3 years ago

@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.

BenjamenMeyer commented 3 years ago

@royfalk I'm assuming you mean https://google.github.io/styleguide/cppguide.html for the Google C++ Style, correct?

BenjamenMeyer commented 3 years ago

Raw comments: https://gist.github.com/BenjamenMeyer/aebe7fa6a06fa0ae02e22b7ed0bfed12 overview:

stephengtuggy commented 3 years ago

@BenjamenMeyer In response to your comments:

I'm glad that we seem to be in agreement about just about everything else.

Thanks.

BenjamenMeyer commented 3 years ago

@stephengtuggy certainly we should create a repo where we can store some various editor configurations for folks to use.

  1. I suggest another repo so it doesn't cloud all the other repos
  2. It can be organized with a folder for each editor
  3. The settings can be provided for all the different languages we use across all the repos
stephengtuggy commented 3 years ago

@stephengtuggy certainly we should create a repo where we can store some various editor configurations for folks to use.

  1. 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.)

  1. 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.

  1. 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.

stephengtuggy commented 3 years ago

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?