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

Linting for rviz_rendering #17

Merged
merged 5 commits into from
Sep 2, 2017
Merged

Linting for rviz_rendering #17

merged 5 commits into from
Sep 2, 2017

Conversation

Martin-Idel
Copy link
Contributor

@Martin-Idel Martin-Idel commented Aug 31, 2017

This pull request adds liniting to rviz_rendering and fixes all linting issues to have a clean build.

Closes #1

@Martin-Idel Martin-Idel changed the title Feature/linting Linting for rviz_rendering #1 Aug 31, 2017
@Martin-Idel Martin-Idel changed the title Linting for rviz_rendering #1 Linting for rviz_rendering Aug 31, 2017
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of the Open Source Robotics Foundation, Inc. nor the names of its
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this is the right change because Willow Garage's name should still not be used (nothing has changed in that respect).

The updated 3-clause bsd template uses a more general statement here:

Neither the name of the copyright holder nor the names of its contributors may be used to endorse
-- https://choosealicense.com/licenses/bsd-3-clause/

We should probably update to that instead.

Also there is a pull request I am looking into that should allow us to use the block comments rather than // comments, letting us have smaller diffs:

ament/ament_lint#82

So if you want to merge this, for now I would suggest disabling the copyright linter and wait for that pr to get merged before trying to enable it again. Otherwise I am going to wait to merge this pr until we have that sorted out because I really don't want to have a diff like this in all the files we port.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree - it would be much better to have ament_lint copyright check be able to work with block comments. If this happens soon, I'll be inclined to wait for it. Otherwise, I can also disable it if you want.
Regarding the change, I wasn't sure (that's why it's in a separate commit) - it just seemed logical because the file has no connection whatsoever to Willow Garage.

The template I chose was the one recognized by ament_lint - see here: https://github.com/ament/ament_lint/tree/master/ament_copyright/ament_copyright/template

  • the weird part I only saw now is that the license template is equivalent to the bsd-3-clause you mention, while the license header isn't - and ament_copyright checks for the header.


void OgreLogging::useLogFile(const std::string & filename)
{
preference_ = FileLogging;
filename_ = filename;
filename_ = filename.c_str();
Copy link
Member

Choose a reason for hiding this comment

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

This is not safe, as the lifetime of filename is not guaranteed to be longer than filename_, that's why I just disable the linter on this one until that is resolved some other way. You can either leave the NOLINT or fix it another way.

@@ -124,6 +127,7 @@ void OgreLogging::configureLogging()
if (preference_ == StandardOut) {
ll.min_lml = Ogre::LML_NORMAL;
}
delete log_manager;
Copy link
Member

Choose a reason for hiding this comment

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

I don't believe this to be correct either. I think the logger will be held by Ogre::LogManager::getSingletonPtr()afterwards.

Copy link
Contributor Author

@Martin-Idel Martin-Idel Sep 1, 2017

Choose a reason for hiding this comment

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

Looking into it, you're absolutely right. I find this quite weird style, though: I would've expected there to be some kind of static factory method instead - if I new an object, this should mean I'm also responsible to delete it. I guess we have to disable cppcheck for this newcall then. I'll look into it.

@@ -60,7 +61,7 @@ get_resource_directory()
void
set_resource_directory(const std::string & resource_directory)
{
__resource_directory = resource_directory;
__resource_directory = resource_directory.c_str();
Copy link
Member

Choose a reason for hiding this comment

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

This is not safe either, for the reasons described above.

@@ -72,7 +73,7 @@ get_ogre_plugin_directory()
void
set_ogre_plugin_directory(const std::string & ogre_plugin_directory)
{
__ogre_plugin_directory = ogre_plugin_directory;
__ogre_plugin_directory = ogre_plugin_directory.c_str();
Copy link
Member

Choose a reason for hiding this comment

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

Same.

@wjwwood wjwwood added enhancement New feature or request in progress Actively being worked on (Kanban column) labels Aug 31, 2017
- we don't use ament_lint_common because copyright checks fail
- we want to wait for changes in ament_copyright before fixing
- only one error: memory leak of log_manager
- SdkQtCameraMan is from OgreBites and not from rviz
- No change in functionality
@Martin-Idel
Copy link
Contributor Author

I updated the pull request making all requested changes (to simplify things, I force-pushed):

  • we don't use ament_copyright now and all copyright changes were discarded
  • the cppcheck error for the memory leak in ogre_logging and the cpplint errors for static std::strings are only ignored (no changes)

One additional comment: It would be nicer to still use ament_lint_auto with custom linting tools as specified in https://github.com/ament/ament_lint/blob/master/ament_lint_auto/doc/index.rst - but this didn't work for me, so I had to include the linters manually in CMake.

Copy link
Member

@wjwwood wjwwood left a comment

Choose a reason for hiding this comment

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

lgtm, I added a todo for the copyright linter and a comment about the delete-less free.

@wjwwood wjwwood merged commit 9d62823 into ros2:ros2 Sep 2, 2017
@wjwwood wjwwood removed the in progress Actively being worked on (Kanban column) label Sep 2, 2017
@wjwwood
Copy link
Member

wjwwood commented Sep 2, 2017

One additional comment: It would be nicer to still use ament_lint_auto with custom linting tools as specified in https://github.com/ament/ament_lint/blob/master/ament_lint_auto/doc/index.rst - but this didn't work for me, so I had to include the linters manually in CMake.

Interesting, perhaps it's worth opening an issue on the ament_lint_auto package's repository. This will work fine for now.

@mikaelarguedas
Copy link
Member

I don't know if it helps but you can bypass a specific linter by tricking cmake into not finding it and keep using ament_lint_auto for everything else (example to disable only the copyright linter here)

wjwwood pushed a commit that referenced this pull request Sep 6, 2017
* Introduce linters in rviz_rendering

- we don't use ament_lint_common because copyright checks fail
- we want to wait for changes in ament_copyright before fixing

* Fix cppcheck errors

- only one error: memory leak of log_manager

* Extract SdkQtCameraMan from OgreBites to fix linters

- SdkQtCameraMan is from OgreBites and not from rviz
- No change in functionality

* adding a todo about the copyright linter

* add a comment about delete-less new call
@anhosi anhosi deleted the feature/linting branch November 9, 2017 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[rviz_rendering] add ament linters
4 participants