Skip to content
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

Add lint check for C++ changes #12407

Open
seanbudd opened this issue May 13, 2021 · 8 comments
Open

Add lint check for C++ changes #12407

seanbudd opened this issue May 13, 2021 · 8 comments
Labels
audience/nvda-dev PR or issue is relevant to NVDA / Add-on developers p4 https://github.com/nvaccess/nvda/blob/master/projectDocs/issues/triage.md#priority triaged Has been triaged, issue is waiting for implementation.

Comments

@seanbudd
Copy link
Member

Is your feature request related to a problem? Please describe.

Unlinted C++ code exists on the master branch of NVDA, and PRs to master can contain unlinted C++ code. Currently reviewers must manually check if a PR introduces unlinted C++ code.

Describe the solution you'd like

It would be nice to have a lint check similar to our flake8 python check that checks if a PR introduces unlinted C++ code.

It would also be good to lint our existing C++ code base, but this may run into problems as discussed on #12261

Potential tool to use: cpplint

Describe alternatives you've considered

Manual checking and linting, other tools

@seanbudd seanbudd added the audience/nvda-dev PR or issue is relevant to NVDA / Add-on developers label May 13, 2021
@feerrenrut
Copy link
Contributor

I've been involved in the integration of cppcheck before, a static analysis tool.
We also have the option to run: /analyze via MSVC. see "Compiling NVDAHelper with Debugging Options" in the readme.

However, I agree it would be best to have something that runs as part of the build. Ideally it would address not only style, but also detect common errors via static analysis.

Some overviews of common tools:

@josephsl
Copy link
Collaborator

josephsl commented May 13, 2021 via email

@feerrenrut
Copy link
Contributor

Building nvda with scons source nvdaHelperDebugFlags=analyze will produce warnings for the code.
Many of these are highlighted in code when using Visual Studio (if paths and options are set reasonably well)

There are options to log these to an xml file. This file could then be used to add pragma directives to ignore the pre-existing warnings. Then we can set the build to run analyze for all PR builds and fail them if there are any new warnings. The in code pragmas will highlight the warnings for developers to watch out for problems / fix as we go.

@feerrenrut
Copy link
Contributor

We might also want to consider what ruleset is used:
https://docs.microsoft.com/en-us/cpp/code-quality/using-the-cpp-core-guidelines-checkers?view=msvc-170

@LeonarddeR
Copy link
Collaborator

It would also be good to lint our existing C++ code base, but this may run into problems as discussed on #12261

I don't think #12261 is relevant to C++ code. With Python, auto formatting can theoretically result into parse errors. With C++, badly linted stuff simply won't build.
It makes sense to find out what are the defaults of VS Code as well. I assume Visual Studio and VS Code have similar defaults.

@feerrenrut
Copy link
Contributor

badly linted stuff simply won't build.

There may be confusion of terms here. Formatting of C++ is one thing, and as you say low risk, should be easy to introduce (however git blame needs the ignored revision fix). Most C++ linters / checkers warn about more serious "correctness" issues. These warnings may highlight a bug, but fixing them isn't always straightforward, and may introduce other bugs, or snowball into a very large and hard to verify change.

Careful and incremental is my advice. I'd be happy for a reformat to be done automatically however, with something like ClangFormat

@seanbudd seanbudd added p4 https://github.com/nvaccess/nvda/blob/master/projectDocs/issues/triage.md#priority triaged Has been triaged, issue is waiting for implementation. labels Jul 7, 2022
@LeonarddeR
Copy link
Collaborator

I forgot about this one. @seanbudd any plans to address it in the near future?

@seanbudd
Copy link
Member Author

@LeonarddeR - it's on our roadmap on a very low priority and scheduled for late next year, so I wouldn't bet on it, but we'd like to tackle it eventually

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
audience/nvda-dev PR or issue is relevant to NVDA / Add-on developers p4 https://github.com/nvaccess/nvda/blob/master/projectDocs/issues/triage.md#priority triaged Has been triaged, issue is waiting for implementation.
Projects
None yet
Development

No branches or pull requests

4 participants