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

Cannot satisfy both cpplint and uncrustify #158

Open
ivanpauno opened this issue Jul 24, 2019 · 10 comments
Open

Cannot satisfy both cpplint and uncrustify #158

ivanpauno opened this issue Jul 24, 2019 · 10 comments
Labels
help wanted Extra attention is needed

Comments

@ivanpauno
Copy link

I've seen one case, where I can't make both pass (maybe, it's just my error).

If you have an else if, where the condition have to be split in two lines because it's too long, e.g.:

if (...) {
  ...
} else if ( <long condition
  that uses more than one line>)
{
  ...
}

cpplint shows this failure:
If an else has a brace on one side, it should have it on both [readability/braces] [5]

For every other possibility I've tried, uncrustify don't pass.
For example:

if (...) {
  ...
} else if ( <long condition
  that uses more than one line>) {
    ...
}
if (...) {
  ...
}
else if ( <long condition
  that uses more than one line>)
{
  ...
}

The only way of working it around, is putting the if clause nested in the else. But that's only acceptable for one else if, not for multiple.
e.g.:

if (...) {
  ...
} else {
  if ( <long condition
    that uses more than one line>)
  {
    ...
  }
}

Triggered by ros2/rclcpp#778 (comment).
I've also used the last workaround somewhere else (I don't remember where).

@ivanpauno
Copy link
Author

IMHO, the first snippet I posted should pass without failures.

@dirk-thomas
Copy link
Contributor

dirk-thomas commented Jul 24, 2019

Neither of the snippets complies with our text-form style guide. The long condition should be wrapped directory after the open parenthesis:

} else if (
  <long condition
  that uses more than one line>
) {

@ivanpauno
Copy link
Author

ivanpauno commented Jul 24, 2019

Neither of the snippets complies with our text-form style guide. It should be:

} else if (
  <long condition
  that uses more than one line>
) {

I tried that, but uncrustify didn't like it:

40: --- include/rclcpp/intra_process_manager.hpp
40: +++ include/rclcpp/intra_process_manager.hpp.uncrustify
40: @@ -273,2 +273,2 @@
40: -      sub_ids.take_shared_subscriptions.size() <= 1
40: -    ) {
40: +      sub_ids.take_shared_subscriptions.size() <= 1)
40: +    {
40: @@ -290,2 +290,2 @@
40: -      sub_ids.take_shared_subscriptions.size() > 1
40: -    ) {
40: +      sub_ids.take_shared_subscriptions.size() > 1)
40: +    {
40: 
40: 1 files with code style divergence

The complete snippet:

    } else if (
      !sub_ids.take_ownership_subscriptions.empty() &&
      sub_ids.take_shared_subscriptions.size() <= 1
    ) {
    } else if (
      !sub_ids.take_ownership_subscriptions.empty() &&
      sub_ids.take_shared_subscriptions.size() > 1
    ) {

P.S.: If I follow uncrustify suggestion, cpplint doesn't pass.

@rotu
Copy link
Contributor

rotu commented Aug 2, 2019

fyi: uncrustify/uncrustify#2360

@asorbini
Copy link

asorbini commented Apr 3, 2021

I just ran into this same issue while working on rmw_connextdds#22

@clalancette
Copy link
Contributor

Updating to a newer uncrustify may fix it, but that always has additional fallout. It's not something we are going to do right now, but we could consider updating uncrustify in H-Turtle.

@clalancette clalancette added the help wanted Extra attention is needed label Apr 22, 2021
@AndyZe
Copy link

AndyZe commented Apr 26, 2021

You can get around this by skipping cpplint for the line: // NOLINT

cpplint/cpplint#35

hsd-dev added a commit to hsd-dev/ros1_bridge that referenced this issue Jan 13, 2022
added NOLINT whenever both cpplint and uncrustify cannot be satisfied
ament/ament_lint#158

Signed-off-by: Harsh Deshpande <harshavardhan.deshpande@ipa.fraunhofer.de>
hsd-dev added a commit to hsd-dev/ros1_bridge that referenced this issue Jan 13, 2022
added NOLINT whenever both cpplint and uncrustify cannot be satisfied
ament/ament_lint#158

Signed-off-by: Harsh Deshpande <harshavardhan.deshpande@ipa.fraunhofer.de>
@clalancette
Copy link
Contributor

So we actually did update both cpplint and uncrustify for Humble. @ivanpauno Can you give this another try on Rolling and see if your original issue is solved?

@ivanpauno
Copy link
Author

I still can reproduce this.
I think we will need to modify our uncrustify settings to make it work (or if possible, delete/modify this check from cpplint).

@padhupradheep
Copy link

any updates guys?

hsd-dev added a commit to hsd-dev/ros1_bridge that referenced this issue Jun 16, 2022
added NOLINT whenever both cpplint and uncrustify cannot be satisfied
ament/ament_lint#158

Signed-off-by: Harsh Deshpande <harshavardhan.deshpande@ipa.fraunhofer.de>
hsd-dev added a commit to hsd-dev/ros1_bridge that referenced this issue Jun 16, 2022
added NOLINT whenever both cpplint and uncrustify cannot be satisfied
ament/ament_lint#158

Signed-off-by: Harsh Deshpande <harshavardhan.deshpande@ipa.fraunhofer.de>
hsd-dev added a commit to hsd-dev/ros1_bridge that referenced this issue Jul 6, 2022
added NOLINT whenever both cpplint and uncrustify cannot be satisfied
ament/ament_lint#158

Signed-off-by: Harsh Deshpande <harshavardhan.deshpande@ipa.fraunhofer.de>
benmaidel pushed a commit to benmaidel/ros1_bridge that referenced this issue Sep 15, 2022
added NOLINT whenever both cpplint and uncrustify cannot be satisfied
ament/ament_lint#158

Signed-off-by: Harsh Deshpande <harshavardhan.deshpande@ipa.fraunhofer.de>
benmaidel pushed a commit to mojin-robotics/ros1_bridge that referenced this issue Sep 20, 2022
added NOLINT whenever both cpplint and uncrustify cannot be satisfied
ament/ament_lint#158

Signed-off-by: Harsh Deshpande <harshavardhan.deshpande@ipa.fraunhofer.de>
hsd-dev added a commit to hsd-dev/ros1_bridge that referenced this issue Mar 27, 2023
added NOLINT whenever both cpplint and uncrustify cannot be satisfied
ament/ament_lint#158

Signed-off-by: Harsh Deshpande <harshavardhan.deshpande@ipa.fraunhofer.de>
hsd-dev added a commit to hsd-dev/ros1_bridge that referenced this issue Mar 27, 2023
added NOLINT whenever both cpplint and uncrustify cannot be satisfied
ament/ament_lint#158

Signed-off-by: Harsh Deshpande <harshavardhan.deshpande@ipa.fraunhofer.de>
ErickKramer pushed a commit to ErickKramer/ros1_bridge that referenced this issue Jun 12, 2023
added NOLINT whenever both cpplint and uncrustify cannot be satisfied
ament/ament_lint#158

Signed-off-by: Harsh Deshpande <harshavardhan.deshpande@ipa.fraunhofer.de>
ErickKramer pushed a commit to ErickKramer/ros1_bridge that referenced this issue Oct 26, 2023
added NOLINT whenever both cpplint and uncrustify cannot be satisfied
ament/ament_lint#158

Signed-off-by: Harsh Deshpande <harshavardhan.deshpande@ipa.fraunhofer.de>
abencz pushed a commit to locusrobotics/ros1_bridge that referenced this issue Jan 16, 2024
added NOLINT whenever both cpplint and uncrustify cannot be satisfied
ament/ament_lint#158

Signed-off-by: Harsh Deshpande <harshavardhan.deshpande@ipa.fraunhofer.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

7 participants