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

Pass include paths to cppcheck #117

Merged
merged 16 commits into from
Jan 10, 2019
Merged

Pass include paths to cppcheck #117

merged 16 commits into from
Jan 10, 2019

Conversation

jacobperron
Copy link
Contributor

Specifically, passing the parent directories of all source files since a typical include
for a C/C++ header are located in a subdirectory named after the package or library.


Resolves #116

Test CI with cppcheck v1.86 (up to rclcpp): Build Status

@jacobperron jacobperron added the in progress Actively being worked on (Kanban column) label Dec 18, 2018
@jacobperron jacobperron added in review Waiting for review (Kanban column) and removed in progress Actively being worked on (Kanban column) labels Dec 19, 2018
@jacobperron
Copy link
Contributor Author

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

And CI machine with new version of cppcheck (v1.86)

  • macOS Build Status

@jacobperron
Copy link
Contributor Author

With lint fixes:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

cppcheck v1.86:

  • macOS Build Status

jacobperron and others added 6 commits January 3, 2019 13:18
Specifically, passing the parent directories of all source files since a typical include
for a C/C++ header are located in a subdirectory named after the package or library.
Co-Authored-By: jacobperron <jacob@openrobotics.org>
@jacobperron
Copy link
Contributor Author

I've updated the PR to use BUILDSYSTEM_TARGETS if cmake version is >= 3.7. We're not experiencing cppcheck issues for systems with older cmake versions, like Xenial, so not passing include directories (as before) should remain okay.
@dirk-thomas Please take another look.

@jacobperron
Copy link
Contributor Author

A couple issues I've identified with this approach:

  1. Passing include directories to cppcheck significantly increases the time it takes to run.
    It doesn't seem like 120s is enough in some situations. Likely need to bump the timeout >200s (maybe 300s if we can live with it).
  2. Errors are reported from included headers from outside the package being tested.
    I have a hack to handle this in e67e564.

Thoughts?

…being tested

This eliminates the need for a longer test timeout and avoids cppcheck from testing external files.
Reverted prior changes accordingly.
@jacobperron
Copy link
Contributor Author

jacobperron commented Jan 8, 2019

Attempt to resolve timeout issue and errors from external packages by only including headers from the package being tested.

@jacobperron
Copy link
Contributor Author

jacobperron commented Jan 9, 2019

Ready for another round of review.

Passing include directories to cppcheck uncovered a potential issue in rcl (fixed in ros2/rcl#371). It's possible there will be more uncovered issues.

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

@jacobperron
Copy link
Contributor Author

CI is good. The one cppcheck error is handled by ros2/rcl#371.

@jacobperron
Copy link
Contributor Author

CI (linter tests only):

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

@jacobperron jacobperron merged commit 8d2ef3b into master Jan 10, 2019
@jacobperron jacobperron deleted the pass_include_cppcheck branch January 10, 2019 01:55
@jacobperron jacobperron removed the in review Waiting for review (Kanban column) label Jan 10, 2019
PROPERTY INCLUDE_DIRECTORIES
)

# Only append include directories that are from the package being tested
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sloretz See #125.

You can pass cppcheck one or more include directories that contain the macros it is trying to resolve.
I'm not satisfied with the solution, but I think anything better would require changes in cppcheck itself.

Copy link
Contributor

Choose a reason for hiding this comment

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

thanks, I missed that PR

# Only append include directories that are from the package being tested
# This accomplishes two things:
# 1. Reduces execution time (less include directories to search)
# 2. cppcheck will not check for errors in external packages
Copy link
Contributor

Choose a reason for hiding this comment

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

This fails on Windows in this case: ros2/ros2#942.

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 don't understand the case that's failing. From the referenced ticket, it looks like the failures are due to headers from external packages not being passed to cppcheck (which is the intended behavior). For this case, we have ament_cmake_cppcheck_ADDITIONAL_INCLUDE_DIRS that can be set (introduced in #125).

Copy link
Contributor

Choose a reason for hiding this comment

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

Without the proper include directories cppcheck warns for unknown macros.

ros2/rclpy#577 sets an additional include dir.

Sign up for free to 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.

4 participants