-
Notifications
You must be signed in to change notification settings - Fork 98
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 nodiscard and example usage in Actor #1360
Conversation
Signed-off-by: Ryan Friedman <[email protected]>
Signed-off-by: Ryan Friedman <[email protected]>
#else | ||
#error "HELLO" | ||
#define SDFORMAT_WARN_UNUSED | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
per #1358 (comment), we don't need to define this macro, we can use [[nodiscard]]
directly in the header file. apologies for the back-and-forth
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No worries. While I think I could do this to the model, this is perhaps a great candidate for using clang-tidy's automated refactoring capabilities. Although I don't have experience with it, perhaps someone at Gazebo does?
I don't really expect to have time to do it to the entire repo, at least manually. It's not quick work because I don't think you can find-replace or regex it.
In the PR, you can see I tried using the modernize-use-nodiscard
builtin, but I could not get it working correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't configured clang-tidy
before. I think it would be worth adding [[nodiscard]]
to this class by hand and then comparing to what clang-tidy generates
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I installed clang-tidy
on a debian machine and built Ionic up to sdformat15
in a colcon workspace and then was able to apply the [[nodiscard]]
attribute automatically using the following command after sourcing the workspace:
clang-tidy --fix -checks=-*,modernize-use-nodiscard src/sdformat/include/sdf/*.hh -- $(pkg-config --cflags sdformat15)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fantastic. I'll go ahead and do the work manually and post a diff.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
untested changes to all header files in 1d96a58
I'm pretty sure it pushes some lines over 80 characters, which would need to be fixed
I'm going to close because I don't have time to see this project through. Anyone else is welcome to continue! |
🎉 New feature
Relates to #1358
Summary
In theory, clang-tidy should be able to automatically apply this across the whole repo, but clang-tidy doesn't seem to work with this repo. If anyone knows how to use it, that would be much preferable because automated code refactors are much less error-prone and quicker than me doing it manually.
Test it
Checklist
codecheck
passed (See contributing)Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining
Signed-off-by
messages.