Skip to content

Enable and apply clang-tidy readability and misc fixes. - #3052

Merged
henryiii merged 3 commits into
pybind:masterfrom
Skylion007:clang-tidy-fixes-readability
Jun 21, 2021
Merged

Enable and apply clang-tidy readability and misc fixes.#3052
henryiii merged 3 commits into
pybind:masterfrom
Skylion007:clang-tidy-fixes-readability

Conversation

@Skylion007

@Skylion007Skylion007 commented Jun 20, 2021

Copy link
Copy Markdown
Collaborator

Description

  • Broke off this PR from the beefer performance once. This just applies some automated fixes to the code base. The main one is a redundant function ptr dereference and forgetting to mark a bunch const methods as such. Enables a bunch of other checks that ensure modern code.

There is one readability improvement with const return types I would like to enable but it causes error sadly that need to be fixed.

Suggested changelog entry:

* Enable and apply checks for more misc, readability, and code modernization improvements to the codebase. Remove redundant function ptr dereference, makes methods const, and uses member-initializers when possible to allow for trivial construction.

#endif
int m7(int x) throw() { return x-7; }
int m8(int x) const throw() { return x-8; }
// NOLINTNEXTLINE(modernize-use-noexcept)

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check discourages the user of throw, but since these are explicilty deprecated tests, I add nolints to prevent them from being changed.

@Skylion007

Copy link
Copy Markdown
CollaboratorAuthor

Ping @rwgk@henryiii

@rwgkrwgk left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Aaron!

Comment threadtests/test_constants_and_functions.cpp Outdated
@rwgk
rwgk requested a review from henryiiiJune 21, 2021 01:34

@henryiiihenryiii left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This all looks very good to me! Thanks! Love seeing that someone is finally filling out the clang-tidy checks, see my comment at #2478 (comment) :)

@henryiii
henryiii merged commit 3b30b0a into pybind:masterJun 21, 2021
@github-actionsgithub-actionsBot added the needs changelog Possibly needs a changelog entry label Jun 21, 2021
@henryiii

Copy link
Copy Markdown
Collaborator

I'm calling this a fix due to the fact that adding const technically is better, as you can only call const methods on a const object.

@henryiiihenryiii removed the needs changelog Possibly needs a changelog entry label Jul 13, 2021
@rwgkrwgk mentioned this pull request Feb 10, 2023
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@Skylion007@henryiii@rwgk