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

Suppress internalAstError #219

Merged
merged 1 commit into from
Mar 10, 2020
Merged

Conversation

rotu
Copy link
Contributor

@rotu rotu commented Mar 10, 2020

cppcheck can, in some cases, construct an invalid parse tree.
http://build.ros2.org/user/rotu/my-views/view/CycloneDDS/job/Fci__nightly-cyclonedds_ubuntu_focal_amd64/lastCompletedBuild/testReport/rclcpp/cppcheck/error__internalAstError__src_rclcpp_clock_cpp_159_/

- rclcpp.cppcheck error: internalAstError (src/rclcpp/clock.cpp:159)
  <<< failure message
    Syntax Error: AST broken, 'if' doesn't have two operands.
  >>>

This error sounds like a syntax error, but is in fact, not. (cppcheck doesn't seem to even find the syntax error in if(1,1){})
This commit causes such errors to be silently ignored, as they are not actionable.
Signed-off-by: Dan Rose dan@digilabs.io

Copy link
Contributor

@dirk-thomas dirk-thomas left a comment

Choose a reason for hiding this comment

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

Wouldn't it be better to mark the specific file as "skipped" to not pretend it was checked when it actually wasn't?

ament_cppcheck/ament_cppcheck/main.py Outdated Show resolved Hide resolved
`cppcheck` can, in some cases, construct an invalid parse tree.
http://build.ros2.org/user/rotu/my-views/view/CycloneDDS/job/Fci__nightly-cyclonedds_ubuntu_focal_amd64/lastCompletedBuild/testReport/rclcpp/cppcheck/error__internalAstError__src_rclcpp_clock_cpp_159_/

```
- rclcpp.cppcheck error: internalAstError (src/rclcpp/clock.cpp:159)
  <<< failure message
    Syntax Error: AST broken, 'if' doesn't have two operands.
  >>>
```
This error sounds like a syntax error, but is in fact, not. (cppcheck doesn't seem to even find the syntax error in `if(1,1){}`)
This commit causes such errors to be silently ignored, as they are not actionable.
Signed-off-by: Dan Rose <dan@digilabs.io>

Signed-off-by: Dan Rose <dan@digilabs.io>
@rotu
Copy link
Contributor Author

rotu commented Mar 10, 2020

Wouldn't it be better to mark the specific file as "skipped" to not pretend it was checked when it actually wasn't?

It does continue to find errors, just so long as they don't depend on that part of the AST. Adding int x=1; both inside and outside the mis-parsed if statement flags the missing space in both places.

@dirk-thomas
Copy link
Contributor

Thanks for details. Sounds reasonable then.

@dirk-thomas
Copy link
Contributor

(Will merge without CI since ci.ros2.org has issues at the moment and this option is available in cppcheck on Bionic so I don't expect any regressions.)

@dirk-thomas dirk-thomas merged commit c34c8ba into ament:master Mar 10, 2020
@dirk-thomas dirk-thomas added the enhancement New feature or request label Mar 10, 2020
@rotu rotu deleted the pr-2 branch April 8, 2020 20:12
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.

None yet

2 participants